0

I want to use { grep: process.env.profile} in my codecept.conf.js and then e.g. Scenario(...).tag("dev") (or the same for Feature(...)). So if I run test with --profile dev , the above scenario will be executed. And it will be skipped for --profile prod.

Please help me, anyone, where I exactly use the { grep: process.env.profile} in my codecept.conf.js file.

    const { setHeadlessWhen } = require('@codeceptjs/configure');

// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

exports.config = {
  tests: './*_test.js',
  output: './output',
  helpers: {


    Puppeteer: {
      url: 'https://www.eme.com',
      show: true,
     

    }
  },
  include: {
    I: './steps_file.js'
  },
  bootstrap: null,
  mocha: {},
  name: 'extramarks_puppeteer',
  plugins: {
    pauseOnFail: {},
    retryFailedStep: {
      enabled: true
    },
    tryTo: {
      enabled: true
    },
    screenshotOnFail: {
      enabled: true
    }
  }
}
Bhupendra Singh Rautela
  • 3,406
  • 6
  • 21
  • 25

1 Answers1

0

Configure your default codecept.conf.js for local/default execution configuration.

exports.config = {
  tests: './*_test.js',
  output: './output',
  grep: 'dev',
.....

Create another conf file within the same directory for every profile you would like. (i.e. prod.conf.js)

In your prod.conf.js file you may extend your default config file by using lodash to assign what you want. Your prod.conf.js file would look like this:

const merge = require("lodash.merge");
const { config: baseConfig } = require("./codecept.conf.js");

const specificConfig = {
    grep: '',
    helpers: {
        WebDriver: {
            protocol: "http",
            host: process.env.SELENIUM_STANDALONE_CHROME_PORT_4444_TCP_ADDR || "127.0.0.1",
            port: 4444,
        },
    },
    plugins: {
        wdio: {
            enabled: false
        }
    }
};
exports.config = merge(baseConfig, specificConfig);

In order to run codeceptjs with this specific config you need to specify config file like:

npx codeceptjs -c prod.conf.js
aefluke
  • 190
  • 1
  • 5