Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Node.js - npm test silently succeeded without any output?

Node.js - npm test <package> silently succeeded without any output?

Problem

npm test is a cool way to check the package. Output says 'npm is not ok' if package has some issue.

# npm test transkode

While if default test Script passes it doesn't show any output. Can we enable the logs for test?

I did search in node.js google group and found that test output was enabled in older releases. see some discussion.

Also i don't see any option in npm documentation for this NPM Test documentation

What option is required to enable output?

Problem courtesy of: P K

Solution

npm test package will run a package's test script, where the test script is configured in the package.json file. It's up to the package's author to create a test script that will actually output the test's results.

For example, in a sample CoffeeScript package's package.json, I have

"scripts": {
    "test": "cake test"
},

So npm test myPackage will invoke cake test. My Cakefile then has a test task that looks like this:

task 'test', 'test against the specs', ->
    command = extify 'jasmine-node'
    args = ['--coffee', 'spec/']
    jasmine = spawn command, args
    jasmine.stdout.on 'data', (data) -> print data.toString()
    jasmine.stderr.on 'data', (data) -> print data.toString()

Which uses jasmine-node to run the tests. The results of the tests appear in the console.

Solution courtesy of: Eric Bock

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Node.js - npm test silently succeeded without any output?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×