What are you trying to achieve?
I am developing a Yii2 module that is designed for applications with both frontend and backend components, requiring separate test configurations. To simplify configuration management, I created a base configuration file, codeception.base.yml, which contains common settings such as database, Yii2 modules, and paths. Then, I extended this base configuration in two separate codeception.yml files for the frontend and backend.
However, I noticed that when I define the params: - .env in the base configuration file, Codeception ignores it during test execution. The .env file is not loaded, which causes the tests to fail. If I explicitly define the params: - .env in each extended configuration file, then everything works as expected.
What do you get instead?
The tests fail to run correctly because the environment variables from .env are not being loaded from the base configuration file. If i run with debug-d enabled there is not call to any params loader.
Code Example
Here is an example of my setup:
codeception.base.yml:
paths:
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
modules:
enabled:
- Yii2:
configFile: 'config/test.php'
- Db:
dsn: 'mysql:host=127.0.0.1;dbname=testdb'
user: 'root'
password: '%MYSQL_PASS%'
populate: false
cleanup: false
params:
- .env
frontend/codeception.yml:
extends: ../codeception.base.yml
# i also set here the custom config file for yii2 module
paths:
tests: frontend/tests
output: frontend/tests/_output
support: frontend/tests/_support
envs: frontend/tests/_envs
backend/codeception.yml:
extends: ../codeception.base.yml
# i also set here the custom config file for yii2 module
paths:
tests: backend/tests
output: backend/tests/_output
support: backend/tests/_support
envs: backend/tests/_envs
When params: - .env is only defined in codeception.base.yml, it is ignored. But if I add it to each codeception.yml like this, the tests run successfully:
Details
- Codeception version: 4.2.2
- PHP Version: php8.1
- Operating System: MacOs
- Installation type: Composer
- List of installed packages: (skipped since is huge: +100)
What are you trying to achieve?
I am developing a Yii2 module that is designed for applications with both frontend and backend components, requiring separate test configurations. To simplify configuration management, I created a base configuration file,
codeception.base.yml, which contains common settings such as database, Yii2 modules, and paths. Then, I extended this base configuration in two separatecodeception.ymlfiles for the frontend and backend.However, I noticed that when I define the
params: - .envin the base configuration file, Codeception ignores it during test execution. The.envfile is not loaded, which causes the tests to fail. If I explicitly define theparams: - .envin each extended configuration file, then everything works as expected.What do you get instead?
The tests fail to run correctly because the environment variables from
.envare not being loaded from the base configuration file. If i run with debug-denabled there is not call to any params loader.Code Example
Here is an example of my setup:
codeception.base.yml:frontend/codeception.yml:backend/codeception.yml:When
params: - .envis only defined incodeception.base.yml, it is ignored. But if I add it to eachcodeception.ymllike this, the tests run successfully:Details