From 74b92d3ad5d6bd1dcd01a49e7dec2c22517bbcb2 Mon Sep 17 00:00:00 2001 From: Ahn Date: Sat, 9 May 2020 08:07:17 +0200 Subject: [PATCH] fix(compiler): don't resolve files from build folder for `projectReferences` (#1614) --- .../simple-project-references/jest.config.js | 4 + .../simple-project-references/package.json | 3 +- .../yarn-workspace-composite/package.json | 2 +- src/compiler/compiler-utils.ts | 154 +----------------- src/compiler/language-service.spec.ts | 51 ------ src/compiler/language-service.ts | 118 ++++++-------- src/compiler/transpiler.spec.ts | 64 -------- src/compiler/transpiler.ts | 41 ++--- .../__snapshots__/config-set.spec.ts.snap | 2 + src/config/config-set.spec.ts | 4 +- 10 files changed, 74 insertions(+), 369 deletions(-) diff --git a/e2e/__external-repos__/simple-project-references/jest.config.js b/e2e/__external-repos__/simple-project-references/jest.config.js index da9cbec4c0..1942d9a712 100644 --- a/e2e/__external-repos__/simple-project-references/jest.config.js +++ b/e2e/__external-repos__/simple-project-references/jest.config.js @@ -1,3 +1,6 @@ +/** @type {import('@jest/types').Config.InitialOptions} */ +/** @typedef {import('ts-jest')} */ + module.exports = { preset: 'ts-jest', testEnvironment: 'node', @@ -7,6 +10,7 @@ module.exports = { globals: { 'ts-jest': { isolatedModules: true, + tsConfig: 'tsconfig-tests.json' }, }, } diff --git a/e2e/__external-repos__/simple-project-references/package.json b/e2e/__external-repos__/simple-project-references/package.json index 8b2ff833ec..69bb9f193c 100644 --- a/e2e/__external-repos__/simple-project-references/package.json +++ b/e2e/__external-repos__/simple-project-references/package.json @@ -1,8 +1,7 @@ { "private": true, "scripts": { - "build": "yarn tsc -b -f tsconfig.json", - "test": "yarn build && jest" + "test": "jest" }, "devDependencies": { "@types/jest": "^25.2.1", diff --git a/e2e/__external-repos__/yarn-workspace-composite/package.json b/e2e/__external-repos__/yarn-workspace-composite/package.json index e2d1bd9855..bc54165aae 100644 --- a/e2e/__external-repos__/yarn-workspace-composite/package.json +++ b/e2e/__external-repos__/yarn-workspace-composite/package.json @@ -6,7 +6,7 @@ "packages/*" ], "scripts": { - "test": "yarn tsc -b packages/my-app/tsconfig.json && jest --no-cache" + "test": "jest --no-cache" }, "devDependencies": { "@types/jest": "^25.2.1", diff --git a/src/compiler/compiler-utils.ts b/src/compiler/compiler-utils.ts index 35ddc089e9..33f2205e23 100644 --- a/src/compiler/compiler-utils.ts +++ b/src/compiler/compiler-utils.ts @@ -1,12 +1,10 @@ import { Logger } from 'bs-logger' import { writeFileSync } from 'fs' import micromatch = require('micromatch') -import { dirname, join, normalize, relative, resolve } from 'path' +import { join, normalize } from 'path' import * as _ts from 'typescript' -import { ConfigSet } from '../config/config-set' -import { EXTENSION_REGEX, JSON_REGEX, TS_TSX_REGEX } from '../constants' -import { MemoryCache, SourceOutput, TSFiles } from '../types' +import { MemoryCache } from '../types' import { sha1 } from '../util/sha1' /** @@ -60,151 +58,3 @@ export function isTestFile(testMatchPatterns: (string | RegExp)[], fileName: str typeof pattern === 'string' ? micromatch.isMatch(fileName, pattern) : pattern.test(fileName), ) } - -/* istanbul ignore next (we leave this for e2e) */ -function isUsingProjectReferences( - program: _ts.Program, - projectReferences: readonly _ts.ProjectReference[] | undefined, -) { - if (projectReferences && !!program.getProjectReferences) { - return Boolean(program && program.getProjectReferences()) - } - - return false -} - -/* istanbul ignore next (we leave this for e2e) */ -function getResolvedProjectReferences( - program: _ts.Program, -): readonly (_ts.ResolvedProjectReference | undefined)[] | undefined { - const getProjectReferences = program.getResolvedProjectReferences ?? program.getProjectReferences - if (getProjectReferences) { - return getProjectReferences() - } - - return -} - -/* istanbul ignore next (we leave this for e2e) */ -function getProjectReferenceForFile( - filePath: string, - program: _ts.Program, - projectReferences: readonly _ts.ProjectReference[] | undefined, -) { - if (isUsingProjectReferences(program, projectReferences)) { - return ( - program && - getResolvedProjectReferences(program)!.find( - ref => (ref && ref.commandLine.fileNames.some(file => normalize(file) === filePath)) || false, - ) - ) - } - - return -} - -/** - * @internal - */ -/* istanbul ignore next (we leave this for e2e) */ -export function getAndCacheProjectReference( - filePath: string, - program: _ts.Program, - files: TSFiles, - projectReferences: readonly _ts.ProjectReference[] | undefined, -) { - const file = files.get(filePath) - if (file?.projectReference) { - return file.projectReference.project - } - - const projectReference = getProjectReferenceForFile(filePath, program, projectReferences) - if (file !== undefined) { - file.projectReference = { project: projectReference } - } - - return projectReference -} - -// Adapted from https://github.com/Microsoft/TypeScript/blob/45101491c0b077c509b25830ef0ee5f85b293754/src/compiler/tsbuild.ts#L305 -/* istanbul ignore next (we leave this for e2e) */ -function getOutputJavaScriptFileName(inputFileName: string, projectReference: _ts.ResolvedProjectReference) { - const { options } = projectReference.commandLine - const projectDirectory = options.rootDir || dirname(projectReference.sourceFile.fileName) - const relativePath = relative(projectDirectory, inputFileName) - const outputPath = resolve(options.outDir || projectDirectory, relativePath) - const newExtension = JSON_REGEX.test(inputFileName) - ? '.json' - : TS_TSX_REGEX.test(inputFileName) && options.jsx === _ts.JsxEmit.Preserve - ? '.jsx' - : '.js' - - return outputPath.replace(EXTENSION_REGEX, newExtension) -} - -/** - * Gets the output JS file path for an input file governed by a composite project. - * Pulls from the cache if it exists; computes and caches the result otherwise. - */ -/* istanbul ignore next (we leave this for e2e) */ -function getAndCacheOutputJSFileName( - inputFileName: string, - projectReference: _ts.ResolvedProjectReference, - files: TSFiles, -) { - const file = files.get(inputFileName) - if (file?.projectReference?.outputFileName) { - return file.projectReference.outputFileName - } - - const outputFileName = getOutputJavaScriptFileName(inputFileName, projectReference) - if (file !== undefined) { - file.projectReference = file.projectReference ?? { - project: projectReference, - } - file.projectReference.outputFileName = outputFileName - } - - return outputFileName -} - -/** - * @internal - */ -/* istanbul ignore next (we leave this for e2e) */ -export function getCompileResultFromReferencedProject( - fileName: string, - configs: ConfigSet, - files: TSFiles, - referencedProject: _ts.ResolvedProjectReference, -): SourceOutput { - const [relativeProjectConfigPath, relativeFilePath] = [ - configs.resolvePath(referencedProject.sourceFile.fileName), - configs.resolvePath(fileName), - ] - if (referencedProject.commandLine.options.outFile !== undefined) { - throw new Error( - `The referenced project at ${relativeProjectConfigPath} is using ` + - "the outFile' option, which is not supported with ts-jest.", - ) - } - - const jsFileName = getAndCacheOutputJSFileName(fileName, referencedProject, files) - const relativeJSFileName = configs.resolvePath(jsFileName) - if (!configs.compilerModule.sys.fileExists(jsFileName)) { - throw new Error( - 'Could not find output JavaScript file for input ' + - `${relativeFilePath} (looked at ${relativeJSFileName}).\n` + - 'The input file is part of a project reference located at ' + - `${relativeProjectConfigPath}, so ts-jest is looking for the ` + - 'project’s pre-built output on disk. Try running `tsc --build` ' + - 'to build project references.', - ) - } - - const mapFileName = `${jsFileName}.map` - const outputText = configs.compilerModule.sys.readFile(jsFileName) - const sourceMapText = configs.compilerModule.sys.readFile(mapFileName) - - return [outputText!, sourceMapText!] -} diff --git a/src/compiler/language-service.spec.ts b/src/compiler/language-service.spec.ts index eb79eefdcd..989815a357 100644 --- a/src/compiler/language-service.spec.ts +++ b/src/compiler/language-service.spec.ts @@ -17,57 +17,6 @@ describe('Language service', () => { logTarget.clear() }) - it('should get compile result from referenced project when there is a built reference project', () => { - const tmp = tempDir('compiler') - const compiler = makeCompiler({ - jestConfig: { cache: true, cacheDirectory: tmp }, - tsJestConfig: { tsConfig: false }, - }) - const source = 'console.log("hello")' - const fileName = 'test-reference-project.ts' - const getAndCacheProjectReferenceSpy = jest - .spyOn(compilerUtils, 'getAndCacheProjectReference') - .mockReturnValueOnce({} as any) - jest - .spyOn(compilerUtils, 'getCompileResultFromReferencedProject') - .mockImplementationOnce(() => [ - source, - '{"version":3,"file":"test-reference-project.js","sourceRoot":"","sources":["test-reference-project.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA","sourcesContent":["console.log(\\"hello\\")"]}', - ]) - writeFileSync(fileName, source, 'utf8') - - compiler.compile(source, fileName) - - expect(getAndCacheProjectReferenceSpy).toHaveBeenCalled() - expect(compilerUtils.getCompileResultFromReferencedProject).toHaveBeenCalled() - - jest.restoreAllMocks() - removeSync(fileName) - }) - - it('should get compile result from language service when there is no referenced project', () => { - const tmp = tempDir('compiler') - const compiler = makeCompiler({ - jestConfig: { cache: true, cacheDirectory: tmp }, - tsJestConfig: { tsConfig: false }, - }) - const source = 'console.log("hello")' - const fileName = 'test-no-reference-project.ts' - const getAndCacheProjectReferenceSpy = jest - .spyOn(compilerUtils, 'getAndCacheProjectReference') - .mockReturnValueOnce(undefined) - jest.spyOn(compilerUtils, 'getCompileResultFromReferencedProject') - writeFileSync(fileName, source, 'utf8') - - compiler.compile(source, fileName) - - expect(getAndCacheProjectReferenceSpy).toHaveBeenCalled() - expect(compilerUtils.getCompileResultFromReferencedProject).not.toHaveBeenCalled() - - jest.restoreAllMocks() - removeSync(fileName) - }) - it('should cache resolved modules for test file with testMatchPatterns from jest config when match', () => { const spy = jest.spyOn(compilerUtils, 'cacheResolvedModules').mockImplementationOnce(() => {}) const tmp = tempDir('compiler') diff --git a/src/compiler/language-service.ts b/src/compiler/language-service.ts index 2555d05ce4..6c179febc7 100644 --- a/src/compiler/language-service.ts +++ b/src/compiler/language-service.ts @@ -1,5 +1,4 @@ -import { LogContexts, LogLevels, Logger } from 'bs-logger' -import memoize = require('lodash.memoize') +import { LogContexts, Logger, LogLevels } from 'bs-logger' import { basename, normalize, relative } from 'path' import * as _ts from 'typescript' @@ -8,12 +7,8 @@ import { LINE_FEED } from '../constants' import { CompilerInstance, MemoryCache, SourceOutput } from '../types' import { Errors, interpolate } from '../util/messages' -import { - cacheResolvedModules, - getAndCacheProjectReference, - getCompileResultFromReferencedProject, - isTestFile, -} from './compiler-utils' +import { cacheResolvedModules, isTestFile } from './compiler-utils' +import memoize = require('lodash.memoize') function doTypeChecking(configs: ConfigSet, fileName: string, service: _ts.LanguageService, logger: Logger) { if (configs.shouldReportDiagnostic(fileName)) { @@ -37,7 +32,7 @@ export const initializeLanguageServiceInstance = ( const ts = configs.compilerModule const cwd = configs.cwd const cacheDir = configs.tsCacheDir - const { options, projectReferences, fileNames } = configs.parsedTsConfig + const { options, fileNames } = configs.parsedTsConfig const serviceHostTraceCtx = { namespace: 'ts:serviceHost', call: null, @@ -84,7 +79,6 @@ export const initializeLanguageServiceInstance = ( } const serviceHost: _ts.LanguageServiceHost = { getProjectVersion: () => String(projectVersion), - getProjectReferences: () => projectReferences, getScriptFileNames: () => [...memoryCache.files.keys()], getScriptVersion: (fileName: string) => { const normalizedFileName = normalize(fileName) @@ -139,67 +133,55 @@ export const initializeLanguageServiceInstance = ( // Must set memory cache before attempting to read file. updateMemoryCache(code, fileName) - const referencedProject = getAndCacheProjectReference( - fileName, - service.getProgram()!, - memoryCache.files, - projectReferences, - ) - if (referencedProject !== undefined) { - logger.debug({ fileName }, 'compileFn(): get compile result from referenced project') - - return getCompileResultFromReferencedProject(fileName, configs, memoryCache.files, referencedProject) - } else { - const output: _ts.EmitOutput = service.getEmitOutput(fileName) - // Do type checking by getting TypeScript diagnostics - logger.debug({ fileName }, 'compileFn(): computing diagnostics using language service') - - doTypeChecking(configs, fileName, service, logger) - /** - * We don't need the following logic with no cache run because no cache always gives correct typing - */ - if (cacheDir) { - if (isTestFile(configs.testMatchPatterns, fileName)) { - cacheResolvedModules(fileName, code, memoryCache, service.getProgram()!, cacheDir, logger) - } else { - Object.entries(memoryCache.resolvedModules) - .filter( - entry => - /** - * When imported modules change, we only need to check whether the test file is compiled previously or not - * base on memory cache. By checking memory cache, we can avoid repeatedly doing type checking against - * test file for 1st time run after clearing cache because - */ - entry[1].modulePaths.find(modulePath => modulePath === fileName) && !memoryCache.files.has(entry[0]), + const output: _ts.EmitOutput = service.getEmitOutput(fileName) + // Do type checking by getting TypeScript diagnostics + logger.debug({ fileName }, 'compileFn(): computing diagnostics using language service') + + doTypeChecking(configs, fileName, service, logger) + /** + * We don't need the following logic with no cache run because no cache always gives correct typing + */ + if (cacheDir) { + if (isTestFile(configs.testMatchPatterns, fileName)) { + cacheResolvedModules(fileName, code, memoryCache, service.getProgram()!, cacheDir, logger) + } else { + Object.entries(memoryCache.resolvedModules) + .filter( + entry => + /** + * When imported modules change, we only need to check whether the test file is compiled previously or not + * base on memory cache. By checking memory cache, we can avoid repeatedly doing type checking against + * test file for 1st time run after clearing cache because + */ + entry[1].modulePaths.find(modulePath => modulePath === fileName) && !memoryCache.files.has(entry[0]), + ) + .forEach(entry => { + const testFileName = entry[0] + const testFileContent = entry[1].testFileContent + logger.debug( + { fileName }, + 'compileFn(): computing diagnostics for test file that imports this module using language service', ) - .forEach(entry => { - const testFileName = entry[0] - const testFileContent = entry[1].testFileContent - logger.debug( - { fileName }, - 'compileFn(): computing diagnostics for test file that imports this module using language service', - ) - - updateMemoryCache(testFileContent, testFileName) - doTypeChecking(configs, testFileName, service, logger) - }) - } - } - /* istanbul ignore next (this should never happen but is kept for security) */ - if (output.emitSkipped) { - throw new TypeError(`${relative(cwd, fileName)}: Emit skipped for language service`) - } - // Throw an error when requiring `.d.ts` files. - if (!output.outputFiles.length) { - throw new TypeError( - interpolate(Errors.UnableToRequireDefinitionFile, { - file: basename(fileName), - }), - ) - } - return [output.outputFiles[1].text, output.outputFiles[0].text] + updateMemoryCache(testFileContent, testFileName) + doTypeChecking(configs, testFileName, service, logger) + }) + } } + /* istanbul ignore next (this should never happen but is kept for security) */ + if (output.emitSkipped) { + throw new TypeError(`${relative(cwd, fileName)}: Emit skipped for language service`) + } + // Throw an error when requiring `.d.ts` files. + if (!output.outputFiles.length) { + throw new TypeError( + interpolate(Errors.UnableToRequireDefinitionFile, { + file: basename(fileName), + }), + ) + } + + return [output.outputFiles[1].text, output.outputFiles[0].text] }, program: service.getProgram(), } diff --git a/src/compiler/transpiler.spec.ts b/src/compiler/transpiler.spec.ts index 86b99a5f2c..8c4bf1edce 100644 --- a/src/compiler/transpiler.spec.ts +++ b/src/compiler/transpiler.spec.ts @@ -1,78 +1,14 @@ import { removeSync, writeFileSync } from 'fs-extra' -import * as _ts from 'typescript' import { makeCompiler } from '../__helpers__/fakers' import ProcessedSource from '../__helpers__/processed-source' import { TS_JEST_OUT_DIR } from '../config/config-set' -import * as compilerUtils from './compiler-utils' - describe('Transpiler', () => { const baseTsJestConfig = { isolatedModules: true, } - it( - 'should call createProgram() with projectReferences, call getAndCacheProjectReference()' + - ' and getCompileResultFromReferenceProject() when there are projectReferences from tsconfig', - () => { - const programSpy = jest.spyOn(_ts, 'createProgram') - const source = 'console.log("hello")' - const fileName = 'isolated-test-reference-project.ts' - const getAndCacheProjectReferenceSpy = jest - .spyOn(compilerUtils, 'getAndCacheProjectReference') - .mockReturnValueOnce({} as any) - jest - .spyOn(compilerUtils, 'getCompileResultFromReferencedProject') - .mockImplementationOnce(() => [ - source, - '{"version":3,"file":"isolated-test-reference-project.js","sourceRoot":"","sources":["isolated-test-reference-project.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA","sourcesContent":["console.log(\\"hello\\")"]}', - ]) - writeFileSync(fileName, source) - const compiler = makeCompiler({ - tsJestConfig: { - ...baseTsJestConfig, - tsConfig: 'src/__mocks__/tsconfig-project-references.json', - }, - }) - compiler.compile(source, fileName) - - expect(programSpy).toHaveBeenCalled() - expect((programSpy.mock.calls[0][0] as any).options.configFilePath).toContain('tsconfig-project-references.json') - expect(getAndCacheProjectReferenceSpy).toHaveBeenCalled() - expect(compilerUtils.getCompileResultFromReferencedProject).toHaveBeenCalled() - - jest.restoreAllMocks() - removeSync(fileName) - }, - ) - - it('should call createProgram() without projectReferences when there are no projectReferences from tsconfig', () => { - const programSpy = jest.spyOn(_ts, 'createProgram') - const source = 'console.log("hello")' - const fileName = 'isolated-test-reference-project-1.ts' - const getAndCacheProjectReferenceSpy = jest - .spyOn(compilerUtils, 'getAndCacheProjectReference') - .mockReturnValueOnce(undefined) - jest.spyOn(compilerUtils, 'getCompileResultFromReferencedProject') - writeFileSync(fileName, source, 'utf8') - const compiler = makeCompiler({ - tsJestConfig: { - ...baseTsJestConfig, - tsConfig: false, - }, - }) - compiler.compile(source, fileName) - - expect(programSpy).toHaveBeenCalled() - expect((programSpy.mock.calls[0][1] as any).configFilePath).toBeUndefined() - expect(getAndCacheProjectReferenceSpy).toHaveBeenCalled() - expect(compilerUtils.getCompileResultFromReferencedProject).not.toHaveBeenCalled() - - jest.restoreAllMocks() - removeSync(fileName) - }) - it('should compile js file for allowJs true', () => { const fileName = `${__filename}.test.js` const compiler = makeCompiler({ diff --git a/src/compiler/transpiler.ts b/src/compiler/transpiler.ts index acb88b1765..ea48fe602f 100644 --- a/src/compiler/transpiler.ts +++ b/src/compiler/transpiler.ts @@ -4,8 +4,6 @@ import * as _ts from 'typescript' import { ConfigSet } from '../config/config-set' import { CompilerInstance, MemoryCache, SourceOutput } from '../types' -import { getAndCacheProjectReference, getCompileResultFromReferencedProject } from './compiler-utils' - /** * @internal */ @@ -16,15 +14,9 @@ export const initializeTranspilerInstance = ( ): CompilerInstance => { logger.debug('initializeTranspilerInstance(): create typescript compiler') - const { options, projectReferences, fileNames } = configs.parsedTsConfig + const { options, fileNames } = configs.parsedTsConfig const ts = configs.compilerModule - const program = projectReferences - ? ts.createProgram({ - rootNames: fileNames, - options, - projectReferences, - }) - : ts.createProgram([], options) + const program = ts.createProgram(fileNames, options) /* istanbul ignore next (we leave this for e2e) */ const updateFileInCache = (contents: string, filePath: string) => { const file = memoryCache.files.get(filePath) @@ -37,27 +29,20 @@ export const initializeTranspilerInstance = ( return { compileFn: (code: string, fileName: string): SourceOutput => { updateFileInCache(code, fileName) - const referencedProject = getAndCacheProjectReference(fileName, program, memoryCache.files, projectReferences) - /* istanbul ignore next (referencedProject object is too complex to mock so we leave this for e2e) */ - if (referencedProject !== undefined) { - logger.debug({ fileName }, 'compileFn(): get compile result from referenced project') - - return getCompileResultFromReferencedProject(fileName, configs, memoryCache.files, referencedProject) - } else { - logger.debug({ fileName }, 'compileFn(): compiling as isolated module') - const result: _ts.TranspileOutput = ts.transpileModule(code, { - fileName, - transformers: configs.tsCustomTransformers, - compilerOptions: options, - reportDiagnostics: configs.shouldReportDiagnostic(fileName), - }) - if (result.diagnostics && configs.shouldReportDiagnostic(fileName)) { - configs.raiseDiagnostics(result.diagnostics, fileName, logger) - } + logger.debug({ fileName }, 'compileFn(): compiling as isolated module') - return [result.outputText, result.sourceMapText!] + const result: _ts.TranspileOutput = ts.transpileModule(code, { + fileName, + transformers: configs.tsCustomTransformers, + compilerOptions: options, + reportDiagnostics: configs.shouldReportDiagnostic(fileName), + }) + if (result.diagnostics && configs.shouldReportDiagnostic(fileName)) { + configs.raiseDiagnostics(result.diagnostics, fileName, logger) } + + return [result.outputText, result.sourceMapText!] }, program, } diff --git a/src/config/__snapshots__/config-set.spec.ts.snap b/src/config/__snapshots__/config-set.spec.ts.snap index 55469f1a77..5f409bb2cb 100644 --- a/src/config/__snapshots__/config-set.spec.ts.snap +++ b/src/config/__snapshots__/config-set.spec.ts.snap @@ -1,5 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`cacheKey should be a string 1`] = `"{\\"digest\\":\\"a0d51ca854194df8191d0e65c0ca4730f510f332\\",\\"jest\\":{\\"__backported\\":true,\\"globals\\":{}},\\"projectDepVersions\\":{\\"dev\\":\\"1.2.5\\",\\"opt\\":\\"1.2.3\\",\\"peer\\":\\"1.2.4\\",\\"std\\":\\"1.2.6\\"},\\"transformers\\":[\\"hoisting-jest-mock@1\\"],\\"tsJest\\":{\\"compiler\\":\\"typescript\\",\\"diagnostics\\":{\\"ignoreCodes\\":[6059,18002,18003],\\"pretty\\":true,\\"throws\\":true},\\"isolatedModules\\":false,\\"packageJson\\":{\\"kind\\":\\"file\\"},\\"transformers\\":[]},\\"tsconfig\\":{\\"declaration\\":false,\\"inlineSourceMap\\":false,\\"inlineSources\\":true,\\"module\\":1,\\"noEmit\\":false,\\"removeComments\\":false,\\"sourceMap\\":true,\\"target\\":1}}"`; + exports[`jest should merge parent config if any with globals is an empty object 1`] = ` Object { "__backported": true, diff --git a/src/config/config-set.spec.ts b/src/config/config-set.spec.ts index 583b781358..8d0d724258 100644 --- a/src/config/config-set.spec.ts +++ b/src/config/config-set.spec.ts @@ -962,9 +962,7 @@ describe('cacheKey', () => { delete val.versions cs.jsonValue.value = val // digest is mocked in src/__mocks__/index.ts - expect(cs.cacheKey).toMatchInlineSnapshot( - '"{\\"digest\\":\\"a0d51ca854194df8191d0e65c0ca4730f510f332\\",\\"jest\\":{\\"__backported\\":true,\\"globals\\":{}},\\"projectDepVersions\\":{\\"dev\\":\\"1.2.5\\",\\"opt\\":\\"1.2.3\\",\\"peer\\":\\"1.2.4\\",\\"std\\":\\"1.2.6\\"},\\"transformers\\":[\\"hoisting-jest-mock@1\\"],\\"tsJest\\":{\\"compiler\\":\\"typescript\\",\\"diagnostics\\":{\\"ignoreCodes\\":[6059,18002,18003],\\"pretty\\":true,\\"throws\\":true},\\"isolatedModules\\":false,\\"packageJson\\":{\\"kind\\":\\"file\\"},\\"transformers\\":[]},\\"tsconfig\\":{\\"declaration\\":false,\\"inlineSourceMap\\":false,\\"inlineSources\\":true,\\"module\\":1,\\"noEmit\\":false,\\"removeComments\\":false,\\"sourceMap\\":true,\\"target\\":1}}"', - ) + expect(cs.cacheKey).toMatchSnapshot() }) }) // cacheKey