It works well with 3.7.9 and doesn't work with 4.x
The behavior depends on the config setting noGlobals. If it is true (recommended in CodeceptJS 4.x), it fails on ReferenceError: Feature is not defined and no run is performed 🐛 :
mirao@rog:~/workspace/my$ codeceptjs run-rerun --verbose
Error loading test file /home/mirao/workspace/my/tests/My_test.js: ReferenceError: Feature is not defined
at file:///home/mirao/workspace/my/tests/My_test.js:1:1
at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
at async node:internal/modules/esm/loader:643:26
at async file:///home/mirao/workspace/my/node_modules/codeceptjs/lib/rerun.js:56:13
CodeceptJS v4.0.9 #StandWithUkraine
Using test root "/home/mirao/workspace/my"
Helpers: Playwright
Plugins: screenshot, retryFailedStep
OK | 0 passed // 1ms
Process run 1 of max 4, success runs 1/2
Error loading test file /home/mirao/workspace/my/tests/My_test.js: ReferenceError: Feature is not defined
at file:///home/mirao/workspace/my/tests/My_test.js:1:1
at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
at async node:internal/modules/esm/loader:643:26
at async file:///home/mirao/workspace/my/node_modules/codeceptjs/lib/rerun.js:56:13
CodeceptJS v4.0.9 #StandWithUkraine
Using test root "/home/mirao/workspace/my"
Helpers: Playwright
Plugins: screenshot, retryFailedStep
OK | 0 passed // 0ms
Process run 2 of max 4, success runs 2/2
Even if noGlobals: false, it doesn't work well - only the 1st run of the test is performed 🐛
mirao@rog:~/workspace/my$ codeceptjs run-rerun --verbose
Global functions are deprecated. Use `import { Helper, within, session } from "codeceptjs"` instead. Set `noGlobals: true` in config to disable globals.
CodeceptJS v4.0.9 #StandWithUkraine
Using test root "/home/mirao/workspace/my"
Helpers: Playwright
Plugins: screenshot, retryFailedStep
My --
[1] Starting recording promises
Timeouts:
› [Session] Starting singleton browser session
test something
› [New Session] {"ignoreHTTPSErrors":false,"acceptDownloads":true}
Scenario()
I see "Welcome to CodeceptJS!"
[1] Retrying... Attempt #2
[1] Retrying... Attempt #3
[1] Retrying... Attempt #4
[1] Error | Error err => { step.status = 'failed' step.endTime = +Da...
[1] Error | Error undefined...
[1] <teardown> Stopping recording promises
› <screenshot> Saving screenshot test_something.failed.png
› [Screenshot] output/test_something.failed.png
✖ FAILED in 1118ms
-- FAILURES:
1) My
test something:
expected web application to include "Welcome to CodeceptJS!"
+ expected - actual
+Welcome to CodeceptJS!
◯ Scenario Steps:
✖ I.see("Welcome to CodeceptJS!") at Test.<anonymous> (file://./tests/My_test.js:4:7)
◯ Artifacts:
- screenshot: /home/mirao/workspace/my/output/test_something.failed.png
◯ Metadata:
- browser: chromium
- browserVersion: 149.0.7827.55
- windowSize: 1280x720
FAIL | 0 passed, 1 failed // 1s
Fail run 1 of max 4, success runs 0/2
Error: Test run failed
at done (file:///home/mirao/workspace/my/node_modules/codeceptjs/lib/rerun.js:68:20)
at file:///home/mirao/workspace/my/node_modules/codeceptjs/lib/rerun.js:75:25
at done (/home/mirao/workspace/my/node_modules/mocha/lib/mocha.js:1000:7)
CodeceptJS v4.0.9 #StandWithUkraine
Using test root "/home/mirao/workspace/my"
Helpers: Playwright
Plugins: screenshot, retryFailedStep
OK | 0 passed // 0ms
Process run 2 of max 4, success runs 1/2
CodeceptJS v4.0.9 #StandWithUkraine
Using test root "/home/mirao/workspace/my"
Helpers: Playwright
Plugins: screenshot, retryFailedStep
OK | 0 passed // 0ms
Process run 3 of max 4, success runs 2/2
codecept.conf.js:
import { setHeadlessWhen, setCommonPlugins } from '@codeceptjs/configure';
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);
// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();
/** @type {CodeceptJS.MainConfig} */
export const config = {
tests: './tests/*_test.js',
output: './output',
helpers: {
Playwright: {
browser: 'chromium',
url: 'http://localhost',
show: true
}
},
include: {
I: './steps_file.js'
},
noGlobals: true,
plugins: {},
rerun: {
// how many times all tests should pass
minSuccess: 2,
// how many times to try to rerun all tests
maxReruns: 4,
},
name: 'my'
}
tests/My_test.js:
Feature('My');
Scenario('test something', ({ I }) => {
I.see('Welcome to CodeceptJS!');
});
Used SW:
It works well with 3.7.9 and doesn't work with 4.x
The behavior depends on the config setting
noGlobals. If it istrue(recommended in CodeceptJS 4.x), it fails onReferenceError: Feature is not definedand no run is performed 🐛 :Even if
noGlobals: false, it doesn't work well - only the 1st run of the test is performed 🐛codecept.conf.js:
tests/My_test.js:
Used SW: