matt
matt

Reputation: 377

How do you define npm test to run cucumber cross platform?

When I was trying out Jasmine, I could simply add the following to my package.json file:

"scripts": {
    "test": "jasmine"
},

Then when I ran npm test from a Windows command prompt, npm would run my Jasmine tests.

However, with Cucumber-JS, I tried "test": "cucumber" but that simply opened node_modules\.bin\cucumber.js in my editor. I seem to have to use the following to actually run the tests:

"scripts": {
    "test": "cucumber.js.cmd"
},

That seems very platform-specific, and I'd rather not make this difficult for co-developers using Mac or Linux.

Is there a value I can use for the "test" command that would work on multiple operating systems?

EDIT:
Note that my question is similar to this one about mocha, but not quite the same, since the answer in that question (using the name of the package, mocha), solved the problem, whereas in this case using the name of the package (cucumber) did not work.

Upvotes: 1

Views: 2450

Answers (1)

matt
matt

Reputation: 377

After reading a very similar StackO question/answer and looking more closely at the contents of the node_modules\.bin folder, I discovered that using the following seems to do exactly what I wanted:

"scripts": {
    "test": "cucumberjs"
},

Apparently I should have been using cucumberjs instead of just cucumber.

Upvotes: 1

Related Questions