-
-
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
feat: create new @jest/transform package #7915
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/__mocks__/** | ||
**/__tests__/** | ||
src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "@jest/transform", | ||
"version": "24.1.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/jest.git", | ||
"directory": "packages/jest-transform" | ||
}, | ||
"license": "MIT", | ||
"main": "build/index.js", | ||
"dependencies": { | ||
"@babel/core": "^7.1.0", | ||
"babel-plugin-istanbul": "^5.1.0", | ||
"chalk": "^2.0.1", | ||
"convert-source-map": "^1.4.0", | ||
"fast-json-stable-stringify": "^2.0.0", | ||
"graceful-fs": "^4.1.15", | ||
"jest-haste-map": "^24.0.0", | ||
"jest-regex-util": "^24.0.0", | ||
"jest-util": "^24.0.0", | ||
"micromatch": "^3.1.10", | ||
"realpath-native": "^1.1.0", | ||
"slash": "^2.0.0", | ||
"write-file-atomic": "2.4.1" | ||
}, | ||
"devDependencies": { | ||
"@types/babel__core": "^7.0.4", | ||
"@types/convert-source-map": "^1.5.1", | ||
"@types/graceful-fs": "^4.1.2", | ||
"@types/micromatch": "^3.1.0", | ||
"@types/write-file-atomic": "^2.1.1" | ||
}, | ||
"engines": { | ||
"node": ">= 6" | ||
}, | ||
"gitHead": "b16789230fd45056a7f2fa199bae06c7a1780deb" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,20 +6,15 @@ | |
* | ||
*/ | ||
|
||
import {normalize} from 'jest-config'; | ||
import shouldInstrument from '../shouldInstrument'; | ||
import {makeGlobalConfig} from '../../../../TestUtils'; | ||
|
||
describe('shouldInstrument', () => { | ||
const defaultFilename = 'source_file.test.js'; | ||
const defaultOptions = { | ||
collectCoverage: true, | ||
}; | ||
const defaultConfig = normalize( | ||
{ | ||
rootDir: '/', | ||
}, | ||
{}, | ||
).options; | ||
const defaultConfig = makeGlobalConfig({rootDir: '/'}); | ||
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. I had completely forgotten about this util 😅 Dropping the |
||
|
||
describe('should return true', () => { | ||
const testShouldInstrument = ( | ||
|
36 changes: 36 additions & 0 deletions
36
packages/jest-transform/src/enhanceUnexpectedTokenMessage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
|
||
// @flow | ||
|
||
import chalk from 'chalk'; | ||
|
||
const DOT = ' \u2022 '; | ||
|
||
export default function enhanceUnexpectedTokenMessage(e: Error) { | ||
e.stack = | ||
`${chalk.bold.red('Jest encountered an unexpected token')} | ||
|
||
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript. | ||
|
||
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules". | ||
|
||
Here's what you can do: | ||
${DOT}To have some of your "node_modules" files transformed, you can specify a custom ${chalk.bold( | ||
'"transformIgnorePatterns"', | ||
)} in your config. | ||
${DOT}If you need a custom transformation specify a ${chalk.bold( | ||
'"transform"', | ||
)} option in your config. | ||
${DOT}If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the ${chalk.bold( | ||
'"moduleNameMapper"', | ||
)} config option. | ||
|
||
You'll find more details and examples of these config options in the docs: | ||
${chalk.cyan('https://jestjs.io/docs/en/configuration.html')} | ||
|
||
${chalk.bold.red('Details:')} | ||
|
||
` + e.stack; | ||
|
||
return e; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* 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. | ||
* | ||
* @flow | ||
*/ | ||
|
||
export {default as ScriptTransformer} from './ScriptTransformer'; | ||
export {default as shouldInstrument} from './shouldInstrument'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
looks like lerna leftover
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.
yeah, not sure what purpose it serves, but I don't wanna delete it