HEADLESS=true npx codecept run

HI

Does anyone can help me on fixing below error, am new to this configuration

HEADLESS=true npx codecept run
HEADLESS=true : The term ‘HEADLESS=true’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that
the path is correct and try again.
At line:1 char:1

  • HEADLESS=true npx codecept run
  •   + CategoryInfo          : ObjectNotFound: (HEADLESS=true:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

The examples should be compatible with Linux and MacOS.
What’s your OS?

i am on Windows 10, i thought its just .env configuration, is there any way i can use these arguments?

Thank you for your response

You can try:

set HEADLESS=true
npx codeceptjs run

Thank you so much, it worked.

For me, I need to use this command: $env:HEADLESS=“true”

Nothing seems to be working for me:

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

setHeadlessWhen(process.env.HEADLESS);

exports.config = {

output: ‘./output’,

helpers: {

Playwright: {

  url: 'https://www.steadfast.com.au/',

  show: true,

  browser: 'chromium'

},

It always takes what is mentioned inside Playwright settings.

I am trying this on my windows 10 machine:

$env:HEADLESS=“true”; npx codeceptjs run --steps
$env:HEADLESS=“false”; npx codeceptjs run --steps

And in both the cases, the tests run in headless mode.

That’s because environment variables are always strings and setHeadlessWhen dont do type conversion. Set $env:HEADLESS = "" for workaround.

@davert , worth the change?

1 Like