Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 13 20:09
    platinumazure commented #1401
  • Sep 13 20:09
    platinumazure review_requested #1401
  • Sep 13 20:09
    platinumazure review_requested #1401
  • Sep 11 21:12
    patocallaghan commented #1401
  • Sep 04 13:27
    jessica-jordan edited #1405
  • Sep 04 13:24
    jessica-jordan edited #1405
  • Sep 04 13:23
    jessica-jordan edited #1405
  • Sep 04 13:23
    jessica-jordan opened #1405
  • Sep 03 12:49
    Krinkle commented #1342
  • Aug 21 07:20
    patocallaghan commented #1401
  • Aug 16 13:56
    XhmikosR synchronize #1404
  • Aug 16 13:55
    XhmikosR synchronize #1404
  • Aug 16 13:10
    jsf-clabot commented #1404
  • Aug 16 13:10
    jsf-clabot commented #1404
  • Aug 16 13:10
    XhmikosR opened #1404
  • Aug 07 23:07
    timiyay closed #1403
  • Aug 07 23:07
    timiyay commented #1403
  • Aug 07 14:57
    platinumazure labeled #1403
  • Aug 07 14:57
    platinumazure commented #1403
  • Aug 07 09:03
    timiyay opened #1403
Stephen Yeung
@step2yeung
Thanks for the questions and will get that worked out :)
Joana Ivanova
@jivanova
hey :) has anyone implemented rerun of tests? Currently, I am trying to implement something similar to https://github.com/jdalton/qunit-extras/ and the asyncRetries setting but still no success :/
Stephen Yeung
@step2yeung

Hey folks!
Want to get some discussion on this question asked by @rwjblue on PR #1307
how do we support our required browser platforms if we require Promise here?

looking at the supported browsers page: https://jquery.com/browser-support/
we need to support IE 9+, one possibility is to provide a promise polyfill
Would like to see if there are other suggestions for a path forward... thoughts?

Anton
@aazavid
hi, everybody! How i make some example test in node.js. Run through the runner, swears "no define run", i try 'qunit' swears "no define funciton test"

function trim(string) {
return (string || "").replace(/^\s+|\s+$/g, "");
}

QUnit.test("Тест функции trim()", function() {
assert.ok(trim(' test ') == 'test', 'обрезаем крайние пробелы');
assert.ok(trim(' 1 ') == "1", 'очень много пробелов по бокам');
assert.ok(trim(' 24 ') == '24', 'пробелы и табы по бокам');
assert.equal(trim(''), '', 'Пустая строка');
assert.strictEqual(trim(' ][akep'), '][akep', "Должно быть ][акер")
});

Kevin Partington
@platinumazure
Hi @aazavid, thanks for stopping by! Could you please show exactly how you ran QUnit on the command line and the exact output?
Also, unrelated, you might prefer using assert.equal or assert.strictEqual for all of your equality comparisons-- the error message is a lot easier to work with in that case since it will call out expected/actual values.
Avery Bloom
@averydev
Hi there! I'm working on adding a feature to the QUnit Test page where if the user checks a custom box at the top, it'll automatically filter to a pre defined set of tests
I'm able to push my checkbox to the UrlConfig in QUnit, but i'm not able to actually change the tests that run except by manually updating the window.location. Setting the QUnit.config.filter = /foo*./ has no effect, nor does manually setting the QUnit.config.testId
those properties seem to be set, but it doesn't seem to have an effect
Kevin Partington
@platinumazure
Hi @averydev, thanks for reaching out. Any chance you could put together a Gist (or link to any existing GitHub repo) showing what you're trying to do?
Avery Bloom
@averydev
@platinumazure sure thing! This is in the context of an Ember app specifically.
though i don't think it would matter specifically
Avery Bloom
@averydev
Before I do, is this supposed to work? QUnit.config.testId = aTest.testId;Or is there some other step i'm missing?
Kevin Partington
@platinumazure
@averydev Thanks, I'm actually not at all sure. I don't know if that's supposed to work in general, or if it works if you then call some other function, or...
Avery Bloom
@averydev
The docs seem to say it pretty clearly, but it certainly has no perceivable effect :) I’m missing something.
Avery Bloom
@averydev
Ah well, i wasn't able to figure it out... instead i'm just directly updating the window location.
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!
Not A Number
@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();