When it comes to specifying different scripts in a package.json file, we often run into issues when trying to execute specific tests using cucumber-js with tags. This can be easily achieved via the command line by running: npx cucumber-js --tags "@taggedTest". However, attempting to do this within the scripts section leads to errors.
The scripts section typically looks like this:
...
"scripts": {
"e2e": "npx cucumber-js",
"e2e_taggedTests": "npx cucumber-js --tags \"@taggedTests\"",
"unitTests": "jest"
}
...
Even though we can escape quotation marks successfully, escaping the @ symbol seems to be causing an issue, resulting in an error message such as "Unexpected token @ in JSON at position 1097 while parsing near '...cumber-js --tags \"\@taggedTests\"". This problem doesn't seem to have a clear solution in the official documentation.
If you have any insights or suggestions on how to properly escape the @ symbol within the scripts section for execution, please share your feedback. It works seamlessly in other sections like dependencies, but tackling it in the scripts section remains a challenge.
We look forward to hearing from you!