jdalton / qunit-extras Goto Github PK
View Code? Open in Web Editor NEWExtends QUnit with extra features and CLI support.
License: MIT License
Extends QUnit with extra features and CLI support.
License: MIT License
We used to have a screenshot on README.md, but it appears to have been removed. We should also add details about which environments colors work on.
I've compiled nashorn-1.8.0 but now need to tweak the setTimeout
and setInterval
shims to work with it.
Adding support for coloured terminal output would be great. I can make a PR if you like. This should work in most terminals except Windows Command Prompt.
Since updating to the latest version of QUnit and the qunit-clib submodule for Punycode.js, testing under Narwhal throws errors.
The stack trace refers to this line: https://github.com/jdalton/qunit-clib/blob/4ff13811252dca88835c80e92714178321641631/qunit-clib.js#L117
Full log below.
$ export NARWHAL_OPTIMIZATION=-1; narwhal tests.js
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "parsers" from undefined (/Users/Mathias/Projects/punycode.js/vendor/qunit-clib/qunit-clib.js#117)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3753)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3731)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3759)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3778)
at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3791)
at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1487)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1399)
at script(/Users/Mathias/Projects/punycode.js/vendor/qunit-clib/qunit-clib.js:117)
at script(/Users/Mathias/Projects/punycode.js/vendor/qunit-clib/qunit-clib.js:116)
at script(/Users/Mathias/Projects/punycode.js/vendor/qunit-clib/qunit-clib.js:7)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:845)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2504)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:294)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen._usr_local_Cellar_narwhal_0_3_2_libexec_engines_rhino_bootstrap_js_1._c_anonymous_6(Unknown Source)
at org.mozilla.javascript.gen._usr_local_Cellar_narwhal_0_3_2_libexec_engines_rhino_bootstrap_js_1.call(Unknown Source)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1702)
at script(/usr/local/Cellar/narwhal/0.3.2/libexec/packages/narwhal-lib/lib/narwhal/sandbox.js:118)
at script(/Users/Mathias/Projects/punycode.js/tests/tests.js:4)
at script(/Users/Mathias/Projects/punycode.js/tests/tests.js:1)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:845)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2504)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:294)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen._usr_local_Cellar_narwhal_0_3_2_libexec_engines_rhino_bootstrap_js_1._c_anonymous_6(Unknown Source)
at org.mozilla.javascript.gen._usr_local_Cellar_narwhal_0_3_2_libexec_engines_rhino_bootstrap_js_1.call(Unknown Source)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1702)
at script(/usr/local/Cellar/narwhal/0.3.2/libexec/packages/narwhal-lib/lib/narwhal/sandbox.js:118)
at script(/usr/local/Cellar/narwhal/0.3.2/libexec/packages/narwhal-lib/lib/narwhal/sandbox.js:241)
at script.narwhal(/usr/local/Cellar/narwhal/0.3.2/libexec/narwhal.js:290)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:845)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen._usr_local_Cellar_narwhal_0_3_2_libexec_engines_rhino_bootstrap_js_1._c_anonymous_1(Unknown Source)
at org.mozilla.javascript.gen._usr_local_Cellar_narwhal_0_3_2_libexec_engines_rhino_bootstrap_js_1.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
at org.mozilla.javascript.gen._usr_local_Cellar_narwhal_0_3_2_libexec_engines_rhino_bootstrap_js_1._c_script_0(Unknown Source)
at org.mozilla.javascript.gen._usr_local_Cellar_narwhal_0_3_2_libexec_engines_rhino_bootstrap_js_1.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3157)
at org.mozilla.javascript.gen._usr_local_Cellar_narwhal_0_3_2_libexec_engines_rhino_bootstrap_js_1.call(Unknown Source)
at org.mozilla.javascript.gen._usr_local_Cellar_narwhal_0_3_2_libexec_engines_rhino_bootstrap_js_1.exec(Unknown Source)
at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:563)
at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:485)
at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:451)
at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:443)
at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:196)
at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:117)
at org.mozilla.javascript.Context.call(Context.java:521)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:535)
at org.mozilla.javascript.tools.shell.Main.exec(Main.java:179)
at org.mozilla.javascript.tools.shell.Main.main(Main.java:157)
TypeError: Cannot read property "parsers" from undefined
I’m guessing something changed in QUnit. It sure was working fine before.
The latest QUnit stopped exporting a global when it doesn't think it is in a browser, but if not in node it doesn't export anything.
QUnit 1.9 renamed the function raises
to throws
. raises
still exists, but is deprecated. 'throws'
should therefore be added to this block.
$ npm install qunit-extras
does not install qunitjs
as a dependency unless run with the --dev
flag.
Without qunitjs
installed the tests can't run in node, so qunitjs
should be a normal dependency - not a devDependency.
When running $ npm test
I get: Error: Cannot find module 'qunitjs'
. Can be fixed by running $npm install qunitjs
or adding it as a dependency of my project but it should come bundled.
Instead of detecting whether running on Windows, perhaps a better indicator of ANSI color codes support is the TERM environment variable.
I get the following attempting to run the test suite:
$ npm test
> [email protected] test /home/mjo/src/qunit-extras-1.4.2
> node test/test.js
----------------------------------------
qunit-extras
----------------------------------------
FAIL - Some other test with a title
FAIL | EQ | foo | Expected: 2, Actual: 1
----------------------------------------
PASS: 7 FAIL: 1 TOTAL: 8
Finished in 17 milliseconds.
----------------------------------------
npm ERR! Test failed. See above for more details.
I also have a request that I'd like to tack on =)
In test.js
, you load qunit via a relative path:
load('../node_modules/qunitjs/qunit/qunit.js')
Would it be possible to replace that with a simple require('qunitjs')
? The user may have qunit installed in his home directory or globally or somewhere else. Thank you!
If using the new qunit-2.x APIs (already included with qunit-1.16 release) to define async tests, failed tests are not retried.
QUnit.config.asyncRetries = 5;
// Will be retried
asyncTest("old style async", function( assert ) {
setTimeout(function() {
ok(false);
start();
}, 1000);
});
// Will not retry
QUnit.test("new style async", function( assert ) {
var done = assert.async();
setTimeout(function() {
assert.ok(false);
done();
}, 1000);
});
Reference:
http://qunitjs.com/upgrade-guide-2.x/
When a comparison between arrays containing Symbols fails, rather than printing an error message the assert.deepEqual
function throws a type error.
Failing code is:
QUnit.test('array of symbol comparision', assert => {
assert.deepEqual([Symbol('aSymbol')], [5]);
});
For a demo demonstrating the error please see: https://runkit.com/harrysarson/qunit-extras-symbols-bug.
I believe that somewhere [Symbol('mySymbol')].toString()
is called which throws the error.
Interestingly the code fails in node v6.6 and v5.12 but not node v4.5.
I’m not sure if this fits into qunit-extras’s scope, but it would be great if you could do stuff like enable/disable hidepassed and other QUnit settings.
Add a few example tests for easy viewing the outputs of qunit-extras, eg test-passing.js, test-failing.js, run-tests.sh and index.html.
When a test fails, all other tests in that block get their result displayed as well. That’s fine, but it would be nice if we could get rid of the trailing |
for passing tests in that case.
FAIL - basic
PASS | OK | object returned |
FAIL | EQ | values | Expected: a,b,c, Actual: a,x,c
PASS | EQ | passed arguments to callback |
FAIL | EQ | exit early | Expected: a,b, Actual: a,x
It would be useful to have qunit-clib
on npm so we don’t have to bother with Git submodules anymore.
Would you mind adding a package.json
file and publishing qunit-clib
to npm? Thanks!
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.