Protractor option does not work in package.json script

北城以北 提交于 2021-02-11 12:14:15

问题


The following command works as expected:

protractor --cucumberOpts.tags='not @tag1' conf.js

Now I want to add this command as a script to package.json like this:

"scripts": {
    "my-script": "protractor --cucumberOpts.tags='not @tag1' conf.js"
}

Running the command npm run my-script gives me the following error:

Usage: protractor [configFile] [options]
configFile defaults to protractor.conf.js
The [options] object will override values from the config file.
See the reference config for a full list of options.

Options:
  ...

Error: Error: more than one config file specified

Why is that?

Both of the commands seem to be identical.


回答1:


This is not actually a protractor issue. I was able to recreate this issue and resolved it by using escaped doubles quotes in that script string like so.

"scripts": {
    "my-script": "protractor --cucumberOpts.tags=\"not @tag1\" conf.js"
}

This issue (apparently) is to do with how node handles single quotes on different operating systems. There is some more info in this question.



来源:https://stackoverflow.com/questions/55478786/protractor-option-does-not-work-in-package-json-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!