GithubHelp home page GithubHelp logo

dog-fooding qunit about qunit HOT 2 CLOSED

qunitjs avatar qunitjs commented on June 22, 2024
dog-fooding qunit

from qunit.

Comments (2)

jzaefferer avatar jzaefferer commented on June 22, 2024

Could you provide an example of how exposing those would help?

from qunit.

gutzofter avatar gutzofter commented on June 22, 2024

@jzaeffer - I'm sorry! I'm no longer advocating for exposure of the functions. What I'm going to argue for is a plug-in extensibility system.

Case in point:
for (var i = 0; i < config.assertions.length; i++) {
var assertion = config.assertions[i];

    var li = document.createElement("li");
    li.className = assertion.result ? "pass" : "fail";
    li.appendChild(document.createTextNode(assertion.message || "(no message)"));
    ol.appendChild(li);

    if (assertion.result) {
        good++;
    } else {
        bad++;
        config.stats.bad++;
        config.moduleStats.bad++;
    }
}

This code here mixes the test result management with presentation.

In your code base: test storage, test runner, test results, and presentation (even some profiling) are all mixed together.

What I would like to recommend that all these be made plug-ins, with the capabilities to wrap core function.

Here is a unit test that I have for an Ajax request:

should('show kits list when [delete] clicked after clicking on row from kits list', function() {
    var origAjax = $.ajax;
    var testData = {};
    $.ajax = function(data) {
        testData = data;
    };
    $('#kits_tbl tbody tr :first').click();
    $('#delete_edit').click();
    same(testData.data, 'type=remove&kit_number=THX-1138&kit_description=A+Doohickey+used+on+Jaberwockies');

    var response = {};
    response.status = 'success';
    testData.success(response); // process edit

    testData.success(myKitsListContent); // reload content
    $.ajax = origAjax;

    isListVisible();

});

In this test I'm able to wrap the $.ajax function in jquery and utilize my own. This allow me to extend ajax functionality. With this capabilty now I can insert monitoring sensing data/callbacks to ajax.

You can do the same with plug-ins for qunit.

A unit tester only has one concern did my assertions pass or fail. More repsonsibility on the unit tester is too much!

So instead of qunit keeping track of execution time of tests, you can create a plug-in that wraps tests and will keep track of the time of execution.

from qunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.