如何在 package.json 脚本条目中将 JSON 字符串作为参数传递?

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

对于 Puppeteer 测试,我想使用 package.json 脚本执行 UI 测试:

"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\"}",
},

--world-parameters 参数应作为 JSON 传递。如何转义 " 字符?

所以我读到他们需要转义两次。

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

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