Jest is bad. Not only as a testing framework, but as a utility in general.

Artemko
2 min readAug 18, 2020

Jest will make you hate testing if only you aren’t React developer and you do use conveniently npx-created test suites for your components. Otherwise — it’s a pain in the ass.

  1. Jest configs can‘t be written in TS
  2. Jest doesn’t support “root hooks“ to setup environment for all test suits. It’s atype of hook before (or after) every test in every file. Instead, you are forced to use some weird jest-environment-node module with an awkward configuration process.
  3. That custom environment config you can’t write in TS also
  4. You can’t simply export global variables for all test suites (see #2)
  5. Jest doesn’t know how to handle arguments for scripts (crucial for integration tests)
  6. Jest can’t nest test suits inside each other.
  7. Jest starts and generally runs slower than other testing frameworks (except maybe Karma)
  8. Jest configs can’t be written as ES6 modules without third-party tools (babel, etc.)

Update from 19.04.2022

Jest now can support TS config via a third-party solution, for this you have to install ts-jest and @jest/types packages.
For example, my jest.config.ts looks like this:

import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
preset: 'jest-preset-angular',
verbose: true,
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/dist/'
],
globals: {
'ts-jest': {
tsconfig: 'tsconfig.spec.json',
},
},
};

export default config;

But all that you can’t do with Jest you can do with Mocha. I see no reasons to migrate to Jest, while Mocha still can do everything better.

Also, there is a newcomer — Vitest. Since the Vite team does everything at top-notch, I doubt that Vitest would be anyhow worse than Jest, so welcome Vitest!

--

--

Artemko
Artemko

Written by Artemko

Software Engineer with experience.

Responses (2)