Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 19:05
    Krinkle labeled #1519
  • 19:05
    Krinkle labeled #1519
  • 19:05
    Krinkle labeled #1519
  • 19:04
    Krinkle commented #1519
  • 14:11
    amk221 commented #1519
  • 13:54
    ro0gr commented #1519
  • 11:21
    amk221 commented #1519
  • 11:21
    amk221 commented #1519
  • 11:21
    amk221 commented #1519
  • 11:21
    amk221 commented #1519
  • 11:20
    amk221 commented #1519
  • 11:20
    amk221 commented #1519
  • 11:18
    amk221 commented #1519
  • 11:18
    amk221 commented #1519
  • 11:12
    amk221 edited #1519
  • 11:11
    amk221 opened #1519
  • Nov 24 23:54
    Krinkle assigned #1518
  • Nov 24 23:54
    Krinkle labeled #1518
  • Nov 24 23:54
    Krinkle labeled #1518
  • Nov 24 23:54
    Krinkle labeled #1518
munrocket
@munrocket
Hi! Anybody knows how QUnit show results in browser? It uses TAP result?
munrocket
@munrocket
I want to use QUnit to show general TAP result, it is posible somehow?
Mark
@MHalter
Hi to all! I try to use qunit 2.9.2 with the Rhino engine. If I set QUnit.config.autorun = false and I call QUnit.start() as last statement then my example tests run. If I set QUnit.config.autorun = true than the will not be executet. I can debug and see that my test will be queued but the test start will not be called. Has someone an idea? my Code:

(function(global) {
    var timer = new java.util.Timer();
    var counter = 1;
    var ids = {};

    global.setTimeout = function(fn, delay) {
        var id = counter;
        counter += 1;
        ids[id] = new JavaAdapter(java.util.TimerTask, { run : fn });
        if (!delay) {delay = 1;}
        timer.schedule(ids[id], delay);
        return id;
    };

        global.clearTimeout = function(id) {
            ids[id].cancel();
            timer.purge();
            delete ids[id];
        };

        global.setInterval = function(fn, delay) {
            var id = counter;
            counter += 1;
            ids[id] = new JavaAdapter(java.util.TimerTask, { run : fn });
            if (!delay) {delay = 1;}
            timer.schedule(ids[id], delay, delay);
            return id;
        };

        global.clearInterval = global.clearTimeout;

        // exports object in case of "isCommonJS"
        global.exports = {};

    })(this);

load("D:/Webstorm-Workspace/Script-Test-Ranch/libs/qunit/qunit-2.9.2.js")

QUnit = exports.QUnit;
QUnit.config.blocking = false;
QUnit.config.autorun = false;
QUnit.config.updateRate = 0;
QUnit.config.showSuccess = true;

QUnit.begin(function( details ) {
    print( "Test amount:", details.totalTests );
});

QUnit.testStart(function( details ) {
    print( "Now running: ", details.module, details.name );
});

QUnit.done(function( details ) {
    print("Total: " + details.total + " Failed: " + details.failed + " Passed: " + details.passed);
});

QUnit.log(function( details ){
    var testResult, runtime;
    if (details.result) {
        testResult = "success";
    } else {
        testResult = "FAILED";
    }
    if (details.runtime !== undefined && details.runtime !== null) {
        runtime = " [" + details.runtime + " ms] ";
    }
    var loc = " " + details.module + ": " + details.name + ": ";
    output = testResult +  runtime + " " + loc + (details.message ? details.message + ", " : "");

    if (details.actual) {
        output += "expected: " + details.expected + ", actual: " + details.actual;
    }
    if (details.source) {
        output += ", " + details.source;
    }

   print(output);
});

QUnit.module( "First Test");

QUnit.test( "ok test", function( assert ) {
    assert.ok( true, "true succeeds" );
    assert.ok( "non-empty", "non-empty string succeeds" );

    assert.ok( false, "false fails" );
    assert.ok( 0, "0 fails" );
    assert.ok( NaN, "NaN fails" );
    assert.ok( "", "empty string fails" );
    assert.ok( null, "null fails" );
    assert.ok( undefined, "undefined fails" );
});

QUnit.module( "Second Test");
QUnit.test( "ok test", function( assert ) {
    assert.ok( true, "true succeeds" );
    assert.ok( "non-empty", "non-empty string succeeds" );

    assert.ok( false, "false fails" );
    assert.ok( 0, "0 fails" );
    assert.ok( NaN, "NaN fails" );
    assert.ok( "", "empty string fails" );
    assert.ok( null, "null fails" );
    assert.ok( undefined, "undefined fails" );
});

