npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nw-test-runner

v1.4.0

Published

Test runner for node webkit with mocha, chai and Istabul.

Downloads

25

Readme

nw-test-runner

Test runner for node webkit app with mocha and istanbul

Why nw-test-runner?

We were working on a node-webkit app and we couldn't find a good way to write unit tests. Our unit tests initially were written with mocha and separated as client and node side tests. Client side tests were run with mocha-phantomjs and mocha used in node side tests. But, it was not enough. The tests that we wrote, though they passed in their respective environments we cannot be sure that they will pass in node-webkit. Also, node-webkit allowed us to write browser side and node side scripts intertwined, which means we had to mock a lot of things to get the test running. Hence, we decided to run the unit tests in the node-webkit environment. But, there were no good libraries that allowed us to do so. Hence, nw-test-runner was created.

How to use nw-test-runner?

Install to your project folder using npm:

npm install nw-test-runner --save-dev

Create a config file in your project folder from where you are going to run your unit tests. The name of the file should be nwtest.config.js

Here is a sample file:-

{
    "files": [
        "src/app/angular.js",
        "src/app/angular-mocks.js"
    ],
    "src": "src/**/*.js",
    "mock":"tests/**/*mock.js",
    "deps":"tests/**/*deps.js",
    "test":"tests/**/*test.js",
    "output": "test-results",
    "nwpath": "nodewebkit/nw",
    "ext": "spec",
    "covReport": ['cobertura', 'html' ],
    "doNotRunCoverage": true
}

'files' - Files to include in all your tests.These will be loaded before all your test, mock and source files

'src' - The source file pattern to match and load

'mock' - The mock file pattern to match and load

'deps' - The dependencies file pattern to match and load. These are the files that you can specify as dependencies if you decide not to mock

'test*' - The test file pattern to match and load

'output' - The output folder to which all your test results will be published.

'nwpath*' - The path to the nw.exe.

'ext' - The extension you use for your test file name. Could be *.spec.js or *.test.js.

'covReport' - Array of coverage reports you need to be generated

'doNotRunCoverage' - This will check if coverage needs to be run for source files that have no tests

How does it work?

The nw-test-runner goes through your list of test files that you have added. It picks a test file and then tries to find the corresponding src, mock and dependency file by matching the name.

For ex:-

if you test file is named app.test.js, the src file should be named app.js, the dep file should be named app.deps.js and your mock file should be named app.mock.js. Having a corresponding src and mock file is optional.

If you want to include some other source files to support your test, it can be done by adding the following code in your deps file. If you have to repeatedly mock something for your tests, you can create a single file with the mock and include it using deps file.

module.exports = ['/path/to/file1.js', '/path/to/file2.js'];

How to run the tests?

As of now, you have to do

node node_modules/nw-test-runner

or, alternatively you can make this command to be executed for 'npm test' in package.json

In case, you want to run only a perticular test file, you can pass an optional command line argument. The test files that contain the string that you passed in their name only will be run

node node_modules/nw-test-runner app.service.js

Later, a cli tool will be added for running the tests