How do use node-qunit?
Asked Answered
W

1

9

The info on this page seems less-than-forth-coming -- https://github.com/kof/node-qunit. I've got a setup where I installed nodejs and installed the node-quit module. I have test runner and executed the command node /path/to/runner.js. Below is an example of my setup. Any ideas or examples on how to do this or maybe I'm using it wrong. I previous ran qunit tests using Rhino and EnvJs without any issues but I figured I try nodejs since I using it for other things and the packaging system can be scripted in my build. Maybe I missing an option to node to include Qunit or some environment variable not set -- that would make sense.

File Structure

node/
public/
  js/
    main.js
tests/
  js/
    testrunner.js
    tests.js

Installation

cd node
npm install qunit

This will now update the file structure.

node/
  node_modules/
    qunit/

tests/js/testrunner.js

var runner = require("../../node/node_modules/qunit");
runner.run({
    code : "/full/path/to/public/js/main.js",
    tests : "/full/path/to/tests/js/tests.js"
});

tests/js/tests.js

test("Hello World", function() {
    ok(true);
});

Command

node tests/js/testrunner.js
Winnipegosis answered 28/6, 2012 at 0:24 Comment(0)
W
6

It appears that you need to use full paths to the main.js and tests.js files and also include a relative path to the qunit module. I updated the code above as an example for others.

Winnipegosis answered 28/6, 2012 at 12:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.