         minimap.decorateMarker(editor.markBufferRange([[100,3], [100,5]]), type: 'highlight-under', color: '#0000FF')
 
         editor.setScrollTop(0)
-        nextAnimationFrame()
-
-        expect(minimapElement.drawHighlightDecoration).toHaveBeenCalled()
-        expect(minimapElement.drawHighlightDecoration.calls.length).toEqual(2)
+
+        waitsFor -> nextAnimationFrame isnt noAnimationFrame
+        runs ->
+          nextAnimationFrame()
+
+          expect(minimapElement.drawHighlightDecoration).toHaveBeenCalled()
+          expect(minimapElement.drawHighlightDecoration.calls.length).toEqual(2)
 
       it 'renders the visible outline decorations', ->
         spyOn(minimapElement, 'drawHighlightOutlineDecoration').andCallThrough()

        atom.config.set 'editor.preferredLineLength', 2

        atom.config.set 'minimap.adjustMinimapWidthToSoftWrap', true
        waitsFor -> minimapElement.frameRequested
        runs -> nextAnimationFrame()


        minimap.decorateMarker(editor.markBufferRange([[100,3], [100,5]]), type: 'highlight-outline', color: '#0000ff')

        editor.setScrollTop(0)

        waitsFor -> nextAnimationFrame isnt noAnimationFrame
        runs ->
          nextAnimationFrame()

          expect(minimapElement.drawHighlightOutlineDecoration).toHaveBeenCalled()
          expect(minimapElement.drawHighlightOutlineDecoration.calls.length).toEqual(4)

      describe 'when the editor is scrolled', ->
        beforeEach ->
          editor.setScrollTop(2000)
          editor.setScrollLeft(50)

          waitsFor -> nextAnimationFrame isnt noAnimationFrame
          runs -> nextAnimationFrame()

        it 'updates the visible area', ->
          expect(realOffsetTop(visibleArea)).toBeCloseTo(minimap.getTextEditorScaledScrollTop() - minimap.getScrollTop(), 0)
