•  
      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
    15017
    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
    Referencing request #13806

    Git commit

    tuleap/tuleap/stable

    Move the Git plugin to Jest 4180ec7d8e
    Move the timetracking plugin to Jest 04a59d9609
    Move the crosstracker plugin to Jest 6741d43307
    Jest tests should be marked as failed when console.error() or console.warn() is used 960c273511
    Move the label plugin to Jest e6bcd7991b
    Move tests related to Tuleap Core to Jest 88b08fb2fa
    Make sure tests related CKEditor file upload handling test something c4cfa182d2
    Remove bundled JS libs from the coverage collection c96548ad2c
    Run Jest tests sequentially in the CI test pipeline a99e0b5f33
    Remove the bundled CodeMirror code from tlp documentation b2fa2a930b
    tlp documentation should not be broken 66bbda285f
    Move the FRS plugin to Jest 3a3d2863f2
    Move the document plugin to Jest 2d864aea47
    Move the pullrequest plugin to Jest 4dfb854c58
    Move the tracker plugin to Jest bda9270526
    Use Jest Multi-Project-Runner instead of a global config ba2b1f8e08
    Jenkinsfile action to run Jest tests should be usable by external plugins 3620da7068
    Jest should not replace all modules with tlp in the name 2a40392a93
    Migrate kanban to Jest 176fdfd8ea
    Migrate Planning-v2 to Jest dd3489c62e
    Purge all karma/jasmine configuration 5e70043ab5
    Each modules of the AgileDashboard plugin should use an independant Jest config e26d71dc94
    Remove tuleap-vue-components alias 2e3479f6bf
    Remove tlp_mocks_alias 282966ca90
    Remove tlp-fetch-mocks-helper-jest alias 90566b85fa
    Move the testmanagement plugin to Jest 1ddb8ae2ce
    Remove tlp-fetch-mocks-helper-jest alias ddc4d8d209
    Clean-up karma references a6f2a660b6
    Use Jest Multi-Project-Runner instead of a global config 2e2a8b0c81
    Move the baseline plugin to Jest 10b7eb43a4

    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