简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM