Search code examples
javascriptplaywright

how to pass parameter from npx command to playright.config.js file


i have this axios report in playwright.config.js file reporter: [['junit', { outputFile: 'results.xml' }],['./aio-reporter.js']],

now I want to pass a parameter to the report when I'm running the test from the command line ex: reporter: [['junit', { outputFile: 'results.xml' }],['./aio-reporter.js'], let testcycle],

npx playwright test --testcycle=TC-TY-2


Solution

  • One option that is simple to implement would be to just use an environment variable in this case to pass in that value. You could run the command like so:

    TESTCYCLE=“TC-TY-2” npx playwright test
    

    And then you can reference that value in the code as process.env.TESTCYCLE