How-to-npm test.js

On the how-to-npm module, on the testing section, it tells how to set up the package.json file to have “test”: “node test.js” and how to make the test.js file, but doesn’t say what is supposed to go in the test.js file, only that it “has to exit
without throwing an error, or else the test fails”. What am I supposed to put in the test.js file to make this work? I’ve tried process.exit() but the tests fail.

I think you can just leave the file blank. Save it to the directory you’re in, update with the “test”: “node test.js”, and then make sure you save all changes in the text editor. Then run the how-to-npm verify check in the command line.

1 Like

I am having this problem, too. Leaving blank does not fix it.

If you are on windows, make sure the file is indeed test.js, not test.js.txt .
All I put in my file was a comment
// Created per how-to-npm
It passed.

Facing same issue. Responses above doesn’t resolve the issue.

adding a comment and saving all with (Cmd + S) made it pass

Make sure you’re updating the right package.json file and place the test.js in the same directory

Which application are you using for your text file? Am struggling here I cant move from NPM TEST

Did you save your package.json file?

Ok, I think I’ve identified the issue. The instructions say to name the new test file “node test.js”, and then insert “node test.js” as the script within the package.json file. That’s wrong. You need to name your test file “test.js”, and then set the package.json script to “node test.js”.