-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support transforming testRunner with preset/transform #8823
Changes from all commits
d0077f8
2abf528
34c2aec
3beec27
6d5e58c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,10 @@ | |
"testRegex": "/__tests__/.*\\.(js)$", | ||
"testEnvironment": "node", | ||
"transformIgnorePatterns": [ | ||
"/jest-environment-node/" | ||
"jest-circus", | ||
"jest-each", | ||
"jest-environment-node/", | ||
"jest-jasmine2" | ||
], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These will have to be ignored manually as a relative path to the package is used rather than node_modules. |
||
"moduleFileExtensions": [ | ||
"js" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
it('should add two numbers', () => { | ||
expect(1 + 1).toBe(2); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
module.exports = { | ||
presets: [ | ||
['@babel/preset-env', {targets: {node: 'current'}}], | ||
'@babel/preset-typescript', | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"jest": { | ||
"rootDir": "./", | ||
"testRunner": "<rootDir>/test-runner.ts" | ||
}, | ||
"dependencies": { | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/preset-typescript": "^7.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import {JestEnvironment} from '@jest/environment'; | ||
import {TestResult, createEmptyTestResult} from '@jest/test-result'; | ||
import {Config} from '@jest/types'; | ||
import Runtime from 'jest-runtime'; | ||
|
||
export default async function testRunner( | ||
globalConfig: Config.GlobalConfig, | ||
config: Config.ProjectConfig, | ||
environment: JestEnvironment, | ||
runtime: Runtime, | ||
testPath: string, | ||
): Promise<TestResult> { | ||
return { | ||
...createEmptyTestResult(), | ||
numPassingTests: 1, | ||
testFilePath: testPath, | ||
testResults: [ | ||
{ | ||
ancestorTitles: [], | ||
duration: 2, | ||
failureMessages: [], | ||
fullName: 'sample test', | ||
location: null, | ||
numPassingAsserts: 1, | ||
status: 'passed', | ||
title: 'sample test', | ||
}, | ||
], | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"module": "commonjs", | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
"@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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add to references in tsconfig There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's present in |
||
"@jest/types": "^26.6.2", | ||
"@types/node": "*", | ||
"chalk": "^4.0.0", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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