Closed alexkirillovtech closed 1 year ago
Hey @beatfactor, as discussed here https://github.com/nightwatchjs/nightwatch/issues/652, I created a new issue for problem with global hooks in example project. Please reach out with any questions, would love to help, because I really need to make this global hooks work
There is a small fix for this in 2.6.9. Can you try with this version? Is that the entire globals module?
@beatfactor I made upgrade to 2.6.9, but still can't make the hooks works.
Hooks are located in /lib/globals.js
can you post your entire globals file here?
@beatfactor yes, it looks like this `const globals = { // this controls whether to abort the test execution when an assertion failed and skip the rest // it's being used in waitFor commands and expect assertions abortOnAssertionFailure: true,
// this will overwrite the default polling interval (currently 500ms) for waitFor commands // and expect assertions that use retry waitForConditionPollInterval: 500,
// default timeout value in milliseconds for waitFor commands and implicit waitFor value for // expect assertions waitForConditionTimeout: 5000,
// this will cause waitFor commands on elements to throw an error if multiple // elements are found using the given locate strategy and selector throwOnMultipleElementsReturned: false,
// controls the timeout value for async hooks. Expects the done() callback to be invoked within this time // or an error is thrown asyncHookTimeout: 10000,
// controls the timeout value for when running async unit tests. Expects the done() callback to be invoked within this time // or an error is thrown unitTestsTimeout: 2000,
// controls the timeout value for when executing the global async reporter. Expects the done() callback to be invoked within this time // or an error is thrown customReporterCallbackTimeout: 20000,
// Automatically retrying failed assertions - You can tell Nightwatch to automatically retry failed assertions until a given timeout is reached, before the test runner gives up and fails the test. retryAssertionTimeout: 1000,
default: { myGlobal: function () { return "I'm a method"; }, isLocal: true, },
integration: { isLocal: false, },
test_env: { myGlobal: "test_global", beforeEach: function () { console.log("GLOBAL afterEach"); }, },
before(cb) { console.log("GLOBAL BEFORE"); cb(); },
beforeEach: function (browser, cb) { console.log("GLOBAL beforeEach"); cb() },
after(cb) { console.log("GLOBAL AFTER"); cb(); },
afterEach: function (browser, cb) { console.log("GLOBAL afterEach"); cb(); },
reporter(results, cb) { cb(); }, };
module.exports = globals;`
@beatfactor Is there a way how I can help you with this?
@beatfactor I found an issue, can't believe that it was so simple
In globals.js we need to specify a path for globals file
// See https://nightwatchjs.org/guide/concepts/test-globals.html globals_path: "lib/globals.js",
Hey @alexkirillovtech Since this was a configuration issue, I'm closing it for now. Please feel free to reopen if you are still facing it.
Description of the bug/issue
I am using an example that is recommended in documentation. Repo can be find here https://github.com/nightwatchjs-community/nightwatch-examples.
In globals.js We have a plenty of hooks such as before, after and etc.
The problem is that these hooks are not working no matter what I changed in configuration.
Please review it
Steps to reproduce
Sample test
Command to run
Verbose Output
No response
Nightwatch Configuration
Nightwatch.js Version
2.6.3
Node Version
19.10.1
Browser
Chrome 108.0.0
Operating System
MacOs Ventura 13.1 (22C65)
Additional Information
No response