QUnit.start();
Christophe CHARLES
@chrc
Hi :)
Without run qunit tests into a directory, do you know if it is possible to have/get a static report/numbers about total tests into the directory?
Like total number of tests show into the top of the web page ".../tests?hidepassed" ?
Thank you
Kevin Partington
@platinumazure
Are you asking how to open a page with QUnit on it and see total tests, but without running any of them?
Yvain Liechti
@ryuran
Hi QUnit users.
I use QUnit in a project to take screenshot using pupeteer then compare it.
But I want run this test on a list of files. So I need to create QUnit test in an forEach loop in some asynchronous tasks.
Each time I try, QUnit return a first global error Error: No tests were run.
What i'm doing wrong ?
Tim Fenney
@timfenney
Hello QUnit!
Looks like the site qunitjs.com is down?
Timo Tijhof
@Krinkle
(The site was back up the day after. It was an upstream issue.)
Timo Tijhof
@Krinkle
@edg2s See platinumazure/eslint-plugin-qunit#86 for some of the ideas for 5.0
Timo Tijhof
@Krinkle
... which, now that I've done my homework as well, I see you already reviewed months ago. Touché
Kevin Partington
@platinumazure
I've got a Gitter channel for eslint-plugin-qunit, if we want to discuss anything further there: https://gitter.im/platinumazure/eslint-plugin-qunit
Timo Tijhof
@Krinkle
@rwjblue I've sent you an invite to be able to triage QUnit issues. I figured that might come in handy since you tend to watch the repository as well. No obligation :)
Kevin Partington
@platinumazure
Hey folks. I'm reviewing platinumazure/eslint-plugin-qunit#94 and I wanted to check: Did QUnit ever support hooks.setup and hooks.teardown, or were those only on module calls with an object argument rather than the callback function?
Timo Tijhof
@Krinkle
platinumazure: Good question! Support for setup/teardown was removed in 2.0 and much of the multi hooks and nesting was built out within 2.x. But... nested hooks itself did land in 1.x and it did live side-by-side with setup/teardown. But... it was added after we started deprecating setup/teardown, and we only supported those as module options.
This snapshot shows setup/teardown coming in from test env, and moduleFns (module hooks object) supporting the newer beforeEach/afterEach methods.
Kevin Partington
@platinumazure
Got it, so hooks.setup() and hooks.teardown() were never valid as far as I can understand. Let me know if I am missing anything. Thanks!
Timo Tijhof
@Krinkle
That's right. They never existed.
Timo Tijhof
@Krinkle
Any Sinon users in the room? I'd like to know your preferred way of integrating with QUnit. See issue qunitjs/qunitjs.com#161 for where I'm collecting ideas for a recommendation to document on the site.
jamesz17
@jamesz17
Hi, I am using qunitjs (version 2.4.1), and I saw a message that "qunitjs" is deprecated and replaced by "qunit". Is "qunit" a drop in replacement for "qunitjs", i.e. no changes needed? We do use qunit for our unit tests.
and in my code I do see references to "qunitjs"
Timo Tijhof
@Krinkle
@jamesz17 That's right. If your JS test suite HTML entry point is loading qunitjs 2.x from node_modules via npm, then you can smoothly update to "qunit" 2.x where the same codebase continued. drop-in replacement :)
the nodejs CLI command is part of the same package before/after the rename and similarly compatible. Only the npm package name was renamed.
jamesz17
@jamesz17
@Krinkle thanks for the quick reply. Do I need to change the references in my code from "qunitjs" to "qunit" if I update to "qunit" 2.x ?
I assume I can directly remove "qunitjs" from npm package.json and add "qunit" 2.x without changing anything else? (there is no breaking changes if I do that)
Timo Tijhof
@Krinkle
@jamesz17 The only change is the package name. Depending on how your tests are run, you may have strings that include the package name. For example, require("qunitjs") would become require("qunit")
If you use git, then git grep qunitjs should find any places that might need an update.
For most projects, no changes are needed. The API is on the QUnit object, which has not changed. and the CLI command is still called qunit, same as before.
jamesz17
@jamesz17
@Krinkle I am not sure what do you mean by "JS test suite HTML entry point is loading qunitjs 2.x from node_modules via npm"? do you mean installing qunitjs via npm?
Timo Tijhof
@Krinkle
@jamesz17 Yes, for example, if you install qunitjs from npm and load it in test/index.html as <script src="node_modules/qunitjs/qunit.js"> then you only need to edit package.json and then update the directory name in that <script> path.
I would recommend giving it a try and see how it goes! For most projects, no other changes are needed :)
jamesz17
@jamesz17
@Krinkle thank you
I am gonna give it a try
: )
Steve McClure
@smcclure15
hi gang - i guess im the new guy. thank you @Krinkle for the invite to this group!
i work on Test Infrastructure at MathWorks and we have oodles of QUnit tests running continuously, so i certainly have a vested interest, but this engagement is fun regardless :-)
and now down to business... do you think we should drop Phantom support with 3.0? there's still some pieces inside the reporter/html.js logic. I came across it because im looking at code coverage with a fine-toothed comb, looking to boost coverage of any low-hanging fruit
Timo Tijhof
@Krinkle
@smcclure15 Hey, welcome!
Good question. I think as a web developer I mostly tend to no longer support PhantomJS. However for QUnit specifically I think there might still be lots of users using PhantomJS without realizing it, e.g. as part of a wrapper that happens to use it internally. But.. I think all of the wrappers and runners I am aware of, have since adopted Headless Firefox, or Headless Chrome, or indirectly via puppeteer.
So.. yeah, I think we can drop it for QUnit 3.0. Would be good to provide a deprecation warning for that before then.
Steve McClure
@smcclure15

