E.g.
features/
|- a.test.js
|- a-folder/
|-a.nother.test.js
E.g.
features/
|- a-folder/
|-a.test.js
or
features/
|- a.test.js
|- b.test.js
|- c.test.js
The tests are currently loaded form the pattern options, called 'tests'. This is the section of code that globs the pattern and adds each file path it finds to a list of file paths to be loaded
https://github.com/Codeception/CodeceptJS/blob/master/lib/codecept.js#L94-L99
tl;dr? Don;t worry, this is what it looks like
loadTests(pattern) {
pattern = pattern || this.config.tests;
glob.sync(fsPath.resolve(global.codecept_dir, pattern)).forEach((file) => {
this.testFiles.push(fsPath.resolve(file));
});
}
And...
....this is what I propose
loadTests(pattern) {
pattern = pattern || this.config.tests;
glob.sync(fsPath.resolve(global.codecept_dir, pattern)).forEach((file) => {
if (fs.lstatSync(file).isDirectory()) {
loadTests(fsPath.resolve(global.codecept_dir, `${pattern}/*`));
} else {
this.testFiles.push(fsPath.resolve(file));
}
});
}
^ Check if the value is a folder, if so resolves the path and recurse through the loadTests method until it reaches a file, then add that file path to the list of file paths to be loaded
@JoeChapman ./tests/**/*_test.js in codecept.json will search tests recurcive in test folder
@APshenkin you are correct, thank you.
Nice very helpful!
Most helpful comment
@JoeChapman
./tests/**/*_test.jsin codecept.json will search tests recurcive in test folder