From 02b143993cfc4883e42ba5af871fb628b4589de0 Mon Sep 17 00:00:00 2001 From: Huafu Gandon Date: Sat, 22 Sep 2018 11:13:00 +0200 Subject: [PATCH] ci(cache): improves cache handling & use a non-deleted dir --- .gitignore | 2 +- .npmignore | 1 + .travis.yml | 1 + appveyor.yml | 1 + e2e/__cases__/deep/src/Tests/jest.config.js | 1 - e2e/__cases__/ts-jest-checks/index.spec.ts | 12 +++ e2e/__helpers__/test-case/run-result.ts | 18 +++- e2e/__helpers__/test-case/runtime.ts | 87 ++++++++++-------- e2e/__helpers__/test-case/types.ts | 1 + e2e/__templates__/default/jest.config.js | 1 - e2e/__templates__/with-babel-6/jest.config.js | 1 - e2e/__templates__/with-babel-7/jest.config.js | 1 - e2e/__templates__/with-jest-22/jest.config.js | 1 - .../with-typescript-2-7/jest.config.js | 1 - .../with-unsupported-version/jest.config.js | 1 - .../__snapshots__/diagnostics.test.ts.snap | 10 +- .../isolated-modules.test.ts.snap | 10 +- .../__snapshots__/simple.test.ts.snap | 91 ------------------- .../__snapshots__/source-map.test.ts.snap | 10 +- ...{simple.test.ts => ts-jest-checks.test.ts} | 5 +- e2e/jest.config.js | 2 +- jest.config.js | 2 +- scripts/lib/paths.d.ts | 2 + scripts/lib/paths.js | 2 + 24 files changed, 101 insertions(+), 163 deletions(-) create mode 100644 e2e/__cases__/ts-jest-checks/index.spec.ts delete mode 100644 e2e/__tests__/__snapshots__/simple.test.ts.snap rename e2e/__tests__/{simple.test.ts => ts-jest-checks.test.ts} (72%) diff --git a/.gitignore b/.gitignore index 0f63580947..bc66b30bc2 100644 --- a/.gitignore +++ b/.gitignore @@ -43,7 +43,7 @@ jspm_packages .vscode .idea - +.cache # tests specific tests/simple-long-path/long-src-path diff --git a/.npmignore b/.npmignore index 2c9e8e1826..807d8ccce6 100644 --- a/.npmignore +++ b/.npmignore @@ -69,6 +69,7 @@ tsconfig.build.json tslint.json .npmrc .markdownlint.yaml +.cache # Github Pages docs diff --git a/.travis.yml b/.travis.yml index a25fb34449..40686a9023 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ env: cache: npm: true directories: + - .cache - /tmp/ts-jest-e2e-workdir/__templates__ node_js: diff --git a/appveyor.yml b/appveyor.yml index d2cd89b28c..7610f4e0f9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -28,6 +28,7 @@ install: - npm run clean -- --when-ci-commit-message cache: + - .cache -> package.json - '%APPDATA%\npm-cache' - '%APPDATA%\ts-jest-e2e\__templates__' diff --git a/e2e/__cases__/deep/src/Tests/jest.config.js b/e2e/__cases__/deep/src/Tests/jest.config.js index 6e63135aff..5f8f09a3cc 100755 --- a/e2e/__cases__/deep/src/Tests/jest.config.js +++ b/e2e/__cases__/deep/src/Tests/jest.config.js @@ -20,5 +20,4 @@ module.exports = Object.assign({}, cfg, { tsConfig: "./tsconfig.json", }, }, - cacheDirectory: '../../node_modules/.cache', }) diff --git a/e2e/__cases__/ts-jest-checks/index.spec.ts b/e2e/__cases__/ts-jest-checks/index.spec.ts new file mode 100644 index 0000000000..2ea1f32ce1 --- /dev/null +++ b/e2e/__cases__/ts-jest-checks/index.spec.ts @@ -0,0 +1,12 @@ +import { createTransformer } from 'ts-jest' +import { readFileSync } from 'fs' + +describe('tsConfig', () => { + it('should have digest and versions', () => { + const tr = createTransformer() + const cs = tr.configsFor({} as any) + expect(cs.tsJestDigest).toHaveLength(40) + expect(cs.tsJestDigest).toBe(readFileSync(require.resolve('ts-jest/.ts-jest-digest'), 'utf8')) + expect(cs.versions['ts-jest']).toBe(require('ts-jest/package.json').version) + }) +}) diff --git a/e2e/__helpers__/test-case/run-result.ts b/e2e/__helpers__/test-case/run-result.ts index f37ec02a08..ca80a640e5 100644 --- a/e2e/__helpers__/test-case/run-result.ts +++ b/e2e/__helpers__/test-case/run-result.ts @@ -4,6 +4,8 @@ import { readFileSync, realpathSync } from 'fs' import { tmpdir } from 'os' import { resolve, sep } from 'path' +import { cacheDir } from '../../../scripts/lib/paths' + import ProcessedFileIo from './processed-file-io' import { escapeRegex, normalizeJestOutput, stripAnsiColors } from './utils' @@ -17,6 +19,7 @@ export default class RunResult { cmd: string args: string[] env: { [key: string]: string } + config: jest.InitialOptions }>, ) {} get logFilePath() { @@ -56,9 +59,11 @@ export default class RunResult { return normalizeJestOutput(this.stdout) } get cmdLine() { - return [this.context.cmd, ...this.context.args] - .filter(a => !['-u', '--updateSnapshot', '--runInBand', '--'].includes(a)) - .join(' ') + return this.normalize( + [this.context.cmd, ...this.context.args] + .filter(a => !['-u', '--updateSnapshot', '--runInBand', '--'].includes(a)) + .join(' '), + ) } ioFor(relFilePath: string): ProcessedFileIo { @@ -80,7 +85,12 @@ export default class RunResult { const realCwd = realpathSync(cwd) const tmp = tmpdir() const realTmp = realpathSync(tmp) - const map = [{ from: cwd, to: '' }, { from: tmp, to: '' }, { from: /\b[a-f0-9]{40}\b/g, to: '' }] + const map = [ + { from: cwd, to: '' }, + { from: tmp, to: '' }, + { from: /\b[a-f0-9]{40}\b/g, to: '' }, + { from: cacheDir, to: '' }, + ] if (cwd !== realCwd) map.push({ from: realCwd, to: '' }) if (tmp !== realTmp) map.push({ from: realTmp, to: '' }) if (sep === '\\') { diff --git a/e2e/__helpers__/test-case/runtime.ts b/e2e/__helpers__/test-case/runtime.ts index 7f35e6d575..c4eb2b5684 100644 --- a/e2e/__helpers__/test-case/runtime.ts +++ b/e2e/__helpers__/test-case/runtime.ts @@ -49,26 +49,40 @@ function hooksSourceWith(vars: Record): string { } export function run(name: string, options: RunTestOptions = {}): RunResult { - const { args = [], env = {}, template, inject, writeIo, noCache } = options + const { + args = [], + env = {}, + template, + inject, + writeIo, + noCache, + jestConfigPath: configFile = 'jest.config.js', + } = options const { workdir: dir, sourceDir, hooksFile, ioDir } = prepareTest( name, template || templateNameForPath(join(Paths.e2eSourceDir, name)), options, ) - const pkg = require(join(dir, 'package.json')) + const pkg = readJsonSync(join(dir, 'package.json')) + + // grab base configuration + const jestConfigPath = resolve(dir, configFile) + let baseConfig: jest.InitialOptions = require(jestConfigPath) + if (configFile === 'package.json') baseConfig = (baseConfig as any).jest + + const extraConfig = {} as jest.InitialOptions let shortCmd: string let cmdArgs: string[] = [] if (inject) { - cmdArgs.push('--testPathPattern="/__eval\\\\.ts$"') - } // '--testRegex=""' + extraConfig.testMatch = undefined + extraConfig.testRegex = '/__eval\\.ts$' + } if (process.argv.find(v => ['--updateSnapshot', '-u'].includes(v))) { cmdArgs.push('-u') } cmdArgs.push(...args) - let isScriptWithConfig = false if (!inject && pkg.scripts && pkg.scripts.test) { - isScriptWithConfig = /['" ]\-\-config['" ]/.test(pkg.scripts.test) if (cmdArgs.length) { cmdArgs.unshift('--') } @@ -80,49 +94,41 @@ export function run(name: string, options: RunTestOptions = {}): RunResult { } // check/merge config - if (isScriptWithConfig) { - throw new Error(`Cannot extend config of a test case using a package script which has '--config' in command line.`) - } - let originalConfig: any = join(dir, 'jest.config.js') if (cmdArgs.includes('--config')) { - const confArg = cmdArgs[cmdArgs.indexOf('--config') + 1] - if (confArg.startsWith('{')) { - originalConfig = JSON.parse(confArg) - } else { - originalConfig = require(resolve(dir, confArg)) - } - } else if (existsSync(originalConfig)) { - originalConfig = require(originalConfig) - } else { - originalConfig = require(join(dir, 'package.json')).jest || {} + throw new Error(`Extend config using tsJestConfig and jestConfig options, not thru args.`) + } + if (cmdArgs.includes('--no-cache')) { + throw new Error(`Use the noCache option to disable cache, not thru args.`) } - let finalConfig = originalConfig as jest.InitialOptions // extends config - if (options.jestConfig || options.tsJestConfig) { - finalConfig = merge({}, originalConfig, options.jestConfig, { - globals: { 'ts-jest': options.tsJestConfig || {} }, - }) - cmdArgs.push( - '--config', - JSON.stringify( - merge({}, originalConfig, options.jestConfig, { - globals: { 'ts-jest': options.tsJestConfig || {} }, - }), - ), - ) + if (options.jestConfig) { + merge(extraConfig, options.jestConfig) + } + if (options.tsJestConfig) { + const globalConfig: any = extraConfig.globals || (extraConfig.globals = {}) + const tsJestConfig = globalConfig['ts-jest'] || (globalConfig['ts-jest'] = {}) + merge(tsJestConfig, options.tsJestConfig) } - // verify that we have the cache directory set - let hasCaching = !(cmdArgs.includes('--no-cache') || finalConfig.cache === false) - if (hasCaching && (noCache || writeIo)) { + if (noCache || writeIo) { cmdArgs.push('--no-cache') - hasCaching = false + } else if (!(baseConfig.cacheDirectory || extraConfig.cacheDirectory)) { + // force the cache directory if not set + extraConfig.cacheDirectory = join(Paths.cacheDir, `e2e-${template}`) } - if (hasCaching && !finalConfig.cacheDirectory) { - throw new Error(`The cacheDirectory is not set in the config`) + + // write final config + const finalConfig = merge({}, baseConfig, extraConfig) + if (Object.keys(extraConfig).length !== 0) { + if (configFile === 'package.json') { + pkg.jest = finalConfig + outputJsonSync(jestConfigPath, pkg) + } else { + outputFileSync(jestConfigPath, `module.exports = ${JSON.stringify(finalConfig, null, 2)}`, 'utf8') + } } - // run in band + // ensure we run in band if (!cmdArgs.includes('--runInBand')) { cmdArgs.push('--runInBand') } @@ -169,6 +175,7 @@ export function run(name: string, options: RunTestOptions = {}): RunResult { args: cmdArgs, env: mergedEnv, ioDir: writeIo ? ioDir : undefined, + config: finalConfig, }) } diff --git a/e2e/__helpers__/test-case/types.ts b/e2e/__helpers__/test-case/types.ts index 7b9fb038d4..3df848b707 100644 --- a/e2e/__helpers__/test-case/types.ts +++ b/e2e/__helpers__/test-case/types.ts @@ -11,6 +11,7 @@ export interface RunTestOptions { jestConfig?: jest.ProjectConfig | any tsJestConfig?: TsJestConfig | any noCache?: boolean + jestConfigPath?: string } export type RunWithTemplatesIterator = (runtTest: () => RunResult, context: RunWithTemplateIteratorContext) => void diff --git a/e2e/__templates__/default/jest.config.js b/e2e/__templates__/default/jest.config.js index f2dfac2bf3..3aec8d89c5 100644 --- a/e2e/__templates__/default/jest.config.js +++ b/e2e/__templates__/default/jest.config.js @@ -2,5 +2,4 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', globals: { 'ts-jest': { tsConfig: {} } }, - cacheDirectory: './node_modules/.cache', } diff --git a/e2e/__templates__/with-babel-6/jest.config.js b/e2e/__templates__/with-babel-6/jest.config.js index bd787516d8..b35dffccb6 100644 --- a/e2e/__templates__/with-babel-6/jest.config.js +++ b/e2e/__templates__/with-babel-6/jest.config.js @@ -2,5 +2,4 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', globals: { 'ts-jest': { tsConfig: {}, babelConfig: true } }, - cacheDirectory: './node_modules/.cache', } diff --git a/e2e/__templates__/with-babel-7/jest.config.js b/e2e/__templates__/with-babel-7/jest.config.js index bd787516d8..b35dffccb6 100644 --- a/e2e/__templates__/with-babel-7/jest.config.js +++ b/e2e/__templates__/with-babel-7/jest.config.js @@ -2,5 +2,4 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', globals: { 'ts-jest': { tsConfig: {}, babelConfig: true } }, - cacheDirectory: './node_modules/.cache', } diff --git a/e2e/__templates__/with-jest-22/jest.config.js b/e2e/__templates__/with-jest-22/jest.config.js index 85f0636d4f..dced9dcb57 100644 --- a/e2e/__templates__/with-jest-22/jest.config.js +++ b/e2e/__templates__/with-jest-22/jest.config.js @@ -3,5 +3,4 @@ const { jestPreset } = require('ts-jest') module.exports = Object.assign({}, jestPreset, { testEnvironment: 'node', globals: { 'ts-jest': { tsConfig: {} } }, - cacheDirectory: './node_modules/.cache', }) diff --git a/e2e/__templates__/with-typescript-2-7/jest.config.js b/e2e/__templates__/with-typescript-2-7/jest.config.js index 1df109c5e9..5640fd1c53 100644 --- a/e2e/__templates__/with-typescript-2-7/jest.config.js +++ b/e2e/__templates__/with-typescript-2-7/jest.config.js @@ -2,5 +2,4 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', globals: { 'ts-jest': { tsConfig: {}, diagnostics: { ignoreCodes: [5023] } } }, - cacheDirectory: './node_modules/.cache', } diff --git a/e2e/__templates__/with-unsupported-version/jest.config.js b/e2e/__templates__/with-unsupported-version/jest.config.js index df64965f35..386d3cb912 100644 --- a/e2e/__templates__/with-unsupported-version/jest.config.js +++ b/e2e/__templates__/with-unsupported-version/jest.config.js @@ -2,5 +2,4 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', globals: { 'ts-jest': { tsConfig: {}, diagnostics: { ignoreCodes: [5023, 5024] } } }, - cacheDirectory: './node_modules/.cache', } diff --git a/e2e/__tests__/__snapshots__/diagnostics.test.ts.snap b/e2e/__tests__/__snapshots__/diagnostics.test.ts.snap index a83ecd257d..7be8b505c4 100644 --- a/e2e/__tests__/__snapshots__/diagnostics.test.ts.snap +++ b/e2e/__tests__/__snapshots__/diagnostics.test.ts.snap @@ -116,7 +116,7 @@ exports[`With diagnostics, first throws should fail using template "with-typescr `; exports[`With diagnostics, warn only should pass using template "default" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"warnOnly":true}}},"cacheDirectory":"./node_modules/.cache"} --no-cache + √ jest --no-cache ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -138,7 +138,7 @@ exports[`With diagnostics, warn only should pass using template "default" 1`] = `; exports[`With diagnostics, warn only should pass using template "with-babel-6" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"diagnostics":{"warnOnly":true}}},"cacheDirectory":"./node_modules/.cache"} --no-cache + √ jest --no-cache ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -160,7 +160,7 @@ exports[`With diagnostics, warn only should pass using template "with-babel-6" 1 `; exports[`With diagnostics, warn only should pass using template "with-babel-7" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"diagnostics":{"warnOnly":true}}},"cacheDirectory":"./node_modules/.cache"} --no-cache + √ jest --no-cache ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -182,7 +182,7 @@ exports[`With diagnostics, warn only should pass using template "with-babel-7" 1 `; exports[`With diagnostics, warn only should pass using template "with-jest-22" 1`] = ` - √ jest --config {"transform":{"^.+\\\\.tsx?$":"ts-jest"},"testMatch":["**/__tests__/**/*.js?(x)","**/?(*.)+(spec|test).js?(x)","**/__tests__/**/*.ts?(x)","**/?(*.)+(spec|test).ts?(x)"],"moduleFileExtensions":["js","json","jsx","node","ts","tsx"],"testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"warnOnly":true}}},"cacheDirectory":"./node_modules/.cache"} --no-cache + √ jest --no-cache ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -204,7 +204,7 @@ exports[`With diagnostics, warn only should pass using template "with-jest-22" 1 `; exports[`With diagnostics, warn only should pass using template "with-typescript-2-7" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023],"warnOnly":true}}},"cacheDirectory":"./node_modules/.cache"} --no-cache + √ jest --no-cache ↳ exit code: 0 ===[ STDOUT ]=================================================================== diff --git a/e2e/__tests__/__snapshots__/isolated-modules.test.ts.snap b/e2e/__tests__/__snapshots__/isolated-modules.test.ts.snap index 95d97a990e..f744686504 100644 --- a/e2e/__tests__/__snapshots__/isolated-modules.test.ts.snap +++ b/e2e/__tests__/__snapshots__/isolated-modules.test.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`With isolatedModules enabled should pass using template "default" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"isolatedModules":true}},"cacheDirectory":"./node_modules/.cache"} + √ jest ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -18,7 +18,7 @@ exports[`With isolatedModules enabled should pass using template "default" 1`] = `; exports[`With isolatedModules enabled should pass using template "with-babel-6" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"isolatedModules":true}},"cacheDirectory":"./node_modules/.cache"} + √ jest ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -35,7 +35,7 @@ exports[`With isolatedModules enabled should pass using template "with-babel-6" `; exports[`With isolatedModules enabled should pass using template "with-babel-7" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"isolatedModules":true}},"cacheDirectory":"./node_modules/.cache"} + √ jest ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -52,7 +52,7 @@ exports[`With isolatedModules enabled should pass using template "with-babel-7" `; exports[`With isolatedModules enabled should pass using template "with-jest-22" 1`] = ` - √ jest --config {"transform":{"^.+\\\\.tsx?$":"ts-jest"},"testMatch":["**/__tests__/**/*.js?(x)","**/?(*.)+(spec|test).js?(x)","**/__tests__/**/*.ts?(x)","**/?(*.)+(spec|test).ts?(x)"],"moduleFileExtensions":["js","json","jsx","node","ts","tsx"],"testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"isolatedModules":true}},"cacheDirectory":"./node_modules/.cache"} + √ jest ↳ exit code: 0 ===[ STDOUT ]=================================================================== @@ -69,7 +69,7 @@ exports[`With isolatedModules enabled should pass using template "with-jest-22" `; exports[`With isolatedModules enabled should pass using template "with-typescript-2-7" 1`] = ` - √ jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023]},"isolatedModules":true}},"cacheDirectory":"./node_modules/.cache"} + √ jest ↳ exit code: 0 ===[ STDOUT ]=================================================================== diff --git a/e2e/__tests__/__snapshots__/simple.test.ts.snap b/e2e/__tests__/__snapshots__/simple.test.ts.snap deleted file mode 100644 index 94d0438d92..0000000000 --- a/e2e/__tests__/__snapshots__/simple.test.ts.snap +++ /dev/null @@ -1,91 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Simple test should pass using template "default" 1`] = ` - √ jest - ↳ exit code: 0 - ===[ STDOUT ]=================================================================== - - ===[ STDERR ]=================================================================== - PASS ./Hello.spec.ts - Hello Class - √ should create a new Hello - - Test Suites: 1 passed, 1 total - Tests: 1 passed, 1 total - Snapshots: 0 total - Time: XXs - Ran all test suites. - ================================================================================ -`; - -exports[`Simple test should pass using template "with-babel-6" 1`] = ` - √ jest - ↳ exit code: 0 - ===[ STDOUT ]=================================================================== - - ===[ STDERR ]=================================================================== - PASS ./Hello.spec.ts - Hello Class - √ should create a new Hello - - Test Suites: 1 passed, 1 total - Tests: 1 passed, 1 total - Snapshots: 0 total - Time: XXs - Ran all test suites. - ================================================================================ -`; - -exports[`Simple test should pass using template "with-babel-7" 1`] = ` - √ jest - ↳ exit code: 0 - ===[ STDOUT ]=================================================================== - - ===[ STDERR ]=================================================================== - PASS ./Hello.spec.ts - Hello Class - √ should create a new Hello - - Test Suites: 1 passed, 1 total - Tests: 1 passed, 1 total - Snapshots: 0 total - Time: XXs - Ran all test suites. - ================================================================================ -`; - -exports[`Simple test should pass using template "with-jest-22" 1`] = ` - √ jest - ↳ exit code: 0 - ===[ STDOUT ]=================================================================== - - ===[ STDERR ]=================================================================== - PASS ./Hello.spec.ts - Hello Class - √ should create a new Hello - - Test Suites: 1 passed, 1 total - Tests: 1 passed, 1 total - Snapshots: 0 total - Time: XXs - Ran all test suites. - ================================================================================ -`; - -exports[`Simple test should pass using template "with-typescript-2-7" 1`] = ` - √ jest - ↳ exit code: 0 - ===[ STDOUT ]=================================================================== - - ===[ STDERR ]=================================================================== - PASS ./Hello.spec.ts - Hello Class - √ should create a new Hello - - Test Suites: 1 passed, 1 total - Tests: 1 passed, 1 total - Snapshots: 0 total - Time: XXs - Ran all test suites. - ================================================================================ -`; diff --git a/e2e/__tests__/__snapshots__/source-map.test.ts.snap b/e2e/__tests__/__snapshots__/source-map.test.ts.snap index 1bfdb75d9b..4f10c0e99d 100644 --- a/e2e/__tests__/__snapshots__/source-map.test.ts.snap +++ b/e2e/__tests__/__snapshots__/source-map.test.ts.snap @@ -34,7 +34,7 @@ exports[`using template "default" should have the source maps comment 1`] = ` `; exports[`using template "default" should report correct line numbers 1`] = ` - × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023,7027]}}},"cacheDirectory":"./node_modules/.cache"} --no-cache + × jest --no-cache ↳ exit code: 1 ===[ STDOUT ]=================================================================== console.log main.ts:2 @@ -121,7 +121,7 @@ exports[`using template "with-babel-6" should have the source maps comment 1`] = `; exports[`using template "with-babel-6" should report correct line numbers 1`] = ` - × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"diagnostics":{"ignoreCodes":[5023,7027]}}},"cacheDirectory":"./node_modules/.cache"} --no-cache + × jest --no-cache ↳ exit code: 1 ===[ STDOUT ]=================================================================== console.log main.ts:2 @@ -214,7 +214,7 @@ exports[`using template "with-babel-7" should have the source maps comment 1`] = `; exports[`using template "with-babel-7" should report correct line numbers 1`] = ` - × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"babelConfig":true,"diagnostics":{"ignoreCodes":[5023,7027]}}},"cacheDirectory":"./node_modules/.cache"} --no-cache + × jest --no-cache ↳ exit code: 1 ===[ STDOUT ]=================================================================== console.log main.ts:2 @@ -301,7 +301,7 @@ exports[`using template "with-jest-22" should have the source maps comment 1`] = `; exports[`using template "with-jest-22" should report correct line numbers 1`] = ` - × jest --config {"transform":{"^.+\\\\.tsx?$":"ts-jest"},"testMatch":["**/__tests__/**/*.js?(x)","**/?(*.)+(spec|test).js?(x)","**/__tests__/**/*.ts?(x)","**/?(*.)+(spec|test).ts?(x)"],"moduleFileExtensions":["js","json","jsx","node","ts","tsx"],"testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023,7027]}}},"cacheDirectory":"./node_modules/.cache"} --no-cache + × jest --no-cache ↳ exit code: 1 ===[ STDOUT ]=================================================================== console.log main.ts:2 @@ -386,7 +386,7 @@ exports[`using template "with-typescript-2-7" should have the source maps commen `; exports[`using template "with-typescript-2-7" should report correct line numbers 1`] = ` - × jest --config {"preset":"ts-jest","testEnvironment":"node","globals":{"ts-jest":{"tsConfig":{},"diagnostics":{"ignoreCodes":[5023,7027]}}},"cacheDirectory":"./node_modules/.cache"} --no-cache + × jest --no-cache ↳ exit code: 1 ===[ STDOUT ]=================================================================== console.log main.ts:2 diff --git a/e2e/__tests__/simple.test.ts b/e2e/__tests__/ts-jest-checks.test.ts similarity index 72% rename from e2e/__tests__/simple.test.ts rename to e2e/__tests__/ts-jest-checks.test.ts index c416c4cdb7..99a0554378 100644 --- a/e2e/__tests__/simple.test.ts +++ b/e2e/__tests__/ts-jest-checks.test.ts @@ -1,14 +1,13 @@ import { allValidPackageSets } from '../__helpers__/templates' import { configureTestCase } from '../__helpers__/test-case' -describe('Simple test', () => { - const testCase = configureTestCase('simple') +describe('ts-jest internal checks test', () => { + const testCase = configureTestCase('ts-jest-checks') testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => { it(testLabel, () => { const result = runTest() expect(result.status).toBe(0) - expect(result).toMatchSnapshot() }) }) }) diff --git a/e2e/jest.config.js b/e2e/jest.config.js index e70656fa06..2ce70c5dc7 100644 --- a/e2e/jest.config.js +++ b/e2e/jest.config.js @@ -11,5 +11,5 @@ module.exports = { '/e2e/__serializers__/processed-source.ts', ], verbose: true, - cacheDirectory: '/node_modules/.cache/e2e', + cacheDirectory: '/.cache/e2e', } diff --git a/jest.config.js b/jest.config.js index 50463093b3..a056994a39 100644 --- a/jest.config.js +++ b/jest.config.js @@ -15,5 +15,5 @@ module.exports = { moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'], testEnvironment: 'node', snapshotSerializers: ['/src/__serializers__/processed-source.ts'], - cacheDirectory: '/node_modules/.cache/unit', + cacheDirectory: '/.cache/unit', } diff --git a/scripts/lib/paths.d.ts b/scripts/lib/paths.d.ts index 4c6b0e3768..15e6af7057 100644 --- a/scripts/lib/paths.d.ts +++ b/scripts/lib/paths.d.ts @@ -1,4 +1,5 @@ declare const rootDir: string +declare const cacheDir: string declare const pkgDigestFile: string declare const e2eSourceDir: string declare const e2eRootDir: string @@ -12,6 +13,7 @@ declare const e2eTestsDir: string export { rootDir, + cacheDir, pkgDigestFile, e2eSourceDir, e2eRootDir, diff --git a/scripts/lib/paths.js b/scripts/lib/paths.js index 26907635b1..1b7db61525 100644 --- a/scripts/lib/paths.js +++ b/scripts/lib/paths.js @@ -2,6 +2,7 @@ const path = require('path') const os = require('os') const rootDir = path.resolve(__dirname, '..', '..') +const cacheDir = path.join(rootDir, '.cache') const pkgDigestFile = path.join(rootDir, '.ts-jest-digest') const distDir = path.join(rootDir, 'dist') const testsRootDir = path.join(rootDir, 'tests') @@ -17,6 +18,7 @@ const e2eWotkDirLink = path.join(e2eRootDir, '__workdir_synlink__') module.exports = { pkgDigestFile, + cacheDir, rootDir, e2eSourceDir, e2eRootDir,