I am using mocha and selenium to do end to end integration testing. I am using beforeEach and afterEach hook to initialize browser and kill it after each test. Here is my js file which has both the methods
const webdriver = require('selenium-webdriver')
require('selenium-webdriver/chrome')
require('chromedriver')
global.driver = {}
// setup
beforeEach(async function () {
this.timeout(60000)
try {
driver = await new webdriver.Builder().forBrowser('chrome').build()
await driver.manage().window().setSize(1600, 900)
} catch (ex) {
console.log(ex.stack)
}
})
afterEach(async function () {
this.timeout(60000)
if (driver === null) {
console.log('some problem in before each of the test ' + this.currentTest.title + ' returning...')
return
}
await driver.quit()
})
Now when i run the test suit on jenkins i very frequently see this ("email already registered" is a test name)
✓ email domain not allowed (4167ms)
1) "before each" hook for "email already registered"
some problem in before each of the test email already registered returning...
39 passing (9m)
1 pending
1 failing
1) "before each" hook for "email already registered":
Error: Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
The thing to notice is that once this error comes the subsequent tests do not run. My test suit has 100s of tests and in the run above it quit once it encountered this beforeEach error and didn't run next set of tests.
I have tried various things but nothing seems to work. Any pointer in debugging this will be very helpful. Thanks in advance.
via Raghvendra Singh
No comments:
Post a Comment