 
   beforeEach ->
     atom.workspaceView = new WorkspaceView
-    atom.workspaceView.openSync('sample.js')
+    activationPromise = null
 
-    activationPromise = atom.packages.activatePackage("command-palette")
+    waitsForPromise ->
+      atom.workspace.open('sample.js')
 
-    atom.workspaceView.attachToDom().focus()
-    atom.workspaceView.trigger 'command-palette:toggle'
+    runs ->
+      activationPromise = atom.packages.activatePackage("command-palette")
+
+      atom.workspaceView.attachToDom().focus()
+      atom.workspaceView.trigger 'command-palette:toggle'
 
     waitsForPromise ->
       activationPromise

          expect(eventLi.find('span')).toHaveText(description)
          expect(eventLi.find('span').attr('title')).toBe(eventName)
          for binding in keyBindings when binding.command is eventName
            expect(eventLi.find(".key-binding:contains(#{_.humanizeKeystroke(binding.keystroke)})")).toExist()
        else
          expect(eventLi).not.toExist()


          expect(eventLi.find('span')).toHaveText(description)
          expect(eventLi.find('span').attr('title')).toBe(eventName)
          for binding in keyBindings when binding.command is eventName
            expect(eventLi.find(".key-binding:contains(#{_.humanizeKeystroke(binding.keystrokes)})")).toExist()
        else
          expect(eventLi).not.toExist()
