Skip to content

Commit

Permalink
added readme
Browse files Browse the repository at this point in the history
  • Loading branch information
kenotron committed Mar 23, 2018
1 parent 70b2a8e commit 064313b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Jest with ES Modules!

This repo demonstrate how one can use `esm` module with `jest`.

The jist is that we have to go patch up the internal jest require at the proper time. This requires a custom jest runner. To run this sample, run:

```
yarn
yarn test
```

esm-jest.js currently tries to infer from the test and source files whether they are ESM or not by match against ".mjs" or if it consists of import / export. The latter seems expensive and inaccurate unless we pair it with Acorn parser (which is what ESM internally is doing). One can take this repo and make it more bullet proof, but it is a working example of something that works without having to transpile anything to support ESM.

## Inspiration

The inspiration for all this is from the solution listed here: https://stackoverflow.com/questions/46433678/specify-code-to-run-before-any-jest-setup-happens

0 comments on commit 064313b

Please sign in to comment.