mercredi 11 mars 2020

Jest runs 40 times slower than mocha

I've opened a ticket, but it got closed immediately without any information if this is normal and acceptable;

I'll post the question here.


Thinking that this is normal could be one of the biggest mistakes of my career so far. I was tinkering with CodeSandbox and noticed how instantaneous the tests were compared to what I was used to. Set up a basic template project, and here are my results:

{
  "name": "jest-performance-test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "test": "mocha"
  },
  "dependencies": {
    "chai": "^4.2.0",
    "jest": "^23.0.0"
  },
  "devDependencies": {
    "mocha": "^7.1.0"
  }
}

jest.config.js

{
  "testRegex": "__tests__/*",
  "testEnvironment": "node",
}

Several dozen duplicated tests with

const {expect} = require('chai')

it ('should run the test', async () => {
  expect (true).to.be.true
})

//...

in each

running jest --watch, making a change and saving:

jest results

running yarn run test --watch (mocha --watch), making a change and saving:

enter image description here

--runInBand makes it even worse.

I get it, I'm stuck with 5y/o Windows laptop on HDD and all that, but 40 times?

I have projects with pretty intricate jest setups, and tried to solve the issue of performance many times over the last year or so.

Is there anything I can do to not switch to mocha/chai? I don't feel like running a single jest test anymore.

Aucun commentaire:

Enregistrer un commentaire