Skip to content

Commit

Permalink
Catch console errors in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Jan 1, 2020
1 parent 732eba8 commit cfaa91a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/acceptance/setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import assert from 'assert'
import { setDefaultTimeout, After, Before } from 'cucumber'
import { createSession, closeSession, client, startWebDriver, stopWebDriver } from 'nightwatch-api'
import { rollbackConfigs, setConfigs, cacheConfigs } from './helpers/config'
import { getAllLogsWithDateTime } from './helpers/browserConsole.js'
import { getAllLogsWithDateTime } from './helpers/browserConsole'

const RUNNING_ON_CI = !!process.env.CI
const RUNNING_ON_SAUCELABS = !!process.env.SAUCE_USERNAME
Expand Down Expand Up @@ -71,12 +72,11 @@ After(function closeSessionForEnv () {
return closeSession()
})

After(async function tryToReadBrowserConsoleOnFailure ({ result }) {
if (result.status === 'failed') {
const logs = await getAllLogsWithDateTime('SEVERE')
if (logs.length > 0) {
console.log('\nThe following logs were found in the browser console:\n')
logs.forEach(log => console.log(log))
}
}
After(async function failIfThereIsConsoleError () {
const logs = await getAllLogsWithDateTime('SEVERE')
assert.strictEqual(
logs.length, 0,
'\nThe following errors were found in the browser console:\n' +
logs.join('\n')
)
})

0 comments on commit cfaa91a

Please sign in to comment.