-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow subclasses to extend
processAsync
and getCacheKeyAsync
(
- Loading branch information
Showing
7 changed files
with
84 additions
and
88 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
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,15 @@ | ||
import { json as runWithJson, onNodeVersions } from '../run-jest' | ||
|
||
const DIR = 'extend-ts-jest' | ||
|
||
// Only need to test in ESM because ESM makes `this` context become `undefined` | ||
onNodeVersions('>=12.16.0', () => { | ||
test(`successfully runs the tests inside ${DIR}`, () => { | ||
const { json } = runWithJson(DIR, undefined, { | ||
nodeOptions: '--experimental-vm-modules --no-warnings', | ||
}) | ||
|
||
expect(json.success).toBe(true) | ||
expect(json.numTotalTestSuites).toBe(1) | ||
}) | ||
}) |
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 @@ | ||
test('should pass', () => { | ||
expect(true).toBe(true) | ||
}) |
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,10 @@ | ||
const tsJestTransformer = require('../../dist/ts-jest-transformer') | ||
|
||
class FooTransformer extends tsJestTransformer.TsJestTransformer { | ||
async processAsync(sourceText, sourcePath, transformOptions) { | ||
return new Promise((resolve) => resolve(this.process(sourceText, sourcePath, transformOptions))) | ||
} | ||
} | ||
module.exports = { | ||
createTransformer: () => new FooTransformer(), | ||
} |
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,12 @@ | ||
{ | ||
"jest": { | ||
"globals": { | ||
"ts-jest": { | ||
"isolatedModules": true | ||
} | ||
}, | ||
"transform": { | ||
"^.+\\.tsx?$": "./foo-transformer.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
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