'How to organize codeception tests in subfolders, and have one codecept.conf.js pointing to the whole folder schema
I'm having issues, creating subfolders in my './acceptance_tests.js/*_tests.js' pathname within my codecept config.
I.e. My codecept.conf.js looks like this:
exports.config = {
tests: './acceptance_tests/*_test.js',
output: './output' ....
I can run tests no problem that are within acceptance_test file path when the conf.js file is set to this. When I try to create a sub-folder to organize my tests i.e. acceptance_test > account_test > (tests) or acceptance_test > registration_test > (tests).
I am unable to call those tests, since the conf file is looking for all '*test.js' file within the acceptance_test folder.
I can change the path in the conf file to explicitly point to each subfolder, but it seems there must be a better way to do this. Since I would have to change the file path each time I wanted to run tests in another subfolder.
I have tried to point it to
'./acceptance_tests/randome_subfolder_Name/*_test.js'
'*_test.js'
'./acceptance_tests/*/*_test.js'
But cant seem to get it to run all subfolders or tests within those subfolders sitting within acceptance_test folder. I have tried manually calling out the whole path when running the test like so
Npm run codeceptjs './acceptance_tests/random_subfolder_Name/andomTest_test.js'
And that doesn't work either. But the moment I take that test and drop it in the parent folder of acceptance_test - it does work.
Any help would be much appreciated.
Solution 1:[1]
In the config file you can specify it to look through subfolders with this
exports.config = {
tests: './acceptance_tests/**/*_test.js',
output: './output' ....
With the
'**'
spanning through all subfolders under acceptance_tests
Solution 2:[2]
you can run tests from any folder if you select config file manually, for example:
npx codeceptjs run --grep "test name" --config=tests/codecept.conf.js
in my case config file for all tests is located in the tests folder
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ThatBraziliann |
| Solution 2 | Rinat Makhmutov |
