-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(transformers): use ts factory API for
hoisting
(#3058)
- Loading branch information
Showing
17 changed files
with
723 additions
and
338 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,46 @@ | ||
import * as path from 'path' | ||
import path from 'path' | ||
|
||
import execa from 'execa' | ||
|
||
import { json as runWithJson } from '../run-jest' | ||
import { runNpmInstall } from '../utils' | ||
|
||
const DIR = path.resolve(__dirname, '..', 'hoist-jest') | ||
const { createBundle } = require('../../scripts/lib/bundle') | ||
|
||
beforeEach(() => { | ||
runNpmInstall(DIR) | ||
}) | ||
const executeTest = (dirName: string): void => { | ||
test(`successfully runs the tests with isolatedModules: false`, () => { | ||
const { json } = runWithJson(dirName) | ||
|
||
expect(json.success).toBe(true) | ||
}) | ||
|
||
test(`successfully runs the tests with isolatedModules true`, () => { | ||
const { json } = runWithJson(dirName, ['-c=jest-isolated.config.js']) | ||
|
||
test('successfully runs the tests inside `hoist-jest/` with isolatedModules: false', () => { | ||
const { json } = runWithJson(DIR) | ||
expect(json.success).toBe(true) | ||
}) | ||
} | ||
|
||
expect(json.success).toBe(true) | ||
describe('non-ts-factory', () => { | ||
const DIR = path.resolve(__dirname, '..', 'hoist-jest', 'non-ts-factory') | ||
|
||
beforeAll(() => { | ||
runNpmInstall(DIR) | ||
const bundle = createBundle() | ||
execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', bundle], { | ||
cwd: DIR, | ||
}) | ||
}) | ||
|
||
executeTest(DIR) | ||
}) | ||
|
||
test('successfully runs the tests inside `hoist-jest/` with isolatedModules true', () => { | ||
const { json } = runWithJson(DIR, ['-c=jest-isolated.config.js']) | ||
describe('ts-factory', () => { | ||
const DIR = path.resolve(__dirname, '..', 'hoist-jest', 'ts-factory') | ||
|
||
beforeAll(() => { | ||
runNpmInstall(DIR) | ||
}) | ||
|
||
expect(json.success).toBe(true) | ||
executeTest(DIR) | ||
}) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
{ | ||
"dependencies": { | ||
"react": "^17.0.2", | ||
"typescript": "~3.8.3" | ||
}, | ||
"jest": { | ||
"automock": true, | ||
"globals": { | ||
"ts-jest": { | ||
"diagnostics": false, | ||
"tsconfig": { | ||
"allowJs": true | ||
} | ||
} | ||
}, | ||
"roots": ["<rootDir>", "<rootDir>/../__tests__"], | ||
"moduleNameMapper": { | ||
"react$": "<rootDir>/node_modules/react" | ||
}, | ||
"transform": { | ||
"^.+\\.[tj]sx?$": "ts-jest" | ||
} | ||
} | ||
} |
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,18 @@ | ||
module.exports = { | ||
automock: true, | ||
globals: { | ||
'ts-jest': { | ||
isolatedModules: true, | ||
tsconfig: { | ||
allowJs: true, | ||
}, | ||
}, | ||
}, | ||
roots: ['<rootDir>', '<rootDir>/../__tests__'], | ||
moduleNameMapper: { | ||
react$: '<rootDir>/node_modules/react', | ||
}, | ||
transform: { | ||
'^.+.[tj]sx?$': '<rootDir>/../../../dist/index.js', | ||
}, | ||
} |
2 changes: 1 addition & 1 deletion
2
e2e/hoist-jest/package-lock.json → e2e/hoist-jest/ts-factory/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.