Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Jest preset improvements #851

Closed
edmorley opened this issue May 7, 2018 · 5 comments
Closed

Jest preset improvements #851

edmorley opened this issue May 7, 2018 · 5 comments

Comments

@edmorley
Copy link
Member

edmorley commented May 7, 2018

Whilst working on #845 I found a few areas of improvement for the Jest preset:

  1. it currently both duplicates parts of babel-jest but is also missing some of the extra functionality that it offers - so it seems preferable to re-use babel-jest instead
  2. the Jest config is unnecessarily saved to a temporary file, when we can instead pass via the config option (so long as it's stringified to avoid Can not use custom transfom by runCLI jestjs/jest#5429) Fixed by Morph Neutrino API and CLI into middleware injectors for external CLI tools #852.
  3. the preset sets the retainLines option which is no longer necessary, now that jest supports sourcemaps

For (1), see possible alternatives here:
#845 (comment)

@edmorley edmorley added this to the v9 milestone May 7, 2018
@edmorley
Copy link
Member Author

Issue 2 above was fixed as part of #852.

As for the rest, I've found a couple of different approaches that use babel-jest (rather than reimplementing bits of it), though hit a caching bug, which I've fixed upstream in jestjs/jest#6699. We now need to wait for it to be included in a released version.

Ideally I'd also like to be able to ditch the custom transformer entirely, but this would require further changes to upstream to add an additional option for specifying the custom transformer options. I'll see if they are open to supporting this.

@eliperelman
Copy link
Member

Any updates here? Does this still need to happen as part of v9?

@SimenB
Copy link

SimenB commented Sep 7, 2018

The PR to Jest was released in 23.4.2, I don't think this needs anything from Jest now?

@eliperelman
Copy link
Member

@edmorley do you think it's sufficient then to just open a patch for the retainLines part for v9?

@edmorley
Copy link
Member Author

I've opened #1183 which switches us to using babel-jest.

edmorley added a commit that referenced this issue Oct 21, 2018
We were previously just reimplementing parts of it, and not using
the latest recommended Babel settings (such as still setting
`retainLines: true` when sourcemaps are supported natively).

There isn't currently a way to set the babel-jest `createTransformer()`
options via Jest configuration/globals, so we instead have to resort
to using an environment variable. This has the limitation of only
supporting Babel options that are serializable (virtually all commonly
used configuration options are), with any others being silently omitted.
However this was already the case when using `globals` anyway.

See:
https://github.com/facebook/jest/blob/v23.6.0/packages/babel-jest/README.md
https://github.com/facebook/jest/blob/v23.6.0/packages/babel-jest/src/index.js

Fixes #851.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants