             expect(atom.themes.stylesheetElementForId(two)).toBeNull()
             expect(atom.themes.stylesheetElementForId(three)).toBeNull()
 
+            waitsForPromise ->
+              atom.packages.activatePackage("package-with-stylesheets")
+
+            runs ->
+              expect(atom.themes.stylesheetElementForId(one)).not.toBeNull()
+              expect(atom.themes.stylesheetElementForId(two)).not.toBeNull()
+              expect(atom.themes.stylesheetElementForId(three)).not.toBeNull()
+              expect($('#jasmine-content').css('font-size')).toBe '3px'
+
+        it "assigns the stylesheet's context based on the filename", ->
+          waitsForPromise ->
             atom.packages.activatePackage("package-with-stylesheets")
-            expect(atom.themes.stylesheetElementForId(one)).not.toBeNull()
-            expect(atom.themes.stylesheetElementForId(two)).not.toBeNull()
-            expect(atom.themes.stylesheetElementForId(three)).not.toBeNull()
-            expect($('#jasmine-content').css('font-size')).toBe '3px'
-
-        it "assigns the stylesheet's context based on the filename", ->
-          atom.packages.activatePackage("package-with-stylesheets")
-          element = atom.styles.getStyleElements().find (element) -> element.context is 'test-context'
-          expect(element).toBeDefined()
+
+          runs ->
+            element = atom.styles.getStyleElements().find (element) -> element.context is 'test-context'
+            expect(element).toBeDefined()
 
       describe "grammar loading", ->
         it "loads the package's grammars", ->


            expect(atom.contextMenu.templateForElement(element)).toEqual []

            atom.packages.activatePackage("package-with-menus-manifest")

            expect(atom.menu.template[0].label).toBe "Second to Last"
            expect(atom.menu.template[1].label).toBe "Last"
            expect(atom.contextMenu.templateForElement(element)[0].label).toBe "Menu item 2"
            expect(atom.contextMenu.templateForElement(element)[1].label).toBe "Menu item 1"
            expect(atom.contextMenu.templateForElement(element)[2]).toBeUndefined()

      describe "stylesheet loading", ->
        describe "when the metadata contains a 'stylesheets' manifest", ->

          pack.mainModule.someNumber = 77
          atom.packages.deactivatePackage("package-with-serialization")
          spyOn(pack.mainModule, 'activate').andCallThrough()
          waitsForPromise ->
            atom.packages.activatePackage("package-with-serialization")
          runs ->
            expect(pack.mainModule.activate).toHaveBeenCalledWith({someNumber: 77})

      it "logs warning instead of throwing an exception if the package fails to load", ->
        atom.config.set("core.disabledPackages", [])
