question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Codeceptjs doesn't support to use minimist to pass environment variable

See original GitHub issue

What are you trying to achieve?

Using minimist to use -e to passing environment variable. For example adding the following script in package.json

"ci_xxx": "codeceptjs run -c codecept.ci.conf.js --grep @test -e prod",
"stage_xxx": "codeceptjs run -c codecept.ci.conf.js --grep @test -e staging",
"local_xxx": "codeceptjs run -c codecept.ci.conf.js --grep @test -e dev",

What do you get instead?

an error:

unknown option `-e'

Details

It looks like all the supported args are already pre-defined here: https://github.com/codeceptjs/CodeceptJS/blob/3.x/bin/codecept.js

Can we update codeceptjs to support to use minimist? Much Thanks!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
PeterNgTrcommented, Jul 20, 2022

hey @YSuMinto how about using this https://www.npmjs.com/package/dotenv?

Creating the according .env files like .dev.env, etc. In your codecept.conf.js:

...
switch (process.env.ENV) {
  case 'dev':
    require('dotenv').config({ path: '.dev.env' });
    break;
  case 'prod':
    require('dotenv').config({ path: '.prod.env' });
    break;
  default:
    require('dotenv').config({ path: '.staging.env' });
}
...

following script in package.json

"ci_xxx": "export ENV=prod && codeceptjs run -c codecept.ci.conf.js --grep @test",
"stage_xxx": "export ENV=staging && codeceptjs run -c codecept.ci.conf.js --grep @test",
"local_xxx": "export ENV=dev && codeceptjs run -c codecept.ci.conf.js --grep @test",

Then I believe you’d achieve the same expectations.

0reactions
DavertMikcommented, Aug 21, 2022

Yes, we don’t support minimist as we use different option to parse arguments and options.

to introduce custom options use environment variables:

TEST_ENV=production codeceptjs run
``
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration - CodeceptJS
CodeceptJS configuration is set in codecept.conf.js file. After running codeceptjs init it should be saved in test root.
Read more >
Codeception/CodeceptJS - Gitter
Hi, I am trying to use codeceptjs with appium for mobile web browser testing. When I am trying to run the scenarios, I...
Read more >
npm - Snyk
@alancnet/fantasy-names · @alexamies/chinesedict-js · @alifd/next · @alpacahq/alpaca-trade-api · @amcharts/amcharts3-angular · @amcharts/amcharts4 ...
Read more >
Test Environment Variables - Codeceptjs-BDD
This post walks you through creating and using environment variables, aka Test Properties. ⚙️ Types of ENV files. codecept.env. Common configuration defaults ...
Read more >
Experts for groupby lodash - Linknovate
You can also use the name, however in most cases, the names would not match ... We can also pass in the dogs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found