I've been using nightwatch.js
for functional test automation. The problem is that the test is pausing when the test suite is finished. It doesn't end the process. The code looks like this :
var afterSuite = function(browser) {
dbFixture.deleteCollectionItemById(companyId, 'cilents');
dbFixture.deleteCollectionItemById(customerId, 'users');
dbFixture.deleteCollectionItemById(assetId, 'assets');
dbFixture.deleteFile(imageId);
browser.end();
};
var loginTest = function(browser) {
dbFixture.createCompany(function(company) {
dbFixture.createCustomer(company._id, function(customer, assetid, imageid) {
companyId = company._id;
customerId = customer._id;
assetId = assetid;
imageId = imageid;
goTo.goTo(url.localhost_home + url.login, browser);
login.loginAsAny(customer.email, browser);
newCustomerLoginAssert.assertNewCustomerLogin(browser);
});
});
};
module.exports = {
after: afterSuite,
'As a Customer, I should be able to login to the system once my registration has been approved': loginTest
};
I also tried adding done();
in afterSuite
but still no success. Thanks in advance!
An approach is to register a global reporter
function that is run once all tests have finished and exits the process accordingly ie. if tests have failed or errored, exit 1
, otherwise exit 0
.
eg. http://nightwatchjs.org/guide#external-globals
In your nightwatch.json
config add:
{
"globals_path": "./config/global.js"
}
Then in ./config/global.js
module.exports = {
/**
* After all the tests are run, evaluate if there were errors and exit appropriately.
*
* If there were failures or errors, exit 1, else exit 0.
*
* @param results
*/
reporter: function(results) {
if ((typeof(results.failed) === 'undefined' || results.failed === 0) &&
(typeof(results.error) === 'undefined' || results.error === 0)) {
process.exit(0);
} else {
process.exit(1);
}
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With