aelbore / esbuild-jest

A Jest transformer using esbuild
519 stars 51 forks source link

Why? #58

Open bdombro opened 3 years ago

bdombro commented 3 years ago

Could someone add to the README the motivation behind this plugin (aka why this plugin exists)? Does it make tests run faster bc esbuild is faster babel? Or maybe is it useful to test using the same transpiler as prod?

Also, what's the status? Is it mostly mature or is it experimental?

HaydenOrz commented 2 years ago

If you build your application with EsBuild and use it to transform the code to support jest. Then I think this plugin makes sense because you can remove all dependencies about babel in package.json and never have to maintain babel.config again.

But so far I don't think it's mature

PatrykMilewski commented 2 years ago

It's also a lot faster than Babel, which is important. I don't want to wait 5 seconds each time before tests will start, because Babel needs to transpile stuff, then using ESBuild instead makes perfect sense.

vertic4l commented 2 years ago

@PatrykMilewski and how comes that esbuild-jest relies on things like "@babel/preset-typescript" to make tests in tsx-files work ?

gustawdaniel commented 1 year ago

Lets see on two examples. There is my config

module.exports = {
  roots: ['<rootDir>'],
  testMatch: ['**/__tests__/**/*.+(ts|tsx)', '**/?(*.)+(spec|test).+(ts|tsx)'],
  transform: {
    '^.+\\.(ts|tsx)$': 'esbuild-jest', // or 'jest-ts'
  },
  setupFilesAfterEnv: [],
  testEnvironment: 'node',
}

And result showing how fast tests are

1642781701974

In my opinion it seems to be mature and I have not problem with it (not counting decorators in nest.js)

I opened issues: https://github.com/hannoeru/jest-esbuild/issues/7 and https://github.com/AkifumiSato/esbuild-jest-transform/issues/8

so it is interesting for me, what will be result of discussion between authors of them. From README there is conclusion that we have three almost identical packages and noone did described differences between them.