qunitjs/node-qunit

How do I run the api file?

ianaz opened this issue · 9 comments

Sorry for asking but I did not really get it how to let everything run.

I created a runtests.js with

var testrunner = require("qunit");
testrunner.run({
    code: "../User.class.js",
    tests: "test/TestUser.class.js"
}, function(err, report){ console.log(report); });

and the test file is:

test("a basic test example", function (assert) {
    ok(true, "this test is fine");
});

on calling "node runtests.js" i get

Error: ok() assertion outside test context, was at process. (C:\Users\XXXX\Desktop\qunit\node_modules\qunit\lib
at process.EventEmitter.emit (events.js:115:20)
at F.QUnit.assert.ok (C:\Users\XXXX\Desktop\qunit\node_modules\qunit\support\qunit\qunit\qunit.js:414:10)
at process. (C:\Users\XXXX\Desktop\qunit\node_modules\qunit\lib\child.js:17:11)
at process.EventEmitter.emit (events.js:115:20)

Using Windows 7, node v0.8.2

kof commented

Please provide the full code which is needed to reproduce this.

kof commented

Which version of module are you using?

kof commented

I see the issue it is caused by #60

You don't get this correct error message.

Olegs-MacBook-Air:qunit kof $ node runtests

Testing /Users/kof/Downloads/User.class.js ... { first_line: 'Error: Cannot find module '/Users/kof/Downloads/User.class'',
frames:
[ { named_location: 'Function.Module._resolveFilename',
filename: 'module.js',
line: 338,
character: 15,
_filedata: null },
{ named_location: 'Function.Module._load',
filename: 'module.js',
line: 280,
character: 25,
_filedata: null },
{ named_location: 'Module.require',
filename: 'module.js',
line: 362,
character: 17,
_filedata: null },
{ named_location: 'require',
filename: 'module.js',
line: 378,
character: 17,
_filedata: null },
{ named_location: '_require',
filename: '/Users/kof/Downloads/qunit/node_modules/qunit/lib/child.js',
line: 36,
character: 19,
_filedata: null },
{ named_location: 'Object.',
filename: '/Users/kof/Downloads/qunit/node_modules/qunit/lib/child.js',
line: 127,
character: 1,
_filedata: null },
{ named_location: 'Module._compile',
filename: 'module.js',
line: 449,
character: 26,
_filedata: null },
{ named_location: 'Object.Module._extensions..js',
filename: 'module.js',
line: 467,
character: 10,
_filedata: null },
{ named_location: 'Module.load',
filename: 'module.js',
line: 356,
character: 32,
_filedata: null },
{ named_location: 'Function.Module._load',
filename: 'module.js',
line: 312,
character: 12,
_filedata: null } ],
original_error: { [Error: Cannot find module '/Users/kof/Downloads/User.class'] code: 'MODULE_NOT_FOUND' } }

kof commented

Will provide a new version in some minutes.

kof commented

closes #64 correct relative path resolution 5773a1b

kof commented

Now relative pathes are correctly resolved, you can use them relatively to the script which is called from the console.

testrunner.run({
    code: "./User.class.js",
    tests: "./test/TestUser.class.js"
}, function(err, report){ console.log(report); });
kof commented

new version is published (0.5.12)

Awesome, thanks