gruntjs / grunt-contrib-nodeunit Goto Github PK
View Code? Open in Web Editor NEWRun Nodeunit unit tests.
Home Page: http://gruntjs.com/
License: MIT License
Run Nodeunit unit tests.
Home Page: http://gruntjs.com/
License: MIT License
Hello together,
my project has both grunt-contrib-nodeunit & nodeunit as direct dev-dependencies:
...
"dev-dependencies": {
"grunt-contrib-nodeunit": "~0.3.2",
"nodeunit": "~0.8.2 ",
...
},
...
So npm installs them like this:
node_modules
│
├── grunt-contrib-nodeunit
│ └── tasks
│
└── nodeunit
├── bin
├── deps
├── doc
├── examples
├── img
├── lib
├── man1
├── node_modules
├── share
└── test
Note that, grunt-contrib-nodeunit has no sub-directory node_modules (and therefore no sub-sub- directory nodeunit).
But in #23 the file nodeunit.json is explicitly searched under grunt-contrib-nodeunit/node_modules/nodeunit/bin/.
See: commit 552f171
file: tasks/nodeunit.js
line: 232
var nodeUnitDefaultsFile = path.join(__dirname, '..', 'node_modules', 'nodeunit', 'bin', 'nodeunit.json');
In these circumstances, the file is not found and the escape-characters for the colored output are not set.
I would like to fix this, but I don't know a elegant/simple/robust way to handle the variable location of nodeunit (possibily further up the tree).
Any ideas?
Before:
Running "test:foreach" (test) task
Testing foreach_test.jsFFF
>> forEach - no context
>> Error Expected 4 assertions, 0 ran
>> at Object.exports.test.test.done (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/types.js:121:25)
>> at Object.exports.runTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:72:14)
>> at exports.runSuite (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:117:25)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:118:13)
>> at async.forEachSeries (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:134:9)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:507:9)
>> at Object.doSeries [as concatSeries] (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:147:23)
>> at Object.exports.runSuite (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:95:11)
>> at exports.runSuite (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:124:21)
>> forEach - no context
>> TypeError object is not a function
>> at Object.exports.forEach.no context (/Users/cowboy/Desktop/Work/js_best_practices_2012_10/test/foreach_test.js:34:5)
>> at Object.wrapTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16)
>> at Object.wrapTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16)
>> at wrapTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16)
>> at Object.exports.runTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:69:9)
>> at exports.runSuite (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:117:25)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:118:13)
>> at async.forEachSeries (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:134:9)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:507:9)
>> forEach - context
>> Error Expected 4 assertions, 0 ran
>> at Object.exports.test.test.done (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/types.js:121:25)
>> at Object.exports.runTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:72:14)
>> at exports.runSuite (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:117:25)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:118:13)
>> at async.forEachSeries.iterate (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:129:25)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:510:17)
>> at exports.test.test.done (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/types.js:146:17)
>> at process.startup.processNextTick.process._tickCallback (node.js:244:9)
>> forEach - context
>> TypeError object is not a function
>> at Object.exports.forEach.context (/Users/cowboy/Desktop/Work/js_best_practices_2012_10/test/foreach_test.js:54:5)
>> at Object.wrapTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16)
>> at Object.wrapTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16)
>> at wrapTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16)
>> at Object.exports.runTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:69:9)
>> at exports.runSuite (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:117:25)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:118:13)
>> at async.forEachSeries.iterate (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:129:25)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:510:17)
>> forEach - sparse arrays
>> Error Expected 4 assertions, 0 ran
>> at Object.exports.test.test.done (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/types.js:121:25)
>> at Object.exports.runTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:72:14)
>> at exports.runSuite (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:117:25)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:118:13)
>> at async.forEachSeries.iterate (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:129:25)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:510:17)
>> at exports.test.test.done (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/types.js:146:17)
>> at process.startup.processNextTick.process._tickCallback (node.js:244:9)
>> forEach - sparse arrays
>> TypeError object is not a function
>> at Object.exports.forEach.sparse arrays (/Users/cowboy/Desktop/Work/js_best_practices_2012_10/test/foreach_test.js:79:5)
>> at Object.wrapTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16)
>> at Object.wrapTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16)
>> at wrapTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:235:16)
>> at Object.exports.runTest (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:69:9)
>> at exports.runSuite (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/lib/core.js:117:25)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:118:13)
>> at async.forEachSeries.iterate (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:129:25)
>> at _concat (/Users/cowboy/.nave/installed/0.8.11/lib/node_modules/grunt/node_modules/nodeunit/deps/async.js:510:17)
<WARN> 6/6 assertions failed (8ms) Use --force to continue. </WARN>
After:
Running "test:foreach" (test) task
Testing foreach_test.jsFFF
>> forEach - no context
>> Error Expected 4 assertions, 0 ran
>> at Object.exports.test.test.done (nodeunit/lib/types.js:121:25)
>> at Object.exports.runTest (nodeunit/lib/core.js:72:14)
>> at exports.runSuite (nodeunit/lib/core.js:117:25)
>> at _concat (nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (nodeunit/deps/async.js:118:13)
>> at async.forEachSeries (nodeunit/deps/async.js:134:9)
>> at _concat (nodeunit/deps/async.js:507:9)
>> at Object.doSeries [as concatSeries] (nodeunit/deps/async.js:147:23)
>> at Object.exports.runSuite (nodeunit/lib/core.js:95:11)
>> at exports.runSuite (nodeunit/lib/core.js:124:21)
>> forEach - no context
>> TypeError object is not a function
>> at Object.exports.forEach.no context (test/foreach_test.js:34:5)
>> at Object.wrapTest (nodeunit/lib/core.js:235:16)
>> at Object.wrapTest (nodeunit/lib/core.js:235:16)
>> at wrapTest (nodeunit/lib/core.js:235:16)
>> at Object.exports.runTest (nodeunit/lib/core.js:69:9)
>> at exports.runSuite (nodeunit/lib/core.js:117:25)
>> at _concat (nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (nodeunit/deps/async.js:118:13)
>> at async.forEachSeries (nodeunit/deps/async.js:134:9)
>> at _concat (nodeunit/deps/async.js:507:9)
>> forEach - context
>> Error Expected 4 assertions, 0 ran
>> at Object.exports.test.test.done (nodeunit/lib/types.js:121:25)
>> at Object.exports.runTest (nodeunit/lib/core.js:72:14)
>> at exports.runSuite (nodeunit/lib/core.js:117:25)
>> at _concat (nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (nodeunit/deps/async.js:118:13)
>> at async.forEachSeries.iterate (nodeunit/deps/async.js:129:25)
>> at _concat (nodeunit/deps/async.js:510:17)
>> at exports.test.test.done (nodeunit/lib/types.js:146:17)
>> at process.startup.processNextTick.process._tickCallback (node.js:244:9)
>> forEach - context
>> TypeError object is not a function
>> at Object.exports.forEach.context (test/foreach_test.js:54:5)
>> at Object.wrapTest (nodeunit/lib/core.js:235:16)
>> at Object.wrapTest (nodeunit/lib/core.js:235:16)
>> at wrapTest (nodeunit/lib/core.js:235:16)
>> at Object.exports.runTest (nodeunit/lib/core.js:69:9)
>> at exports.runSuite (nodeunit/lib/core.js:117:25)
>> at _concat (nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (nodeunit/deps/async.js:118:13)
>> at async.forEachSeries.iterate (nodeunit/deps/async.js:129:25)
>> at _concat (nodeunit/deps/async.js:510:17)
>> forEach - sparse arrays
>> Error Expected 4 assertions, 0 ran
>> at Object.exports.test.test.done (nodeunit/lib/types.js:121:25)
>> at Object.exports.runTest (nodeunit/lib/core.js:72:14)
>> at exports.runSuite (nodeunit/lib/core.js:117:25)
>> at _concat (nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (nodeunit/deps/async.js:118:13)
>> at async.forEachSeries.iterate (nodeunit/deps/async.js:129:25)
>> at _concat (nodeunit/deps/async.js:510:17)
>> at exports.test.test.done (nodeunit/lib/types.js:146:17)
>> at process.startup.processNextTick.process._tickCallback (node.js:244:9)
>> forEach - sparse arrays
>> TypeError object is not a function
>> at Object.exports.forEach.sparse arrays (test/foreach_test.js:79:5)
>> at Object.wrapTest (nodeunit/lib/core.js:235:16)
>> at Object.wrapTest (nodeunit/lib/core.js:235:16)
>> at wrapTest (nodeunit/lib/core.js:235:16)
>> at Object.exports.runTest (nodeunit/lib/core.js:69:9)
>> at exports.runSuite (nodeunit/lib/core.js:117:25)
>> at _concat (nodeunit/deps/async.js:508:13)
>> at async.forEachSeries.iterate (nodeunit/deps/async.js:118:13)
>> at async.forEachSeries.iterate (nodeunit/deps/async.js:129:25)
>> at _concat (nodeunit/deps/async.js:510:17)
<WARN> 6/6 assertions failed (8ms) Use --force to continue. </WARN>
Running "test:foreach" (test) task
Testing foreach_test.jsFFF
>> forEach - no context
>> Error Expected 4 assertions, 0 ran
>> forEach - no context
>> TypeError object is not a function
>> at Object.exports.forEach.no context (test/foreach_test.js:34:5)
>> forEach - context
>> Error Expected 4 assertions, 0 ran
>> forEach - context
>> TypeError object is not a function
>> at Object.exports.forEach.context (test/foreach_test.js:54:5)
>> forEach - sparse arrays
>> Error Expected 4 assertions, 0 ran
>> forEach - sparse arrays
>> TypeError object is not a function
>> at Object.exports.forEach.sparse arrays (test/foreach_test.js:79:5)
<WARN> 6/6 assertions failed (8ms) Use --force to continue. </WARN>
Maybe --verbose
will show everything, otherwise it'll be way, way less output.
If watch
always runs tasks in a sub-process, the require cache should no longer need to be cleared. Right?
The current implementation requires the reporter be referenced by name, which assumes the reporter is registered with the nodeunit that this module requires. Instead, if the reporter is unknown, assume it is a file path and require() it. This would make customizing reporters easier for use in CI processes. This seems to be a stanard approach, with examples below. Alternately, is there another preferred approach for registering a custom nodeunit reporter?
nodeunit CLI: https://github.com/caolan/nodeunit/blob/master/bin/nodeunit#L121-L126
grunt-jscs, uses config: https://github.com/jscs-dev/node-jscs/blob/master/lib/cli-config.js#L145-L161
grunt-contrib-jshint: https://github.com/gruntjs/grunt-contrib-jshint/blob/master/tasks/lib/jshint.js#L49-L60
Several projects are getting Dependabot alerts about known security vulnerabilities that are raised by dependencies on grunt-contrib-nodeunit and its dependencies.
Please consider applying the PRs that address these issues and pass the project's test.
I'm getting materially different outputs when I use this grunt-contrib-nodeunit when compared to running nodeunit directly. Here's the code:
test.js
exports.testSomethingElse = function(test){
test.expect(1);
setTimeout(function(){
setTimeout(function(){
var t;
t();
}, 10);
test.ok(true);
//test.done();
},100);
};
Gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
nodeunit: {
all: ['test.js'],
options: {
reporter: 'default'
}
}
});
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.registerTask('default',['nodeunit']);
};
package.json
{
"name": "test",
"version": "0.0.1",
"private": true,
"dependencies": {
"grunt": "latest",
"nodeunit": "latest",
"grunt-contrib-nodeunit": "latest"
}
}
Here's the output:
user@desktop:~/bug_test$ nodeunit test.js
test.js
FAILURES: Undone tests (or their setups/teardowns):
- testSomethingElse
To fix this, make sure all tests call test.done()
user@desktop:~/bug_test$ grunt
Running "nodeunit:all" (nodeunit) task
test.js
Fatal error: undefined is not a function
Notice how when I run it in nodeunit it gives the error message of "Undone tests", while if I run it in grunt it catches the "undefined is not a function" error.
If we comment out the test.done()
line then we get the following output:
user@desktop:~/bug_test$ nodeunit test.js
test.js
✔ testSomethingElse
OK: 1 assertions (104ms)
/home/user/bug_test/test.js:6
t();
^
TypeError: undefined is not a function
at null._onTimeout (/home/user/bug_test/test.js:6:13)
at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
user@desktop:~/bug_test$ grunt
Running "nodeunit:all" (nodeunit) task
test.js
✔ testSomethingElse
OK: 1 assertions (105ms)
Done, without errors.
Again, notice how nodeunit prints out a stacktrace even though the tests passed, while grunt-contrib-nodeunit hides that.
Is there a solution to this problem?
undefined
appears in the output when running nodeunit with the minimal reporter. The config I have set up is:
grunt.loadNpmTasks("grunt-contrib-nodeunit");
grunt.config("nodeunit", {
all: ["tests/*.js"],
options: { reporter: "minimal" }
});
And the output it gives:
Running "test" task
undefinedrouter.jsundefined: .
undefinedserver.jsundefined: ....
undefinedundefinedOK: undefinedundefined5 assertions (25ms)
Done, without errors.
But when I run node
directly and import nodeunit, I can run nodeunit.reporters.minimal.run("server.js")
to generate the expected output:
server.js: ....
OK: 4 assertions (23ms)
Aside: I get the feeling that this is an issue with Grunt more so than this particular task, but is does seem to be specific to nodeunit+Grunt. Let me know if there's a better place for this issue.
There is a particular file which is too deeply nested in NodeUnit for Windows to handle when doing a git add
. The offending file is
node_modules/grunt-contrib-nodeunit/node_modules/nodeunit/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array1.js
The potentially could be others but it causes a fatal error when running git add -A :/
The limit is 260 characters and is documented here
The error raised is the one discussed in this Stackoverflow question
I want to run same nodeunit test twice but it gives me error "Fatal error: test after end() was called"
For example:
Setup
nodeunit:{
src: ['test.js'],
options: {
reporter: 'tap'
}
}
grunt.registerTask('test', 'Run unit test', function (context) {
process.env.TEST = "TEST1";
grunt.task.run('nodeunit');
// change the environment variable
process.env.TEST = "TEST2";
grunt.task.run("nodeunit");
});
test.js
exports.test = {
setUp: function (callback) {
callback();
},
tearDown: function (callback) {
callback();
},
"test 1": function (test) {
test.equal(doSomething(process.env.TEST), true, "should pass with env var:" + process.env.TEST);
test.done();
}
};
Error while running second grunt.task.run
Fatal error: test after end() was called
Is it possible? It would be really handy when testing grunt tasks.
My options look like this:
options: {
reporter: 'junit',
reporterOutput: 'reports'
},
And i am getting this error message:
Error: No output directory defined.
Either add an "output" property to your nodeunit.json config file,
or use the --output command line option.
Just because no assertions failed doesn't mean that 0/0 passing was a good thing.
When no test files are found in the given src, the assertion is run and, a warning is thrown and grunt exits.
When no test files are found in the given src, assertions attemps to run, a log line states that no test files were found and grunt does not exit.
The following code test/importjs_test.js
runs well, passing 1 Assertion when using nodeunit
via the command line:
'use strict';
var grunt;
grunt = require('grunt');
exports.importjs = {
all: function(test) {
var actual, expected;
test.expect(1);
actual = grunt.file.read('tmp/output.js');
expected = 'requirejs(["core/core"].concat(["test/dir/module2", "test/dir/subfolder/module1", ]), function() {})';
test.equal(actual, expected, 'generated file correctly');
return test.done();
}
};
nodeunit test/importjs_test.js
importjs_test.js
✔ importjs - all
OK: 1 assertions (367ms)
Unfortunately, running grunt nodeunit
gives me:
Running "nodeunit:all" (nodeunit) task
>> 0 assertions passed (0ms)
Gruntfile configuration is:
nodeunit:
all: ['test/*_test.js']
grunt version is 0.4.0a
EDIT: I took a closer look using node inspector and noticed that this.files
is undefined and this.file.src
is undefined on line 157 in tasks/nodeunit.js
although there exists a file test/importjs_test.js
. Can't figure out why it can't find this file.
I'm testing with grunt v 0.4.0rc4 and grunt-contrib-nodeunit v 0.1.1
On this line in tasks/nodeunit.js
, this.filesSrc
is not defined:
nodeunit.reporters.grunt.run(this.filesSrc, {}, this.async());
But if I do this it works:
nodeunit.reporters.grunt.run(this.file.src, {}, this.async());
Right now when an assertion like this fails:
test.ok(undefined, 'this value should be truthy');
We see this:
>> my test
>> Message: this value should be truthy
>> Error: this value should be truthy
But we should really see this:
>> my test
>> Message: this value should be truthy
>> Error: undefined == true
I think the fix is to change this line inside betterErrors
:
if (!e || !e.actual || !e.expected) { return assertion; }
To this:
if (!e || !('actual' in e) || !('expected' in e)) { return assertion; }
Hi please fix the errors caught by travis ci.
148Running "nodeunit:tests" (nodeunit) task
149Testing nodeunit_test.js.F....
150>> nodeunit - fail
151>> Message: Operator should display for multiline.
152>> Error: false == true
153>> at /home/travis/build/gruntjs/grunt-contrib-nodeunit/test/nodeunit_test.js:18:12
154>> at callDone (node_modules/grunt/node_modules/grunt-legacy-util/index.js:159:5)
155>> at ChildProcess. (node_modules/grunt/node_modules/grunt-legacy-util/index.js:198:5)
156>> at ChildProcess.emit (events.js:110:17)
157>> at maybeClose (child_process.js:1015:16)
158>> at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
159
160Warning: 1/24 assertions failed (5848ms)� Use --force to continue.
161
162Aborted due to warnings.
163npm ERR! Test failed. See above for more details.
164
165The command "npm test" exited with 1.
Since this repo may be causing other repos to fail.
The 0.10 test is the only one that passes but 0.12 and 4 have been failing.
Hi,
tag 2.1.0 is missing, this causes problems for packagers.
Cheers,
Xavier
Just tried to install 0.3.0 and NPM yelled at me.
npm http 304 https://registry.npmjs.org/grunt-contrib-nodeunit
npm ERR! notarget No compatible version found: grunt-contrib-nodeunit@'>=0.3.0-0 <0.4.0-0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.1.0","0.1.1","0.1.2","0.2.0","0.2.1","0.2.2","0.1.2-rc5","0.1.2-rc6"]
Undone tests cause the task to die without output. In this particular case, not calling callback
in a setUp
function produces no output when run via Grunt, but running the same test via nodeunit itself will produce output.
"use strict";
exports.okay = function (test) {
test.equal(1, 1);
test.done();
};
exports.nope = {
setUp: function (callback) {
// callback();
},
something: function (test) {
test.equal(1, 1);
test.done();
}
};
gist: https://gist.github.com/anonymous/a4603678e29bf9250bbb.
Running grunt nodeunit
gives the following output:
Running "nodeunit:all" (nodeunit) task�
example.js�: .
And it dies without showing the second test.
With the same setup, running nodeunit directly via nodeunit tests/*.js
gives the following output:
example.js�
✔ okay
FAILURES: Undone tests (or their setups/teardowns): �
- nope - something
To fix this, make sure all tests call test.done()
The same is possible by running:
./node_modules/grunt-contrib-nodeunit/node_modules/nodeunit/bin/nodeunit tests/*.js
When including the grunt-contrib-nodeunit devDependency on my project package.json file, when doing npm install I expected to find on node_modules/.bin a symbolic link to the nodeunit executable since it's a dependency of grunt-contrib-nodeunit, but instead I found that this symbolic link is put on node_modules/grunt-contrib-nodeunit/node_modules/.bin instead. I don't think it's a bad idea that path, but I believe it should be added a symbolic link directly on node_modules/.bin so it will be easier to execute without needing to set nodeunit as a direct dependency of my project nor installing them globally.
As proposed on https://github.com/isaacs/npm/issues/4165#issuecomment-28897851, it would be easy to achieve setting on grunt-contrib-nodeunit package.json file the next entry:
bin: { nodeunit: "node_modules/.bin/nodeunit" }
The betterErrors function assumes that the 'stack' property will always exist on line 58, which isn't the case. When it doesn't, the function throws its own error (Fatal error: Cannot call method 'split' of undefined
), hiding the original test failure and immediately failing the task.
Technically, the 'stack' property is still a vendor extension, though both Gecko and V8 implement it. But even in those environments you can throw an error that doesn't have Error as a prototype.
// Merge task-specific and/or target-specific options with these defaults.
@@ -282,6 +283,10 @@ module.exports = function(grunt) {
grunt.file.mkdir(path.normalize(options.reporterOptions.output));
}
if (testName){
options.reporterOptions['testspec']= testName;
}
k-maru/grunt-typescript@04eb345
ここのコミットでtypescript.jsのfindFileをコメントアウトしていますが、これで困るパターンがありました…。
何か意図があるのかもしれませんが、よくわからないのでとりあえず報告だけ…。
再現手順は以下の通り。cloneした後 npm install && grunt test で再現できるはずです。
https://gist.github.com/vvakame/5019579
When grunt-contrib-nodeunit crashes, which is does often without any error message, the exit value is still 0.
The exit value for any failure should be > 0.
By crash I simply mean a fault in the code which nodeunit/grunt was somehow unable to handle. For example, not calling done()
on a setup or tearDown method.
Hi.
I recently inherited ownership of https://github.com/rquadling/grunt-html2js (the company I work for use it and it was no longer being maintained).
I'm not a JS expert, but I'm learning what I need.
I'm stuck trying to track/catch exceptions / grunt.log.warn / grunt.log.error that the main code can generate in the unit tests such that I can see that the code and tests are working correctly.
Currently, an exception thrown in the code just aborts the whole test run.
If anyone has the time to pop over to the repo and take a look at the test setup and give me any pointers (and raise issues over there), then I'd be happy to learn from this.
Specifically, how to fix rquadling/grunt-html2js#76
I've created a branch with tests, but they are empty at the moment.
https://github.com/rquadling/grunt-html2js/blob/issue_76/test/html2js_test.js#L358
Thanks.
Richard.
I've installed the grunt-contrib-nodeunit
task but getting the following issue when trying to run it using node 0.12.2
:
Loading "nodeunit.js" tasks...ERROR
>> Error: No such module: evals
Warning: Task "nodeunit" not found. Use --force to continue.
Aborted due to warnings.
Upgrading the nodeunit
installed by the grunt-contrib-nodeunit
task to 0.9.1 fixes the issue above.
More info in the following nodeunit issue
TAP output redirection doesn't currently work with "reporterOutput".
Blocked by caolan/nodeunit#230
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.