Skip to content

Commit a65079f

Browse files
committed
fix: allow (but deprecate) use of old preprocessor.js
1 parent b895cb4 commit a65079f

8 files changed

Lines changed: 58 additions & 0 deletions

File tree

preprocessor.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
console.warn(
2+
`[ts-jest][DEPRECATED] - replace any occurrences to "ts-jest/dist/preprocessor.js" or ` +
3+
` "<rootDir>/node_modules/ts-jest/preprocessor.js"` +
4+
` in the 'transform' section of your Jest config with just "ts-jest".`
5+
);
6+
7+
module.exports = require('./dist');

scripts/tests.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ function createIntegrationMock() {
3939
path.resolve(testCaseModuleFolder, 'package.json')
4040
);
4141

42+
// TODO: remove this in next major version as well as the test, and the preprocessor.js file in root
43+
// Copy preprocessor.js
44+
fs.copySync(
45+
path.resolve(rootDir, 'preprocessor.js'),
46+
path.resolve(testCaseModuleFolder, 'preprocessor.js')
47+
);
48+
4249
// Copy dist folder
4350
fs.copySync(
4451
path.resolve(rootDir, 'dist'),
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Deprecated Jest transform value should log the depration message 1`] = `"[ts-jest][DEPRECATED] - replace any occurrences to \\"ts-jest/dist/preprocessor.js\\" or \\"<rootDir>/node_modules/ts-jest/preprocessor.js\\" in the 'transform' section of your Jest config with just \\"ts-jest\\"."`;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import runJest from '../__helpers__/runJest';
2+
3+
describe('Deprecated Jest transform value', () => {
4+
it('should log the depration message', () => {
5+
const result = runJest('../deprecated-transform', ['--no-cache']);
6+
7+
const output = result.stderr;
8+
9+
// get only the line with deprecation message (we dont want the snapshot to contain any timing or test name)
10+
const msg = output.split('\n').find(line => /deprecated/i.test(line));
11+
12+
expect(msg).toMatchSnapshot();
13+
});
14+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export class Hello {
2+
constructor(readonly msg: string) {}
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
declare var jest, describe, it, expect;
2+
3+
import { Hello } from '../Hello';
4+
5+
describe('Hello Class', () => {
6+
it('should create a new Hello', () => {
7+
const hello = new Hello('foo');
8+
expect(hello.msg).toBe('foo');
9+
});
10+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"jest": {
3+
"transform": {
4+
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
5+
},
6+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
7+
"moduleFileExtensions": ["ts", "js"]
8+
}
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
}
5+
}

0 commit comments

Comments
 (0)