Run code transforms over global{Setup,Teardown}#7562
Conversation
| import type {Test} from 'types/TestRunner'; | ||
|
|
||
| import {extname, resolve} from 'path'; | ||
| import pEachSeries from 'p-each-series'; |
There was a problem hiding this comment.
using p-each-series allows us to make sure one require hook does not interfere with another
|
|
||
| import {extname, resolve} from 'path'; | ||
| import pEachSeries from 'p-each-series'; | ||
| import {addHook} from 'pirates'; |
There was a problem hiding this comment.
pirates is what babel-register uses
65a50f8 to
53e8f54
Compare
Codecov Report
@@ Coverage Diff @@
## master #7562 +/- ##
==========================================
- Coverage 68.28% 67.93% -0.36%
==========================================
Files 250 248 -2
Lines 9627 9503 -124
Branches 5 5
==========================================
- Hits 6574 6456 -118
+ Misses 3051 3045 -6
Partials 2 2
Continue to review full report at Codecov.
|
da9c958 to
655d16e
Compare
655d16e to
8b3b505
Compare
8b3b505 to
650a23e
Compare
|
This doesn't work with "testEnvironment" |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Fixes #5164. A caveat is that this can not transpile stuff in
node_modules. This is because in order to transpile using e.g.babel-jest, we would need to loadbabel-jest, which means we cannot transpile it.We could try to do static analysis on the transformer modules defined in the config and create a dependency tree of the only files we won't transform, but I'm not sure if it's worth it (or possible). Stuff in
node_modulesshould be runnable in node either way.EDIT: If people want, we can disable
node-modulesignoring, and try to catch errors during transform. By default, Jest hastransformIgnorePatternonnode_modules, so shouldn't make a huge differenceTest plan
I added a flow annotation to an existing test to show the transform happens.