0

I want to pass mutilple CLI arguments through npm to codeceptJS.

E.g. we use tags for device specific tests and we have different test environments. I want to do:

"e2e": "codeceptjs run --steps -c path/to/config.js --grep --profile"

So I could pass in:

npm run e2e @iPhoneX env=qa

I've tried multiple combinations but can't get it to work with both grep and profile. Any ideas?

Paul Redmond
  • 3,276
  • 4
  • 32
  • 52
  • You can't pass arguments via npm scripts like that, there's no way to interpolate what you're passing with `npm run` within the value of `e2e`. Try something like `npm run e2e -- --grep @iPhoneX --profile env=qa`. – jonrsharpe Jun 16 '20 at 13:36
  • Out scripts are setup to run in this configuration. running npm run e2e will run as expected, it's the grep and profille together that's the issue. – Paul Redmond Jun 16 '20 at 13:38
  • `--grep` won't ever work, because you always pass the arguments at the end, to `--profile`. NPM tells you this; when you run `npm run e2e @iPhoneX env=qa` it shows that it's actually running `codeceptjs run --step -c path/to/config.js --grep --profile "@iPhoneX" "env=qa"`. – jonrsharpe Jun 16 '20 at 13:42
  • @jonrsharpe Yes you're right, so is there no way to run both of these together so it does: `--grep "@iPhoneX" --profile "env=qa"` – Paul Redmond Jun 16 '20 at 13:44
  • 1
    No; again, *"there's no way to interpolate what you're passing"*, they all go at the end. You could do it via env vars, but you'd have to change how you're calling it - see e.g. https://stackoverflow.com/a/30906986/3001761. – jonrsharpe Jun 16 '20 at 13:49
  • @jonrsharpe Thanks, I'll look into env vars. I misunderstood your first comment. – Paul Redmond Jun 16 '20 at 13:52

0 Answers0