•  
      request #13806 Use Jest as the default test framework for JS unit tests
    Infos
    #13806
    Thomas Gerbet (tgerbet)
    2019-11-22 11:34
    2019-08-26 17:48
    14316
    Details
    Use Jest as the default test framework for JS unit tests

    The initial setup and usage of Jest has been merged in request #13789. This request is about moving the other test suites and to drop the usage of Karma/Jasmine within Tuleap.

    Why are we moving away from Karma/Jasmine ?

    Karma / Jasmine has been a great help in setting up unit testing of javascript files and apps. However, they came with a few problems:

    • The more tests we have, the more Jenkins "steps" we have to add.
    • Each karma "step" means spinning up a new headless chrome, which consumes resources.
    • For each webpack configuration, we need a new, separate, karma file, which means even more Jenkins steps. This is because karma-webpack can only deal with one webpack configuration.
    • Jasmine tests have to be run all at the same time. The only way to control which tests are run is through hacky "fit / fdescribe" or "xit / xdescribe". When you have more than 500 tests is becomes slow to run all tests everytime.
    • coverage produced a HTML report, but we opened a browser to navigate it.
    • We had to import manually our tests (see request #13653) in part because we badly mocked an external dependency of many apps: TLP.
    • Karma's goal was to run tests in a real browser, but it's hard to say if we ever had the same goal when using it. Given we never ran our tests on IE11 which is the lowest common denominator as far as our browser support is concerned, we never really took advantage of "running tests in a real browser".

    Not all of those are due to Karma or Jasmine, some are due to our own usage of them. We can do better.

    Why are we moving to Jest ?

    Jest offers all the same features as Jasmine but with additional goodness.

    • We hope to be able to unify all JS test suites into a single "npm run test", meaning only one Jenkins step
    • Even if we can't, we're no longer spinning a real browser but jsdom, which runs only in node. It should be faster.
    • Jest tests can be ran one at a time, which means having the same dev experience as PHPUnit tests. (Run continuously the test suite associated to your file / component)
    • Jest handles coverage better, which means seeing test coverage in our IDE
    • Jest can do snapshot testing (Jasmine can't)
    • And error messages are just better. No more "Expected true to be false".
    Empty
    Dev tools
    development
    Empty
    Empty
    Stage
    Empty
    Closed
    2019-11-22
    Attachments
    Empty
    References

    List of items referenced by or referencing this item.

    Git commit

    Follow-ups

    • User avatar
      Closing, everything is done o/ .

      • Status changed from Under implementation to Closed
      • Connected artifacts
      • Close date set to 2019-11-22
    • User avatar
      gerrit #16835 integrated into Tuleap 11.8.99.84
    • User avatar
      gerrit #16836 integrated in its repository
    • User avatar
      gerrit #16828 (Remove tlp_mocks_alias) integrated into Tuleap 11.8.99.70.
    • User avatar
      gerrit #16811 integrated into Tuleap 11.8.99.66 (Remove tuleap-vue-components alias)
    • User avatar
      gerrit #16800 integrated into Tuleap 11.8.99.50
    • User avatar
      Since all the tests have been moved to Jest https://github.com/Enalean/docker-tuleap-test-karma is now archived.

      • Original Submission
    • User avatar
      gerrit #16776 integrated into Tuleap 11.8.99.45.
    • User avatar
      gerrit #16775 integrated into baseline (Clean-up karma references).
    • User avatar
      gerrit #16739 has been merged (Enalean helpdesk plugin).
    • User avatar
      gerrit #16451 integrated into TTM repository
    • User avatar
      gerrit #16727 integrated into Tuleap 11.8.99.19
    • User avatar
      gerrit #16506 integrated into Tuleap 11.8.99.15
    • User avatar
      gerrit #16502 (tlp aliases) integrated into Tuleap 11.7.99.7
    • User avatar
      gerrit #16455 (Jest project for baseline) integrated
    • User avatar
      gerrit #16461 (Jenkinsfile) integrated into Tuleap 11.6.99.127
    • User avatar
      gerrit #16450 (Jest projects) integrated into Tuleap 11.6.99.121
    • User avatar
      gerrit #16212 (Tracker) integrated into Tuleap 11.6.99.76
    • User avatar
      gerrit #16224 (Baseline) integrated into its repo

      • Original Submission
    • User avatar
      gerrit #16188 (Pullrequest) integrated into Tuleap 11.5.99.222

      • Original Submission
    • User avatar
      gerrit #16166 (Document) integrated into Tuleap 11.5.99.195

      • Original Submission
    • User avatar
      gerrit #16120 (FRS) integrated into Tuleap 11.5.99.165.

      • Original Submission
    • User avatar
      • Original Submission
    • User avatar
      gerrit #16097 integrated into Tuleap 11.5.99.140
    • User avatar
      gerrit #16091 integrated into Tuleap 11.5.99.136
    • User avatar
      gerrit #16087 integrated into Tuleap 11.5.99.133
    • User avatar
      gerrit #16081 integrated into Tuleap 11.5.99.122
    • User avatar
      gerrit #16082 integrated into Tuleap 11.5.99.121
    • User avatar
      gerrit #15998 integrated into Tuleap 11.5.99.115
    • User avatar
      gerrit #15999 integrated into Tuleap 11.5.99.101
    • User avatar
      gerrit #15990 integrated into Tuleap 11.5.99.87
    • User avatar
      • Original Submission
    • User avatar
      gerrit #15959 integrated into Tuleap 11.5.99.64 (crosstracker)
    • User avatar
      gerrit #15929 integrated into Tuleap 11.5.99.53 (Timetracking)

      • Original Submission
    • User avatar
      • Original Submission
    • User avatar
      gerrit #15928 integrated into Tuleap 11.5.99.36 (Git plugin)
    • User avatar
      last edited by: Thomas Gerbet (tgerbet) 7 months ago
      Thanks for taking care of that, I was too lazy to do it right now
    • User avatar
      Added a little context on why we are doing this. We might look away and wonder why we chose this tool over that one.

      • Original Submission
    • User avatar
      • Original Submission