•  
      request #13806 Use Jest as the default test framework for JS unit tests
    Infos
    #13806
    Thomas Gerbet (tgerbet)
    2024-10-11 14:46
    2019-08-26 17:48
    15018
    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".
    Dev tools
    development
    Empty
    • [ ] enhancement
    • [ ] internal improvement
    Empty
    Stage
    Empty
    Closed
    2019-11-22
    Attachments
    Empty
    References

    Follow-ups

    User avatar
    Joris MASSON (jmasson)2024-10-11 14:46

    This request's goal was to move from Jasmine to Jest. See request #27548 for the move from Jest to Vitest


    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Thomas Gerbet (tgerbet)2019-11-22 11:34
    Closing, everything is done o/ .

    • Status changed from Under implementation to Closed
    • Connected artifacts
    • Close date set to 2019-11-22
    User avatar
    Joris MASSON (jmasson)2019-09-26 12:37
    gerrit #16224 (Baseline) integrated into its repo

    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    gerrit #16188 (Pullrequest) integrated into Tuleap 11.5.99.222

    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Joris MASSON (jmasson)2019-09-12 11:30
    gerrit #16166 (Document) integrated into Tuleap 11.5.99.195

    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Thomas Gerbet (tgerbet)2019-09-09 15:45
    gerrit #16120 (FRS) integrated into Tuleap 11.5.99.165.

    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Thomas Gerbet (tgerbet)2019-09-09 11:27
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Joris MASSON (jmasson)2019-08-28 16:54
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Joris MASSON (jmasson)2019-08-27 18:31
    gerrit #15929 integrated into Tuleap 11.5.99.53 (Timetracking)

    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Thomas Gerbet (tgerbet)2019-08-27 11:16
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Joris MASSON (jmasson)2019-08-26 18:40
    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
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Thomas Gerbet (tgerbet)2019-08-26 18:02
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes