Support transforming testRunner with preset/transform#8823
Support transforming testRunner with preset/transform#8823SimenB merged 5 commits intojestjs:masterfrom
Conversation
| "testEnvironment": "node", | ||
| "transformIgnorePatterns": [ | ||
| "jest-jasmine2", | ||
| "jest-circus" |
There was a problem hiding this comment.
Adding jest-circus as well so that when it becomes the default runner the tests won't fail
| "jest-jasmine2", | ||
| "jest-each", | ||
| "jest-circus" | ||
| ], |
There was a problem hiding this comment.
These will have to be ignored manually as a relative path to the package is used rather than node_modules.
Seems like the number of ignore paths might increase going forward, one idea I had was to add a pattern like jest-, but that doesn't seem to work in all cases
| runtime: Runtime, | ||
| testPath: string | ||
| ): Promise<TestResult> { | ||
| return Promise.resolve({ |
There was a problem hiding this comment.
just make the function async rather than Promise.resolve?
There was a problem hiding this comment.
we really should have a helper for creating "empty" test results. This is a pain for custom runners (as you can see here)
SimenB
left a comment
There was a problem hiding this comment.
I'm not sure if we should document that it can be transformed? Since everything should be transformable at some point it might not be worth it I guess
|
You mean a single CHANGELOG entry specifying that all everything is transformable? |
|
No, I meant in the documentation. I tmight be what people expect though, so no need. dunno! |
Personally I agree w/ this - which is the whole reason why I started this "Transform EVERYTHING!!" spree: it's really unexpected for somethings but not others to be transformed.
I think that's the best way to go about this CHANGELOG wise - otherwise we're all going to be making near-identical CHANGELOG entries. We could update the same log entry on our PRs, but that'd mean each PR would need to be rebased as the others are merged. I think what if we opened a new PR right now for just the CHANGELOG entry? that way we could have it prepared & it won't be forgotten, since it'll be there on the list of open PRs. |
df9a809 to
b444350
Compare
|
|
||
| import {TestResult} from '@jest/test-result'; | ||
|
|
||
| export default function emptyTestResult(): TestResult { |
There was a problem hiding this comment.
This seems to the minimal TestResult template that I could create
There was a problem hiding this comment.
Is there a legacy reason why leaks is mandatory, it looks like an optional field
There was a problem hiding this comment.
leaks should be optional, probably just an oversight. It's just a boolean though, right?
Could you add it to |
Moving this to a separate PR and reverting it util over here. |
c3f95da to
7caaa64
Compare
|
There seems to be a memory leak in the test for node 10. |
|
You can rebase for a fix for the leak |
4fe76fa to
87aaf3f
Compare
87aaf3f to
94e2a77
Compare
94e2a77 to
cd70978
Compare
ec32419 to
5069cef
Compare
|
CI is failing due to the yarn lock. The lock file will be modified in this PR as |
|
@Mark1626 yeah, that lockfile change looks correct 👍 |
|
Fixing this test now, I'll update once done |
| module.exports = { | ||
| presets: ['@babel/preset-env', '@babel/preset-typescript'], | ||
| presets: [ | ||
| ['@babel/preset-typescript'], |
There was a problem hiding this comment.
@SimenB I'm totally not sure why thing makes the test pass, any pointers?
There was a problem hiding this comment.
doesn't make much sense - this shouldn't be needed at all
There was a problem hiding this comment.
it's the same as the others - we either need to not transpile our runner or make sure to transpile it correctly (via adding targets since we don't want weird async function transpilation)
| presets: [ | ||
| ['@babel/preset-typescript'], | ||
| [ | ||
| '@babel/preset-env', | ||
| { | ||
| targets: {node: 8}, | ||
| }, | ||
| ], | ||
| ], |
There was a problem hiding this comment.
| presets: [ | |
| ['@babel/preset-typescript'], | |
| [ | |
| '@babel/preset-env', | |
| { | |
| targets: {node: 8}, | |
| }, | |
| ], | |
| ], | |
| presets: [ | |
| ['@babel/preset-env', {targets: {node: 'current'}}], | |
| '@babel/preset-typescript', | |
| ], |
| presets: [ | ||
| ['@babel/preset-typescript'], | ||
| [ | ||
| '@babel/preset-env', | ||
| { | ||
| targets: {node: 8}, | ||
| }, | ||
| ], | ||
| ], |
There was a problem hiding this comment.
| presets: [ | |
| ['@babel/preset-typescript'], | |
| [ | |
| '@babel/preset-env', | |
| { | |
| targets: {node: 8}, | |
| }, | |
| ], | |
| ], | |
| presets: [ | |
| ['@babel/preset-env', {targets: {node: 'current'}}], | |
| '@babel/preset-typescript', | |
| ], |
|
@Mark1626 this should be ready now? |
|
There is a e2e |
fba4c35 to
2abf528
Compare
|
This is the failing test I'm trying to fix
module.exports = {
plugins: [
'@babel/plugin-transform-regenerator',
'@babel/plugin-transform-runtime',
],
sourceType: 'script',
}The |
| "testEnvironment": "node", | ||
| "transformIgnorePatterns": [ | ||
| "jest-jasmine2" | ||
| ] |
There was a problem hiding this comment.
@SimenB This was the reason the last test was failing. Adding it manually to transformIgnorePatterns, again as mentioned in a comment below these ignores are needed only when testing the jest repo, any consumers will not need to add these as these will be within node_modules
| "@jest/console": "^26.6.2", | ||
| "@jest/environment": "^26.6.2", | ||
| "@jest/test-result": "^26.6.2", | ||
| "@jest/transform": "^26.6.2", |
There was a problem hiding this comment.
It's present in tsconfig.json.
Sorry this line should have been part of #8751 , got missed in the rebase I'll be more careful next time
|
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
Support transforming
testRunnerwithtransformPart of #8810
cc/ @SimenB
Test plan
Have added a test for transforming
testRunner