by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 27 20:59
    rwjblue commented #1483
  • Sep 27 20:57
    Krinkle labeled #1483
  • Sep 27 20:57
    Krinkle milestoned #1483
  • Sep 27 20:57
    Krinkle opened #1483
  • Sep 24 01:53
    rwjblue commented #165
  • Sep 23 23:14
    trentmwillis opened #165
  • Sep 23 22:36
    trentmwillis commented #163
  • Sep 23 22:35
    trentmwillis commented #161
  • Sep 22 19:58
    gabrielcsapo commented #1476
  • Sep 20 03:19

    Krinkle on docs-contributing

    Docs: Update outdated CONTRIBUT… (compare)

  • Sep 20 03:12

    Krinkle on master

    (compare)

  • Sep 20 03:11

    Krinkle on main

    (compare)

  • Sep 15 17:27
    Krinkle commented #947
  • Sep 15 16:35
    Krinkle milestoned #1084
  • Sep 15 01:35
    Krinkle commented #163
  • Sep 15 01:35
    Krinkle commented #163
  • Sep 15 01:32
    Krinkle commented #163
  • Sep 15 01:14
    Krinkle closed #1183
  • Sep 15 01:14
    Krinkle commented #1183
  • Sep 15 01:12
    Krinkle closed #1414
feloniuosgru
@feloniuosgru
Hi all, can anyone suggest which javascript framework would be good to work with for unit testing?
We have .Net application which use javascript and need some insight on which framework would fit in well. I have explored Jest, Mocha, Jasmine, Chai and really confused.
Shlomi Fish
@shlomif
Hi all! How do I prepare an AMD browser module out of qunit git master? I tried npm install git+https://git@github.com/qunitjs/qunit.git \
followed by base="qunit" ; browserify -s "$base" -r "qunit" -o lib/out-babel/js/qunit.js
and it didn't work
Shlomi Fish
@shlomif
ok, i ended up using "yarn build" and copying dist/qunit.js
thanks
Shlomi Fish
@shlomif
Hi all!
David Gomez
@nan140114
@okainov OH mannnn i love you, this saved my life !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Saravanan
@d-saravanan
Hi, When i run the qunit from the console i get the error as $ is undefined
I created the tests.js file and then using require to add the reference to the library file to test. Any pointers to resolve this issue
Kevin Partington
@platinumazure
@d-saravanan Could you please show your test file?
Saravanan
@d-saravanan

Below given is the QUnit test
QUnit.test("basic test of the showNotification method ", (at) => {
Notifier.debugMode = true;
Notifier.error({
meta: {
"cause": null,
"name": "AppHttpError",
"type": "UNKNOWN_ERROR",
"code": "020",
"message": "Error deleting account phone: getting Phone with query: {\"_id\":\"5c6a9240615cb89008153ba3\"}",
"category": "general",
"status_code": 404,
"statusCode": 500
},
text: "We're not sure what happened?"
});
at.equal($("#notifier").length, 1);
at.equal(0,0);
})

We are invoking the error method which internally uses the jQuery selector to perform DOM manipulation

Saravanan
@d-saravanan
@platinumazure : As I am from India, I could not reply back on time
Kevin Partington
@platinumazure
No problem @d-saravanan, thank you for replying (and sorry for the delay)
@d-saravanan Are you doing something like const $ = require("jquery");
@trentmwillis @Krinkle Does the CLI --require populate the global namespace?
Saravanan
@d-saravanan

@platinumazure :
I do have this line in the test file.
if (typeof(require) !== 'undefined') {
// It's important to define it with the very same name in order to have both browser and CLI runs working with the same test code
showNotification = require('../app.js').showNotification;
$ = require('jquery');
}

var $ = require('jquery');

QUnit.module("testing the html changes for XSS (CWE ID: 80)");

QUnit.test("test one", (assert) => {
assert.equal(1,1);
});

QUnit.test("basic test of the showNotification method ", (at) => {
Notifier.debugMode = true;
Notifier.error({
meta: {
"cause": null,
"name": "HttpError",
"type": "UNKNOWN_ERROR",
"code": "020",
"message": "Error deleting account phone: getting Phone with query: {\"_id\":\"5c6a9240615cb89008153ba3\"}",
"category": "general",
"status_code": 404,
"statusCode": 500
},
text: "We're not sure what happened?"
});
at.equal($("#notifier").length, 1);
at.equal(0,0);
})

I have provided the full file for your reference
Kevin Partington
@platinumazure
@d-saravanan Thanks for the file. Could you please show me how you're running QUnit?
Jack Guo
@ashjackguo
I have a question: In my test.js I have tests written for DOM manipulation and when I run it using qunit cli, all tests failed because document is not defined. When running using qunit cli is it only used for running pure js unit test and not DOM manuplation?
Kevin Partington
@platinumazure
@ashjackguo Not sure but I lean towards yes. You might be able to run in the CLI if you can use a polyfill that will export a DOM-like object into global.document. Hopefully a team member will correct me if I'm wrong
Jack Guo
@ashjackguo
@platinumazure I see, I'll do some research on how to use a polyfill to export a DOM-like object. The reason that I'm asking is that I want to run the test in our build process.
Kevin Partington
@platinumazure
@ashjackguo I think for that sort of thing, people usually use karma or similar
Jack Guo
@ashjackguo
@platinumazure Got it! Thanks for you fast responsive! Much appreciated!!
Timo Tijhof
@Krinkle
Yep, @d-saravanan @platinumazure, using --require will use the same JS global scope as the tests. It's like an implied require() call before the tests files are loaded. Using global-assignments you can use it to shim a browser environment
Saravanan
@d-saravanan
@platinumazure I am using the terminal window and using QUnit tests.js
Saravanan
@d-saravanan
@platinumazure I tried to use the following commands but still in vain
QUnit xss-tests-0.js --require jquery-3.3.1.slim
QUnit xss-tests-0.js --require jquery
I have posted my sample application in the GitHub repo for your reference
https://github.com/d-saravanan/qUnit
Justin Meyer
@justinbmeyer
I've been working on a module that can compare the current rendered styles to a saved image and show a diff if someone breaks the styles. I'd really like to embed this diff in the QUnit output. Does anyone have an idea on how to make this work?
To give you an idea:
const  styleGuide = await getCanvasForUrl("../style/guide.html");
const image = await getCanvasForImage("./style-guide.png");
QUnit.equalImage(  styleGuide, image )
ideally, I'd like to make some equalImage that can diff two canvas elements and present the diff to the user if they are different
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.