that makes sense, thanks.
i started implementing that, then realized that this is probably true of other browsers too. should we have a utility (maybe something near globals.js) to warn about certain deprecated browsers? we have a lot of scaffolding and fallthroughs for the older envs, so we could warn when we know we've had to gracefully degrade/polyfill.

i guess my point is, i assume we'd want to warn for each browser we want to drop in 3.0, but not produce too much noise for warning at every turn. if that outlook is agreeable, i can work on that and propose a PR

Timo Tijhof
@Krinkle
We haven't used warnings in jquery or qunit in the past for general browser support. It's an interesting idea though. I think PhantomJS could use special treatment as its often used without developers thinking about it as a browser. That is, if we were to announce that QUnit requires IE11+, Firefox N+ and drops PhantomJS support, I worry developers might look at their test matrix and shrug, not realizing that while their code doesn't need to work in PhantomJS, that their unit test runner might be be depending on that indirectly. Similar to e.g. if (unlikely) we were to find a bug specific to Puppeteer or something like that.
Timo Tijhof
@Krinkle
fyi, I just re-authenticated Coveralls. It somehow lost the GitHub permission to display source code from the repo, which meant it said "Source Not Available" at https://coveralls.io/builds/34875937/source?filename=src/core.js. This is now fixed.
Steve McClure
@smcclure15

that sounds fair about the browser support - PhantomJS could surprise some folks, and I can issue a warning for that. I'll leave the broader "this browser will be deprecated" can-of-worms alone....

and thanks for touching up the coveralls. I loooooove a green coverage report :-)

Steve McClure
@smcclure15

does anyone have a go-to grunt task to run QUnit node tests?

i've found grunt-qunit-node, grunt-node-qunit (both very old), grunt-contrib-qunit (but that's just for HTML browser tests), and then there's https://github.com/qunitjs/node-qunit, which looks maintained, though still uses some 1.x globals in the readme, and I wasn't sure how easy it was to pull that into Grunt ecosystems...

Timo Tijhof
@Krinkle
@smcclure15 I typically run it outside grunt, by adding && to the test command in package.json. E.g. "test": "grunt && qunit"
Then the user can run the standard npm test idiom and get it the same way as otherwise.
Having said that, we technically have a grunt task for running qunit on node inside our repository: https://github.com/qunitjs/qunit/blob/2.12.0/build/tasks/test-on-node.js - This, however, is not comparable to the QUnit CLI, rather it is comparable to the less common approach of manually running a node script in which you require("qunit") and run that, which is missing a lot of protections and debug utilities. I wouldn't recommend it personally
Steve McClure
@smcclure15
thanks @Krinkle for that context. I ended up simply using js-reporters with TAP output and requiring my test files. very flexible and elegant!
Timo Tijhof
@Krinkle
@smcclure15 awesome. So if I understand correctly - this involves a Node.js script where you require qunit + test suites and attach the TAP reporter. That's good, but I just wanted to double check that you want/need that vs using the CLI. Is this preferred in general or did you run into an issue? If so, I'd love to know what that is (if you can share) as it could help us to improve the CLI (https://qunitjs.com/cli/) . Ideally all you'd need to do is qunit ./test/*.js or simply qunit from the test command.