diff --git a/spec/integration/helpers/start-atom.coffee b/spec/integration/helpers/start-atom.coffee index ad40bcb92..8597dabdd 100644 --- a/spec/integration/helpers/start-atom.coffee +++ b/spec/integration/helpers/start-atom.coffee @@ -60,9 +60,9 @@ buildAtomClient = (args, env) -> .windowHandles(cb) .addCommand "waitForPaneItemCount", (count, timeout, cb) -> - @waitUntil( - (-> @execute((-> atom.workspace.getActivePane().getItems().length)).then ({value}) -> value is count), - timeout) + @waitUntil((-> + @execute(-> atom.workspace?.getActivePane()?.getItems().length) + .then(({value}) -> value is count)), timeout) .then (result) -> expect(result).toBe(true) cb(null) @@ -95,15 +95,17 @@ module.exports = (args, env, fn) -> "--url-base=/wd/hub" ]) + waits(50) + + chromedriverLogs = [] chromedriverExit = new Promise (resolve) -> errorCode = null - logs = [] chromedriver.on "exit", (code, signal) -> errorCode = code unless signal? chromedriver.stderr.on "data", (log) -> - logs.push(log.toString()) + chromedriverLogs.push(log.toString()) chromedriver.stderr.on "close", -> - resolve({errorCode, logs}) + resolve(errorCode) waitsFor("webdriver to finish", (done) -> finish = once -> @@ -111,18 +113,18 @@ module.exports = (args, env, fn) -> .end() .then(-> chromedriver.kill()) .then(chromedriverExit.then( - ({errorCode, logs}) -> + (errorCode) -> if errorCode? jasmine.getEnv().currentSpec.fail """ Chromedriver exited with code #{errorCode}. - Logs:\n#{logs.join("\n")} + Logs:\n#{chromedriverLogs.join("\n")} """ done())) client = buildAtomClient(args, env) - client.on "error", ({body}) -> - jasmine.getEnv().currentSpec.fail(body) + client.on "error", (err) -> + jasmine.getEnv().currentSpec.fail(JSON.stringify(err)) finish() fn(client.init()).then(finish) diff --git a/spec/integration/startup-spec.coffee b/spec/integration/startup-spec.coffee index 95995f6dc..4cc5b1525 100644 --- a/spec/integration/startup-spec.coffee +++ b/spec/integration/startup-spec.coffee @@ -46,6 +46,7 @@ describe "Starting Atom", -> # Opening an existing file in the same directory reuses the window and # adds a new tab for the file. .startAnotherAtom([tempFilePath], ATOM_HOME: AtomHome) + .waitForExist("atom-workspace") .waitForPaneItemCount(2, 5000) .waitForWindowCount(1, 1000) .execute(-> atom.workspace.getActiveTextEditor().getText()) @@ -57,7 +58,6 @@ describe "Starting Atom", -> @startAnotherAtom([otherTempDirPath], ATOM_HOME: AtomHome) , 5000) .waitForExist("atom-workspace", 5000) - .then((exists) -> expect(exists).toBe true) .waitForPaneItemCount(0, 1000) it "saves the state of closed windows", -> @@ -69,6 +69,7 @@ describe "Starting Atom", -> .waitForNewWindow(-> @startAnotherAtom([otherTempDirPath], ATOM_HOME: AtomHome) , 5000) + .waitForExist("atom-workspace", 5000) .waitForPaneItemCount(0, 3000) .execute(-> atom.workspace.open()) .waitForPaneItemCount(1, 3000) @@ -81,6 +82,7 @@ describe "Starting Atom", -> .waitForNewWindow(-> @startAnotherAtom([otherTempDirPath], ATOM_HOME: AtomHome) , 5000) + .waitForExist("atom-workspace", 5000) .waitForPaneItemCount(1, 5000) it "allows multiple project directories to be passed as separate arguments", -> @@ -94,6 +96,7 @@ describe "Starting Atom", -> # Opening a file in one of the directories reuses the same window # and does not change the project paths. .startAnotherAtom([tempFilePath], ATOM_HOME: AtomHome) + .waitForExist("atom-workspace", 5000) .waitForPaneItemCount(1, 5000) .execute(-> atom.project.getPaths()) .then(({value}) -> expect(value).toEqual([tempDirPath, otherTempDirPath]))