Michael
Michael

Reputation: 7113

How to pass a JSON string as argument in a package.json script entry?

For a Puppeteer test I want to execute UI tests with a package.json script:

"scripts": {
    "test:ui": "cucumber-js --require-module ts-node/register --require test/step_definitions/**/*.ts --require test/support/**/*.ts --world-parameters {\"instanceUrl\":\"https://testserver.example.com\"}",
},

The --world-parameters argument should be passed as JSON. How do I escape the " characters?

Upvotes: 0

Views: 1256

Answers (1)

razki
razki

Reputation: 1229

So I've read they need to be escaped twice.

--world-parameters {\\\"instanceUrl\\\": \\\"https:\\\/\\\/testserver.example.com\\\"}

https://github.com/cucumber/cucumber-js/issues/1045

Upvotes: 3

Related Questions