Using the @ symbol in package.json for scripts (in this scenario: executing cucumber-js for tagged features)

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!

Answer №1

Why bother using quotes to mention tags when you can simply use them without? I tested it out with the repository here and it worked perfectly by just adding --tags @test

Answer №2

No need to enclose the tag expression in quotes unless it includes spaces (such as a complex one like @foo or @bar).

For more information, check out:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to compare the elements of an array with those of another array containing nested arrays in order to identify matching results?

Every user in our database has specific skills assigned to them. We maintain a list of available skills with unique IDs. The objective is to filter users based on the skill we are interested in, like displaying all Janitors. We are utilizing Vue.js and im ...

I encountered an issue when sending a PATCH request via Hoppscotch where the request body content was returned as 'undefined', although the username and ID were successfully

const express = require("express"); const app = express(); const path = require("path"); let port = 8080; const { v4: uuidv4 } = require('uuid'); app.use(express.urlencoded({extended: true})); app.set("views engine", ...

The redirection code is not being executed when calling .pipe() before .subscribe()

My AuthService has the following methods: signUp = (data: SignUp): Observable<AuthResponseData> => { const endpoint = `${env.authBaseUrl}:signUp?key=${env.firebaseKey}`; return this._signInOrSignUp(endpoint, data); }; signIn = (data: SignIn): ...

Incorporate the function's output into an <img> tag within an

I am trying to utilize the output of a JavaScript function to populate the 'src' attribute of IMG tags. I plan to implement this in multiple locations on the same page, otherwise I could have used an ID in the IMG tag and update src with getEleme ...

Tips for retrieving multiple values or an array from an AJAX request?

Is there a correct way to pass multiple sets (strings) of data back after executing an ajax call in php? I understand that echo is typically used to send a single string of data back, but what if I need to send multiple strings? And how should I handle th ...

Next.js allows for dynamic page routing using the `useState` hook to redirect users

In my Next.js project, I am using the useState hook to render different components based on the button a user clicks. The main page, called account.js in the application, contains the following code: // Importing react and getting components import React f ...

How is it possible that my array becomes reversed without any intervention on my part?

As I work on developing a website, I encountered a puzzling issue with the calculations inside the router. Despite initializing the array tomato with the desired values, it seems that the values get reversed just before rendering the page. Here is the code ...

What steps should I take to address the error message "TypeError: express-validator is not a function

I am currently utilizing express-validator version 6.4.0 and encountering an error when running the server. I have attempted to implement custom validation by organizing separate files for validator, controller, and routes. Here is the primary server file ...

Angular 4's Mddialog experiencing intermittent display problem

While using MDDialog in my Angular app, I've encountered a couple of issues. Whenever a user clicks on the div, flickering occurs. Additionally, if the user then clicks on one of the buttons, the afterclose event is not triggered. Can anyone provide ...

Combining keys array and values array to create an object in JavaScript

I currently have the following arrays: var keys = [ "color", "size" ]; var values = [ "blue", "medium" ]; My goal is to transform them into an object like this: { color: "blue", size: "medium" } In Python, you can achieve this easily with dict(zip(keys ...

A menu bar featuring dual color schemes for visual differentiation

I am currently designing a navigation bar where one category stands out with a different color (blue) compared to the rest (green). The functionality I'm aiming for is that when the cursor moves away from the blue HOME category, it should change back ...

Activate fullscreen mode in Krpano on desktop by clicking a button

Is there a way to activate fullscreen mode upon clicking a button? I believe I should use the code: krpano.set(fullscreen,true); Currently, I have an image within a slideshow that includes a play button overlay. Once the button is clicked, the slideshow ...

Encountering issues with Gatsby develop functionality following project creation

After creating a Gatsby project, I encountered an error every time I tried to run gatsby develop or npm run develop: UNHANDLED REJECTION spawn node ENOENT Error: spawn node ENOENT - child_process:277 Process.ChildProcess._handle.onexit node:inte ...

Using node.js to download files with axios, streaming the content, and then

I am attempting to download a PDF file using axios, and save it on the server side using fs.writeFile. My code is as follows: axios.get('https://xxx/my.pdf', {responseType: 'blob'}).then(response => { fs.writeFile('/temp/my ...

Methods for retrieving a file within a nodejs project from another file

Currently, my project has the following structure and I am facing an issue while trying to access db.js from CategoryController.js. https://i.sstatic.net/8Yhaw.png The code snippet I have used is as follows: var db = require('./../routes/db'); ...

Knowing how Meteor decides to recompute my template helper

Trying to grasp Meteor's reactivity has been quite the journey. The concept of it triggering a page re-render when a reactive data source in a template changes makes sense to me. I've also got a good handle on what qualifies as a reactive source ...

Every individual child component must be assigned a distinct key prop, even if they are pre-defined. - Utilizing REACT

My navigation bar routes are sourced from a JSON file structured like this: { "categorias": [ { "nombre": "Teacher absences", "componentes": [ { "type": "url", ...

Unable to iterate over an array within a single file Vue component

I created a vue.js app utilizing single file components. In the data section, I initialized an empty array like this: data: function () { return { teamKeys: [] } }, Next, I populate this array by pushing values into it within one of my methods: ...

What is the method to activate map dragging in Leaflet only while the spacebar is pressed?

When using Leaflet maps, the default behavior is to drag the view around by only clicking the mouse. However, I am interested in enabling dragging with the mouse only if the spacebar is pressed as well. I would like to reserve mouse dragging without the sp ...

"Encountered a syntax error while attempting to reference an attribute on an empty object

> "[object Number]" === Object.prototype.toString.call(1) // #1 < true > "[object Number]" === {}.toString.call(1) // #2 < true > {}.toString.call(1) === "[object Number]" // #3 < SyntaxError: Unexpected token ...