Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to send arguments to npm test [duplicate]

I have a test script in my package.json that looks like this

"scripts": {
    "test": "mocha --timeout 4000 "
}

I am trying to send additional arguments from the command line(on windows) but it seems not to get them

I tried

npm test --key mykey
npm test --key=mykey
npm run test --key mykey

but none of the above worked. my test scripts need to get this argument. anyone know how it can be done? (putting this argument in the package.json is not an option)

like image 263
Amit Wagner Avatar asked Sep 07 '25 05:09

Amit Wagner


1 Answers

To pass arguments to the script you have to add -- before those arguments, like this:

npm test -- -arg=val
like image 151
Sebastian Kaczmarek Avatar answered Sep 09 '25 00:09

Sebastian Kaczmarek