Online Training: Web test automation with CodeceptJS. Sign up now!

Accessing config in scenario


How to access the config value from a Scenario?

I would like to send params when running the scripts with -o but I struggle to understand how I can read them inside a scenario.

Ex: npx codeceptjs run --override ‘{ “data”: {“id”: 555 }}’

In a Scenario:


I would like to have the ‘555’ in the request to be dynamic.


Take a look at this config

I take a dynamic parameter, and add it to container:

After, I can access this parameter from a container:

Scenario('asdas', (I, project) => {});

Alternative solution:

First of all, thanks for your prompt replies/help.

I looked at all of them, but I was missing the part on how to make the values came from the command line (process.args) instead of process.env.

But I think the best approach in my case is to use

So now I just update the REST endpoints dynamically:

REST: { endpoint: null,

And command line sample:

npx codeceptjs run --override '{ "helpers": {"REST": {"endpoint": ""}}}'

I’m still stuck on how to send other custom params from process.args, but the solution above is a first step.

Thanks again

Ok just found this in the doc when searching for event listeners:

So now I just use let config = require('codeceptjs').config.get(); to get access to the dynamic configs.