How-to-npm test.js


#1

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.


#2

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.


#3

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


#4

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.


#5

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


#6

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


#7

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


#8

#9

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


#10

Did you save your package.json file?


#11

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”.