 path = require('path')
 
 describe 'AutocompleteSnippets', ->
-  [workspaceElement, completionDelay, editor, editorView, snippetsMain, autocompleteMain, autocompleteManager, didAutocomplete] = []
+  [workspaceElement, completionDelay, editor, editorView, snippetsMain, autocompleteMain, autocompleteManager] = []
 
   beforeEach ->
     runs ->
-      didAutocomplete = false
       # Set to live completion
       atom.config.set('autocomplete-plus.enableAutoActivation', true)
       # Set the completion delay
       completionDelay = 100
       atom.config.set('autocomplete-plus.autoActivationDelay', completionDelay)
       completionDelay += 100 # Rendering delay
+      workspaceElement = atom.views.getView(atom.workspace)
+      jasmine.attachToDOM(workspaceElement)
       autocompleteMain = atom.packages.loadPackage('autocomplete-plus').mainModule
       spyOn(autocompleteMain, 'consumeProvider').andCallThrough()
       snippetsMain = atom.packages.loadPackage('autocomplete-snippets').mainModule

        editor.insertText('d')
        editor.insertText('o')

        advanceClock(completionDelay + 1000)

      waitsFor ->
        autocompleteManager.displaySuggestions.calls.length is 1

        editor.moveToBottom()
        editor.insertText('f')
        editor.insertText('b')
        advanceClock(completionDelay)

      waitsFor ->
        autocompleteManager.findSuggestions.calls.length is 2
