diff --git a/.yarnrc.yml b/.yarnrc.yml index 2543a3901ad2..e26f7794d41a 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -2,11 +2,6 @@ enableGlobalCache: true nodeLinker: node-modules -packageExtensions: - "@docusaurus/plugin-pwa@*": - peerDependencies: - "@babel/core": "^7.0.0" - plugins: - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs spec: "@yarnpkg/plugin-interactive-tools" diff --git a/docs/ManualMocks.md b/docs/ManualMocks.md index 2969e49ea170..8835ead766e9 100644 --- a/docs/ManualMocks.md +++ b/docs/ManualMocks.md @@ -115,9 +115,8 @@ describe('listFilesInDirectorySync', () => { test('includes all files in the directory in the summary', () => { const FileSummarizer = require('../FileSummarizer'); - const fileSummary = FileSummarizer.summarizeFilesInDirectorySync( - '/path/to', - ); + const fileSummary = + FileSummarizer.summarizeFilesInDirectorySync('/path/to'); expect(fileSummary.length).toBe(2); }); diff --git a/e2e/Utils.ts b/e2e/Utils.ts index 1d52d74000f7..fd0a591dfa49 100644 --- a/e2e/Utils.ts +++ b/e2e/Utils.ts @@ -69,15 +69,15 @@ export const linkJestPackage = (packageName: string, cwd: Config.Path) => { fs.symlinkSync(packagePath, destination, 'junction'); }; -export const makeTemplate = ( - str: string, -): ((values?: Array) => string) => (values = []) => - str.replace(/\$(\d+)/g, (_match, number) => { - if (!Array.isArray(values)) { - throw new Error('Array of values must be passed to the template.'); - } - return values[number - 1]; - }); +export const makeTemplate = + (str: string): ((values?: Array) => string) => + (values = []) => + str.replace(/\$(\d+)/g, (_match, number) => { + if (!Array.isArray(values)) { + throw new Error('Array of values must be passed to the template.'); + } + return values[number - 1]; + }); export const cleanup = (directory: string) => rimraf.sync(directory); @@ -251,7 +251,8 @@ export const extractSortedSummary = (stdout: string) => { export const extractSummaries = ( stdout: string, ): Array<{rest: string; summary: string}> => { - const regex = /Test Suites:.*\nTests.*\nSnapshots.*\nTime.*(\nRan all test suites)*.*\n*$/gm; + const regex = + /Test Suites:.*\nTests.*\nSnapshots.*\nTime.*(\nRan all test suites)*.*\n*$/gm; let match = regex.exec(stdout); const matches: Array = []; diff --git a/e2e/__tests__/jestChangedFiles.test.ts b/e2e/__tests__/jestChangedFiles.test.ts index 98f20a601dd9..deafea9f555b 100644 --- a/e2e/__tests__/jestChangedFiles.test.ts +++ b/e2e/__tests__/jestChangedFiles.test.ts @@ -378,11 +378,9 @@ testIfHg('gets changed files for hg', async () => { run(`${HG} init`, DIR); - const roots = [ - '', - 'nested-dir', - 'nested-dir/second-nested-dir', - ].map(filename => path.resolve(DIR, filename)); + const roots = ['', 'nested-dir', 'nested-dir/second-nested-dir'].map( + filename => path.resolve(DIR, filename), + ); let {changedFiles: files} = await getChangedFilesForRoots(roots, {}); expect( diff --git a/e2e/__tests__/toMatchSnapshot.test.ts b/e2e/__tests__/toMatchSnapshot.test.ts index 2c5c1dce8bdc..38efdbcec8fc 100644 --- a/e2e/__tests__/toMatchSnapshot.test.ts +++ b/e2e/__tests__/toMatchSnapshot.test.ts @@ -231,7 +231,8 @@ test('handles invalid property matchers', () => { test('handles property matchers with hint', () => { const filename = 'handle-property-matchers-with-hint.test.js'; - const template = makeTemplate(`test('handles property matchers with hint', () => { + const template = + makeTemplate(`test('handles property matchers with hint', () => { expect({createdAt: $1}).toMatchSnapshot({createdAt: expect.any(Date)}, 'descriptive hint'); }); `); @@ -263,7 +264,8 @@ test('handles property matchers with hint', () => { test('handles property matchers with deep properties', () => { const filename = 'handle-property-matchers-with-name.test.js'; - const template = makeTemplate(`test('handles property matchers with deep properties', () => { + const template = + makeTemplate(`test('handles property matchers with deep properties', () => { expect({ user: { createdAt: $1, name: $2 }}).toMatchSnapshot({ user: { createdAt: expect.any(Date), name: $2 }}); }); `); diff --git a/e2e/__tests__/toThrowErrorMatchingSnapshot.test.ts b/e2e/__tests__/toThrowErrorMatchingSnapshot.test.ts index de3a3010ccf7..4ff08cc5f4f3 100644 --- a/e2e/__tests__/toThrowErrorMatchingSnapshot.test.ts +++ b/e2e/__tests__/toThrowErrorMatchingSnapshot.test.ts @@ -19,7 +19,8 @@ afterAll(() => cleanup(TESTS_DIR)); test('works fine when function throws error', () => { const filename = 'works-fine-when-function-throws-error.test.js'; - const template = makeTemplate(`test('works fine when function throws error', () => { + const template = + makeTemplate(`test('works fine when function throws error', () => { expect(() => { throw new Error('apple'); }) .toThrowErrorMatchingSnapshot(); }); @@ -35,7 +36,8 @@ test('works fine when function throws error', () => { test(`throws the error if tested function didn't throw error`, () => { const filename = 'throws-if-tested-function-did-not-throw.test.js'; - const template = makeTemplate(`test('throws the error if tested function did not throw error', () => { + const template = + makeTemplate(`test('throws the error if tested function did not throw error', () => { expect(() => {}).toThrowErrorMatchingSnapshot(); }); `); @@ -83,7 +85,8 @@ test('cannot be used with .not', () => { test('should support rejecting promises', () => { const filename = 'should-support-rejecting-promises.test.js'; - const template = makeTemplate(`test('should support rejecting promises', () => { + const template = + makeTemplate(`test('should support rejecting promises', () => { return expect(Promise.reject(new Error('octopus'))).rejects.toThrowErrorMatchingSnapshot(); }); `); diff --git a/e2e/browser-resolver/fake-pkg/package.json b/e2e/browser-resolver/fake-pkg/package.json index 93cece076b35..dc12cbaedb20 100644 --- a/e2e/browser-resolver/fake-pkg/package.json +++ b/e2e/browser-resolver/fake-pkg/package.json @@ -5,6 +5,5 @@ "browser": { "./nope.js": "./main.js" }, - "dependencies": { - } + "dependencies": {} } diff --git a/e2e/call-done-twice/package.json b/e2e/call-done-twice/package.json index e22eaf20573d..148788b25446 100644 --- a/e2e/call-done-twice/package.json +++ b/e2e/call-done-twice/package.json @@ -1,5 +1,5 @@ { - "jest": { - "testEnvironment": "node" - } + "jest": { + "testEnvironment": "node" + } } diff --git a/e2e/coverage-without-transform/package.json b/e2e/coverage-without-transform/package.json index 1453c0e1c96b..e2ee444a27b7 100644 --- a/e2e/coverage-without-transform/package.json +++ b/e2e/coverage-without-transform/package.json @@ -1,6 +1,8 @@ { "jest": { - "collectCoverageFrom": ["*.js"], + "collectCoverageFrom": [ + "*.js" + ], "transform": {}, "testEnvironment": "node" } diff --git a/e2e/global-setup-node-modules/package.json b/e2e/global-setup-node-modules/package.json index dd05160ee540..920e91b1a5dd 100644 --- a/e2e/global-setup-node-modules/package.json +++ b/e2e/global-setup-node-modules/package.json @@ -2,7 +2,6 @@ "jest": { "testEnvironment": "node", "globalSetup": "/setup.js", - "transformIgnorePatterns": [ - ] + "transformIgnorePatterns": [] } } diff --git a/e2e/module-name-mapper-correct-config/package.json b/e2e/module-name-mapper-correct-config/package.json index 9a4fb2ec95f8..2631a529d64a 100644 --- a/e2e/module-name-mapper-correct-config/package.json +++ b/e2e/module-name-mapper-correct-config/package.json @@ -2,7 +2,10 @@ "jest": { "moduleNameMapper": { "\\.(css|less)$": "./__mocks__/styleMock.js", - "\\.(sass)$": ["./__mocks__/nonExistentMock.js", "./__mocks__/styleMock.js"] + "\\.(sass)$": [ + "./__mocks__/nonExistentMock.js", + "./__mocks__/styleMock.js" + ] } } } diff --git a/e2e/module-name-mapper-wrong-array-config/package.json b/e2e/module-name-mapper-wrong-array-config/package.json index 6028d52abe51..e8468b116c54 100644 --- a/e2e/module-name-mapper-wrong-array-config/package.json +++ b/e2e/module-name-mapper-wrong-array-config/package.json @@ -1,7 +1,10 @@ { "jest": { "moduleNameMapper": { - "\\.(css|less)$": ["no-such-module", "no-such-module-2"] + "\\.(css|less)$": [ + "no-such-module", + "no-such-module-2" + ] } } } diff --git a/e2e/native-esm-typescript/package.json b/e2e/native-esm-typescript/package.json index 3e30fb6f9177..16c153a4a53e 100644 --- a/e2e/native-esm-typescript/package.json +++ b/e2e/native-esm-typescript/package.json @@ -2,7 +2,9 @@ "name": "native-esm-typescript", "version": "1.0.0", "jest": { - "extensionsToTreatAsEsm": [".ts"], + "extensionsToTreatAsEsm": [ + ".ts" + ], "testEnvironment": "node" } } diff --git a/e2e/require-main-after-create-require/package.json b/e2e/require-main-after-create-require/package.json index eccb477ccc2b..148788b25446 100644 --- a/e2e/require-main-after-create-require/package.json +++ b/e2e/require-main-after-create-require/package.json @@ -3,4 +3,3 @@ "testEnvironment": "node" } } - diff --git a/e2e/transform/transform-environment/tsconfig.json b/e2e/transform/transform-environment/tsconfig.json index 174da5dc37bf..48bf574f026a 100644 --- a/e2e/transform/transform-environment/tsconfig.json +++ b/e2e/transform/transform-environment/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { "esModuleInterop": true, - "module": "commonjs", + "module": "commonjs" } } diff --git a/e2e/transform/transform-runner/runner.ts b/e2e/transform/transform-runner/runner.ts index 2d44fbf0d4ae..1a1f7b432a7c 100644 --- a/e2e/transform/transform-runner/runner.ts +++ b/e2e/transform/transform-runner/runner.ts @@ -38,29 +38,27 @@ export default class BaseTestRunner { (promise, test) => mutex(() => promise - .then( - async (): Promise => { - await onStart(test); - return { - ...createEmptyTestResult(), - numPassingTests: 1, - testFilePath: test.path, - testResults: [ - { - ancestorTitles: [], - duration: 2, - failureDetails: [], - failureMessages: [], - fullName: 'sample test', - location: null, - numPassingAsserts: 1, - status: 'passed', - title: 'sample test', - }, - ], - }; - }, - ) + .then(async (): Promise => { + await onStart(test); + return { + ...createEmptyTestResult(), + numPassingTests: 1, + testFilePath: test.path, + testResults: [ + { + ancestorTitles: [], + duration: 2, + failureDetails: [], + failureMessages: [], + fullName: 'sample test', + location: null, + numPassingAsserts: 1, + status: 'passed', + title: 'sample test', + }, + ], + }; + }) .then(result => onResult(test, result)) .catch(err => onFailure(test, err)), ), diff --git a/e2e/transform/transform-runner/tsconfig.json b/e2e/transform/transform-runner/tsconfig.json index 174da5dc37bf..48bf574f026a 100644 --- a/e2e/transform/transform-runner/tsconfig.json +++ b/e2e/transform/transform-runner/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { "esModuleInterop": true, - "module": "commonjs", + "module": "commonjs" } } diff --git a/e2e/transform/transform-testrunner/tsconfig.json b/e2e/transform/transform-testrunner/tsconfig.json index 174da5dc37bf..48bf574f026a 100644 --- a/e2e/transform/transform-testrunner/tsconfig.json +++ b/e2e/transform/transform-testrunner/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { "esModuleInterop": true, - "module": "commonjs", + "module": "commonjs" } } diff --git a/e2e/watch-plugins/cjs/package.json b/e2e/watch-plugins/cjs/package.json index 46ecf4693a8b..06f4a7adacf8 100644 --- a/e2e/watch-plugins/cjs/package.json +++ b/e2e/watch-plugins/cjs/package.json @@ -1,5 +1,7 @@ { "jest": { - "watchPlugins": ["./my-watch-plugin.cjs"] + "watchPlugins": [ + "./my-watch-plugin.cjs" + ] } } diff --git a/e2e/watch-plugins/js-type-module/package.json b/e2e/watch-plugins/js-type-module/package.json index 394accc14218..5915ce15ac86 100644 --- a/e2e/watch-plugins/js-type-module/package.json +++ b/e2e/watch-plugins/js-type-module/package.json @@ -1,6 +1,8 @@ { "type": "module", "jest": { - "watchPlugins": ["./my-watch-plugin.js"] + "watchPlugins": [ + "./my-watch-plugin.js" + ] } } diff --git a/e2e/watch-plugins/js/package.json b/e2e/watch-plugins/js/package.json index ac767498b92b..fb632c721d95 100644 --- a/e2e/watch-plugins/js/package.json +++ b/e2e/watch-plugins/js/package.json @@ -1,5 +1,7 @@ { "jest": { - "watchPlugins": ["./my-watch-plugin.js"] + "watchPlugins": [ + "./my-watch-plugin.js" + ] } } diff --git a/e2e/watch-plugins/mjs/package.json b/e2e/watch-plugins/mjs/package.json index 8ff0caf139e3..ad712bf25ac9 100644 --- a/e2e/watch-plugins/mjs/package.json +++ b/e2e/watch-plugins/mjs/package.json @@ -1,5 +1,7 @@ { "jest": { - "watchPlugins": ["./my-watch-plugin.mjs"] + "watchPlugins": [ + "./my-watch-plugin.mjs" + ] } } diff --git a/examples/manual-mocks/__tests__/file_summarizer.test.js b/examples/manual-mocks/__tests__/file_summarizer.test.js index 2429e47acf5c..7e352a31d7f7 100644 --- a/examples/manual-mocks/__tests__/file_summarizer.test.js +++ b/examples/manual-mocks/__tests__/file_summarizer.test.js @@ -17,9 +17,8 @@ describe('listFilesInDirectorySync', () => { it('includes all files in the directory in the summary', () => { const FileSummarizer = require('../FileSummarizer'); - const fileSummary = FileSummarizer.summarizeFilesInDirectorySync( - '/path/to', - ); + const fileSummary = + FileSummarizer.summarizeFilesInDirectorySync('/path/to'); expect(fileSummary.length).toBe(2); }); diff --git a/lerna.json b/lerna.json index a27885a992c0..661f2808f325 100644 --- a/lerna.json +++ b/lerna.json @@ -1,7 +1,5 @@ { "version": "27.0.0-next.9", "npmClient": "yarn", - "packages": [ - "packages/*" - ] + "packages": ["packages/*"] } diff --git a/packages/babel-plugin-jest-hoist/src/__tests__/__snapshots__/hoistPlugin.test.ts.snap b/packages/babel-plugin-jest-hoist/src/__tests__/__snapshots__/hoistPlugin.test.ts.snap index b90662f2176e..98dd43fb2396 100644 --- a/packages/babel-plugin-jest-hoist/src/__tests__/__snapshots__/hoistPlugin.test.ts.snap +++ b/packages/babel-plugin-jest-hoist/src/__tests__/__snapshots__/hoistPlugin.test.ts.snap @@ -8,21 +8,23 @@ jest.mock('./App', () => () =>
Hello world
); var _jsxFileName = "/root/project/src/file.js"; -_getJestObj().mock("./App", () => () => - /*#__PURE__*/ _jsxDEV( - "div", - { - children: "Hello world", - }, - void 0, - false, - { - fileName: _jsxFileName, - lineNumber: 1, - columnNumber: 32, - }, - this - ) +_getJestObj().mock( + "./App", + () => () => + /*#__PURE__*/ _jsxDEV( + "div", + { + children: "Hello world", + }, + void 0, + false, + { + fileName: _jsxFileName, + lineNumber: 1, + columnNumber: 32, + }, + this + ) ); import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime"; diff --git a/packages/babel-plugin-jest-hoist/src/index.ts b/packages/babel-plugin-jest-hoist/src/index.ts index fc93cd8ca7de..cc3aeba8431a 100644 --- a/packages/babel-plugin-jest-hoist/src/index.ts +++ b/packages/babel-plugin-jest-hoist/src/index.ts @@ -278,9 +278,8 @@ export default (): PluginObj<{ return this.jestObjGetterIdentifier; } - this.jestObjGetterIdentifier = program.scope.generateUidIdentifier( - 'getJestObj', - ); + this.jestObjGetterIdentifier = + program.scope.generateUidIdentifier('getJestObj'); program.unshiftContainer('body', [ createJestObjectGetter({ diff --git a/packages/expect/src/extractExpectedAssertionsErrors.ts b/packages/expect/src/extractExpectedAssertionsErrors.ts index d4d19e8bbaca..ebc24cd9d976 100644 --- a/packages/expect/src/extractExpectedAssertionsErrors.ts +++ b/packages/expect/src/extractExpectedAssertionsErrors.ts @@ -25,60 +25,61 @@ const resetAssertionsLocalState = () => { // Create and format all errors related to the mismatched number of `expect` // calls and reset the matcher's state. -const extractExpectedAssertionsErrors: Expect['extractExpectedAssertionsErrors'] = () => { - const result: ExpectedAssertionsErrors = []; - const { - assertionCalls, - expectedAssertionsNumber, - expectedAssertionsNumberError, - isExpectingAssertions, - isExpectingAssertionsError, - } = getState(); +const extractExpectedAssertionsErrors: Expect['extractExpectedAssertionsErrors'] = + () => { + const result: ExpectedAssertionsErrors = []; + const { + assertionCalls, + expectedAssertionsNumber, + expectedAssertionsNumberError, + isExpectingAssertions, + isExpectingAssertionsError, + } = getState(); - resetAssertionsLocalState(); + resetAssertionsLocalState(); - if ( - typeof expectedAssertionsNumber === 'number' && - assertionCalls !== expectedAssertionsNumber - ) { - const numOfAssertionsExpected = EXPECTED_COLOR( - pluralize('assertion', expectedAssertionsNumber), - ); + if ( + typeof expectedAssertionsNumber === 'number' && + assertionCalls !== expectedAssertionsNumber + ) { + const numOfAssertionsExpected = EXPECTED_COLOR( + pluralize('assertion', expectedAssertionsNumber), + ); - expectedAssertionsNumberError!.message = - matcherHint('.assertions', '', String(expectedAssertionsNumber), { - isDirectExpectCall: true, - }) + - '\n\n' + - `Expected ${numOfAssertionsExpected} to be called but received ` + - RECEIVED_COLOR(pluralize('assertion call', assertionCalls || 0)) + - '.'; + expectedAssertionsNumberError!.message = + matcherHint('.assertions', '', String(expectedAssertionsNumber), { + isDirectExpectCall: true, + }) + + '\n\n' + + `Expected ${numOfAssertionsExpected} to be called but received ` + + RECEIVED_COLOR(pluralize('assertion call', assertionCalls || 0)) + + '.'; - result.push({ - actual: assertionCalls.toString(), - error: expectedAssertionsNumberError!, - expected: expectedAssertionsNumber.toString(), - }); - } - if (isExpectingAssertions && assertionCalls === 0) { - const expected = EXPECTED_COLOR('at least one assertion'); - const received = RECEIVED_COLOR('received none'); + result.push({ + actual: assertionCalls.toString(), + error: expectedAssertionsNumberError!, + expected: expectedAssertionsNumber.toString(), + }); + } + if (isExpectingAssertions && assertionCalls === 0) { + const expected = EXPECTED_COLOR('at least one assertion'); + const received = RECEIVED_COLOR('received none'); - isExpectingAssertionsError!.message = - matcherHint('.hasAssertions', '', '', { - isDirectExpectCall: true, - }) + - '\n\n' + - `Expected ${expected} to be called but ${received}.`; + isExpectingAssertionsError!.message = + matcherHint('.hasAssertions', '', '', { + isDirectExpectCall: true, + }) + + '\n\n' + + `Expected ${expected} to be called but ${received}.`; - result.push({ - actual: 'none', - error: isExpectingAssertionsError!, - expected: 'at least one', - }); - } + result.push({ + actual: 'none', + error: isExpectingAssertionsError!, + expected: 'at least one', + }); + } - return result; -}; + return result; + }; export default extractExpectedAssertionsErrors; diff --git a/packages/expect/src/index.ts b/packages/expect/src/index.ts index e205722ab9cf..9b86118551d2 100644 --- a/packages/expect/src/index.ts +++ b/packages/expect/src/index.ts @@ -141,100 +141,104 @@ const getMessage = (message?: () => string) => (message && message()) || matcherUtils.RECEIVED_COLOR('No message was specified for this matcher.'); -const makeResolveMatcher = ( - matcherName: string, - matcher: RawMatcherFn, - isNot: boolean, - actual: Promise, - outerErr: JestAssertionError, -): PromiseMatcherFn => (...args) => { - const options = { - isNot, - promise: 'resolves', - }; +const makeResolveMatcher = + ( + matcherName: string, + matcher: RawMatcherFn, + isNot: boolean, + actual: Promise, + outerErr: JestAssertionError, + ): PromiseMatcherFn => + (...args) => { + const options = { + isNot, + promise: 'resolves', + }; - if (!isPromise(actual)) { - throw new JestAssertionError( - matcherUtils.matcherErrorMessage( - matcherUtils.matcherHint(matcherName, undefined, '', options), - `${matcherUtils.RECEIVED_COLOR('received')} value must be a promise`, - matcherUtils.printWithType( - 'Received', - actual, - matcherUtils.printReceived, + if (!isPromise(actual)) { + throw new JestAssertionError( + matcherUtils.matcherErrorMessage( + matcherUtils.matcherHint(matcherName, undefined, '', options), + `${matcherUtils.RECEIVED_COLOR('received')} value must be a promise`, + matcherUtils.printWithType( + 'Received', + actual, + matcherUtils.printReceived, + ), ), - ), - ); - } + ); + } - const innerErr = new JestAssertionError(); - - return actual.then( - result => - makeThrowingMatcher(matcher, isNot, 'resolves', result, innerErr).apply( - null, - args, - ), - reason => { - outerErr.message = - matcherUtils.matcherHint(matcherName, undefined, '', options) + - '\n\n' + - `Received promise rejected instead of resolved\n` + - `Rejected to value: ${matcherUtils.printReceived(reason)}`; - return Promise.reject(outerErr); - }, - ); -}; + const innerErr = new JestAssertionError(); -const makeRejectMatcher = ( - matcherName: string, - matcher: RawMatcherFn, - isNot: boolean, - actual: Promise | (() => Promise), - outerErr: JestAssertionError, -): PromiseMatcherFn => (...args) => { - const options = { - isNot, - promise: 'rejects', + return actual.then( + result => + makeThrowingMatcher(matcher, isNot, 'resolves', result, innerErr).apply( + null, + args, + ), + reason => { + outerErr.message = + matcherUtils.matcherHint(matcherName, undefined, '', options) + + '\n\n' + + `Received promise rejected instead of resolved\n` + + `Rejected to value: ${matcherUtils.printReceived(reason)}`; + return Promise.reject(outerErr); + }, + ); }; - const actualWrapper: Promise = - typeof actual === 'function' ? actual() : actual; - - if (!isPromise(actualWrapper)) { - throw new JestAssertionError( - matcherUtils.matcherErrorMessage( - matcherUtils.matcherHint(matcherName, undefined, '', options), - `${matcherUtils.RECEIVED_COLOR( - 'received', - )} value must be a promise or a function returning a promise`, - matcherUtils.printWithType( - 'Received', - actual, - matcherUtils.printReceived, +const makeRejectMatcher = + ( + matcherName: string, + matcher: RawMatcherFn, + isNot: boolean, + actual: Promise | (() => Promise), + outerErr: JestAssertionError, + ): PromiseMatcherFn => + (...args) => { + const options = { + isNot, + promise: 'rejects', + }; + + const actualWrapper: Promise = + typeof actual === 'function' ? actual() : actual; + + if (!isPromise(actualWrapper)) { + throw new JestAssertionError( + matcherUtils.matcherErrorMessage( + matcherUtils.matcherHint(matcherName, undefined, '', options), + `${matcherUtils.RECEIVED_COLOR( + 'received', + )} value must be a promise or a function returning a promise`, + matcherUtils.printWithType( + 'Received', + actual, + matcherUtils.printReceived, + ), ), - ), - ); - } + ); + } - const innerErr = new JestAssertionError(); - - return actualWrapper.then( - result => { - outerErr.message = - matcherUtils.matcherHint(matcherName, undefined, '', options) + - '\n\n' + - `Received promise resolved instead of rejected\n` + - `Resolved to value: ${matcherUtils.printReceived(result)}`; - return Promise.reject(outerErr); - }, - reason => - makeThrowingMatcher(matcher, isNot, 'rejects', reason, innerErr).apply( - null, - args, - ), - ); -}; + const innerErr = new JestAssertionError(); + + return actualWrapper.then( + result => { + outerErr.message = + matcherUtils.matcherHint(matcherName, undefined, '', options) + + '\n\n' + + `Received promise resolved instead of rejected\n` + + `Resolved to value: ${matcherUtils.printReceived(result)}`; + return Promise.reject(outerErr); + }, + reason => + makeThrowingMatcher(matcher, isNot, 'rejects', reason, innerErr).apply( + null, + args, + ), + ); + }; const makeThrowingMatcher = ( matcher: RawMatcherFn, diff --git a/packages/expect/src/utils.ts b/packages/expect/src/utils.ts index 1d568de8d117..d59efca71fd3 100644 --- a/packages/expect/src/utils.ts +++ b/packages/expect/src/utils.ts @@ -276,36 +276,36 @@ export const subsetEquality = ( // subsetEquality needs to keep track of the references // it has already visited to avoid infinite loops in case // there are circular references in the subset passed to it. - const subsetEqualityWithContext = ( - seenReferences: WeakMap = new WeakMap(), - ) => (object: any, subset: any): boolean | undefined => { - if (!isObjectWithKeys(subset)) { - return undefined; - } + const subsetEqualityWithContext = + (seenReferences: WeakMap = new WeakMap()) => + (object: any, subset: any): boolean | undefined => { + if (!isObjectWithKeys(subset)) { + return undefined; + } - return Object.keys(subset).every(key => { - if (isObjectWithKeys(subset[key])) { - if (seenReferences.has(subset[key])) { - return equals(object[key], subset[key], [iterableEquality]); + return Object.keys(subset).every(key => { + if (isObjectWithKeys(subset[key])) { + if (seenReferences.has(subset[key])) { + return equals(object[key], subset[key], [iterableEquality]); + } + seenReferences.set(subset[key], true); } - seenReferences.set(subset[key], true); - } - const result = - object != null && - hasPropertyInObject(object, key) && - equals(object[key], subset[key], [ - iterableEquality, - subsetEqualityWithContext(seenReferences), - ]); - // The main goal of using seenReference is to avoid circular node on tree. - // It will only happen within a parent and its child, not a node and nodes next to it (same level) - // We should keep the reference for a parent and its child only - // Thus we should delete the reference immediately so that it doesn't interfere - // other nodes within the same level on tree. - seenReferences.delete(subset[key]); - return result; - }); - }; + const result = + object != null && + hasPropertyInObject(object, key) && + equals(object[key], subset[key], [ + iterableEquality, + subsetEqualityWithContext(seenReferences), + ]); + // The main goal of using seenReference is to avoid circular node on tree. + // It will only happen within a parent and its child, not a node and nodes next to it (same level) + // We should keep the reference for a parent and its child only + // Thus we should delete the reference immediately so that it doesn't interfere + // other nodes within the same level on tree. + seenReferences.delete(subset[key]); + return result; + }); + }; return subsetEqualityWithContext()(object, subset); }; diff --git a/packages/jest-changed-files/tsconfig.json b/packages/jest-changed-files/tsconfig.json index 25e34a0f4511..3046cb6b9b6a 100644 --- a/packages/jest-changed-files/tsconfig.json +++ b/packages/jest-changed-files/tsconfig.json @@ -4,7 +4,5 @@ "rootDir": "src", "outDir": "build" }, - "references": [ - {"path": "../jest-types"} - ] + "references": [{"path": "../jest-types"}] } diff --git a/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.ts b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.ts index e9b38908ce63..1b6908fa113d 100644 --- a/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.ts +++ b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.ts @@ -23,12 +23,10 @@ const jestAdapter = async ( testPath: string, sendMessageToJest?: TestFileEvent, ): Promise => { - const { - initialize, - runAndTransformResultsToJestFormat, - } = runtime.requireInternalModule( - FRAMEWORK_INITIALIZER, - ); + const {initialize, runAndTransformResultsToJestFormat} = + runtime.requireInternalModule( + FRAMEWORK_INITIALIZER, + ); const {globals, snapshotState} = await initialize({ config, diff --git a/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts index cac44efb078b..46d21818a596 100644 --- a/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts +++ b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts @@ -263,16 +263,15 @@ export const runAndTransformResultsToJestFormat = async ({ }; }; -const handleSnapshotStateAfterRetry = (snapshotState: SnapshotStateType) => ( - event: Circus.Event, -) => { - switch (event.name) { - case 'test_retry': { - // Clear any snapshot data that occurred in previous test run - snapshotState.clear(); +const handleSnapshotStateAfterRetry = + (snapshotState: SnapshotStateType) => (event: Circus.Event) => { + switch (event.name) { + case 'test_retry': { + // Clear any snapshot data that occurred in previous test run + snapshotState.clear(); + } } - } -}; + }; const eventHandler = async (event: Circus.Event) => { switch (event.name) { diff --git a/packages/jest-circus/src/testCaseReportHandler.ts b/packages/jest-circus/src/testCaseReportHandler.ts index f68515e0e9cc..86001187fe50 100644 --- a/packages/jest-circus/src/testCaseReportHandler.ts +++ b/packages/jest-circus/src/testCaseReportHandler.ts @@ -9,18 +9,17 @@ import type {Circus} from '@jest/types'; import type {TestFileEvent} from 'jest-runner'; import {makeSingleTestResult, parseSingleTestResult} from './utils'; -const testCaseReportHandler = ( - testPath: string, - sendMessageToJest: TestFileEvent, -) => (event: Circus.Event): void => { - switch (event.name) { - case 'test_done': { - const testResult = makeSingleTestResult(event.test); - const testCaseResult = parseSingleTestResult(testResult); - sendMessageToJest('test-case-result', [testPath, testCaseResult]); - break; +const testCaseReportHandler = + (testPath: string, sendMessageToJest: TestFileEvent) => + (event: Circus.Event): void => { + switch (event.name) { + case 'test_done': { + const testResult = makeSingleTestResult(event.test); + const testCaseResult = parseSingleTestResult(testResult); + sendMessageToJest('test-case-result', [testPath, testCaseResult]); + break; + } } - } -}; + }; export default testCaseReportHandler; diff --git a/packages/jest-circus/src/types.ts b/packages/jest-circus/src/types.ts index 60c406117cf0..d381cfec56e1 100644 --- a/packages/jest-circus/src/types.ts +++ b/packages/jest-circus/src/types.ts @@ -9,16 +9,16 @@ import type {Circus} from '@jest/types'; import expect = require('expect'); -export const STATE_SYM = (Symbol( +export const STATE_SYM = Symbol( 'JEST_STATE_SYMBOL', -) as unknown) as 'STATE_SYM_SYMBOL'; -export const RETRY_TIMES = (Symbol.for( +) as unknown as 'STATE_SYM_SYMBOL'; +export const RETRY_TIMES = Symbol.for( 'RETRY_TIMES', -) as unknown) as 'RETRY_TIMES_SYMBOL'; +) as unknown as 'RETRY_TIMES_SYMBOL'; // To pass this value from Runtime object to state we need to use global[sym] -export const TEST_TIMEOUT_SYMBOL = (Symbol.for( +export const TEST_TIMEOUT_SYMBOL = Symbol.for( 'TEST_TIMEOUT_SYMBOL', -) as unknown) as 'TEST_TIMEOUT_SYMBOL'; +) as unknown as 'TEST_TIMEOUT_SYMBOL'; declare global { module NodeJS { diff --git a/packages/jest-cli/src/__tests__/cli/args.test.ts b/packages/jest-cli/src/__tests__/cli/args.test.ts index 1e8bc855ebaf..112c02198b39 100644 --- a/packages/jest-cli/src/__tests__/cli/args.test.ts +++ b/packages/jest-cli/src/__tests__/cli/args.test.ts @@ -56,14 +56,14 @@ describe('check', () => { }); it('raises an exception if maxWorkers is specified with no number', () => { - const argv = ({maxWorkers: undefined} as unknown) as Config.Argv; + const argv = {maxWorkers: undefined} as unknown as Config.Argv; expect(() => check(argv)).toThrow( 'The --maxWorkers (-w) option requires a number or string to be specified', ); }); it('allows maxWorkers to be a %', () => { - const argv = ({maxWorkers: '50%'} as unknown) as Config.Argv; + const argv = {maxWorkers: '50%'} as unknown as Config.Argv; expect(() => check(argv)).not.toThrow(); }); diff --git a/packages/jest-cli/src/init/__tests__/init.test.js b/packages/jest-cli/src/init/__tests__/init.test.js index e95d79aca782..6f8867a246b8 100644 --- a/packages/jest-cli/src/init/__tests__/init.test.js +++ b/packages/jest-cli/src/init/__tests__/init.test.js @@ -15,8 +15,9 @@ import init from '../'; const {JEST_CONFIG_EXT_ORDER} = constants; jest.mock('prompts'); -jest.mock('../../../../jest-config/build/getCacheDirectory', () => () => - '/tmp/jest', +jest.mock( + '../../../../jest-config/build/getCacheDirectory', + () => () => '/tmp/jest', ); jest.mock('path', () => ({...jest.requireActual('path'), sep: '/'})); jest.mock('graceful-fs', () => ({ diff --git a/packages/jest-cli/src/init/generateConfigFile.ts b/packages/jest-cli/src/init/generateConfigFile.ts index 6b672f49bffe..4e70ad309382 100644 --- a/packages/jest-cli/src/init/generateConfigFile.ts +++ b/packages/jest-cli/src/init/generateConfigFile.ts @@ -35,13 +35,8 @@ const generateConfigFile = ( results: Record, generateEsm = false, ): string => { - const { - useTypescript, - coverage, - coverageProvider, - clearMocks, - environment, - } = results; + const {useTypescript, coverage, coverageProvider, clearMocks, environment} = + results; const overrides: Record = {}; diff --git a/packages/jest-config/src/__tests__/normalize.test.ts b/packages/jest-config/src/__tests__/normalize.test.ts index d34ec4b6ffcb..751c0cabe7dc 100644 --- a/packages/jest-config/src/__tests__/normalize.test.ts +++ b/packages/jest-config/src/__tests__/normalize.test.ts @@ -64,7 +64,7 @@ beforeEach(() => { }); afterEach(() => { - ((console.warn as unknown) as jest.SpyInstance).mockRestore(); + (console.warn as unknown as jest.SpyInstance).mockRestore(); }); it('picks a name based on the rootDir', async () => { @@ -148,9 +148,7 @@ describe('rootDir', () => { describe('automock', () => { it('falsy automock is not overwritten', async () => { - ((console.warn as unknown) as jest.SpyInstance).mockImplementation( - () => {}, - ); + (console.warn as unknown as jest.SpyInstance).mockImplementation(() => {}); const {options} = await normalize( { automock: false, @@ -432,9 +430,7 @@ describe('setupTestFrameworkScriptFile', () => { let Resolver; beforeEach(() => { - ((console.warn as unknown) as jest.SpyInstance).mockImplementation( - () => {}, - ); + (console.warn as unknown as jest.SpyInstance).mockImplementation(() => {}); Resolver = require('jest-resolve').default; Resolver.findNodeModule = jest.fn(name => name.startsWith('/') ? name : '/root/path/foo' + path.sep + name, @@ -451,7 +447,7 @@ describe('setupTestFrameworkScriptFile', () => { ); expect( - ((console.warn as unknown) as jest.SpyInstance).mock.calls[0][0], + (console.warn as unknown as jest.SpyInstance).mock.calls[0][0], ).toMatchSnapshot(); }); @@ -825,9 +821,7 @@ describe('babel-jest', () => { describe('Upgrade help', () => { beforeEach(() => { - ((console.warn as unknown) as jest.SpyInstance).mockImplementation( - () => {}, - ); + (console.warn as unknown as jest.SpyInstance).mockImplementation(() => {}); const Resolver = require('jest-resolve').default; Resolver.findNodeModule = jest.fn(name => { @@ -859,7 +853,7 @@ describe('Upgrade help', () => { expect(hasDeprecationWarnings).toBeTruthy(); expect( - ((console.warn as unknown) as jest.SpyInstance).mock.calls[0][0], + (console.warn as unknown as jest.SpyInstance).mock.calls[0][0], ).toMatchSnapshot(); }); }); @@ -1564,7 +1558,7 @@ describe('testPathPattern', () => { expect(options.testPathPattern).toBe(''); expect( - ((console.log as unknown) as jest.SpyInstance).mock.calls[0][0], + (console.log as unknown as jest.SpyInstance).mock.calls[0][0], ).toMatchSnapshot(); }); @@ -1705,9 +1699,7 @@ describe('cwd', () => { }); it('is not lost if the config has its own cwd property', async () => { - ((console.warn as unknown) as jest.SpyInstance).mockImplementation( - () => {}, - ); + (console.warn as unknown as jest.SpyInstance).mockImplementation(() => {}); const {options} = await normalize( { cwd: '/tmp/config-sets-cwd-itself', @@ -1775,9 +1767,7 @@ describe('displayName', () => { describe('testTimeout', () => { it('should return timeout value if defined', async () => { - ((console.warn as unknown) as jest.SpyInstance).mockImplementation( - () => {}, - ); + (console.warn as unknown as jest.SpyInstance).mockImplementation(() => {}); const {options} = await normalize( {rootDir: '/root/', testTimeout: 1000}, {} as Config.Argv, diff --git a/packages/jest-config/src/normalize.ts b/packages/jest-config/src/normalize.ts index d74459d00978..08ea6d7ba270 100644 --- a/packages/jest-config/src/normalize.ts +++ b/packages/jest-config/src/normalize.ts @@ -634,9 +634,9 @@ export default async function normalize( setupBabelJest(options); // TODO: Type this properly - const newOptions = ({ + const newOptions = { ...DEFAULT_CONFIG, - } as unknown) as AllOptions; + } as unknown as AllOptions; if (options.resolver) { newOptions.resolver = resolve(null, { @@ -1061,7 +1061,7 @@ export default async function normalize( newOptions.json = !!argv.json; newOptions.testFailureExitCode = parseInt( - (newOptions.testFailureExitCode as unknown) as string, + newOptions.testFailureExitCode as unknown as string, 10, ); @@ -1113,7 +1113,7 @@ export default async function normalize( : 'new'; newOptions.maxConcurrency = parseInt( - (newOptions.maxConcurrency as unknown) as string, + newOptions.maxConcurrency as unknown as string, 10, ); newOptions.maxWorkers = getMaxWorkers(argv, options); diff --git a/packages/jest-config/src/vendor/jsonlint.js b/packages/jest-config/src/vendor/jsonlint.js index 7dfa6dbced84..adc6847b6557 100644 --- a/packages/jest-config/src/vendor/jsonlint.js +++ b/packages/jest-config/src/vendor/jsonlint.js @@ -1,7 +1,7 @@ // From: https://github.com/zaach/jsonlint // Vendored in Jest to avoid jsonlint's transitive dependencies. /* eslint-disable */ -var jsonlint = (function() { +var jsonlint = (function () { var parser = { trace: function trace() {}, yy: {}, @@ -470,7 +470,7 @@ var jsonlint = (function() { }, }; /* Jison generated lexer */ - var lexer = (function() { + var lexer = (function () { var lexer = { EOF: 1, parseError: function parseError(str, hash) { @@ -480,7 +480,7 @@ var jsonlint = (function() { throw new Error(str); } }, - setInput: function(input) { + setInput: function (input) { this._input = input; this._more = this._less = this.done = false; this.yylineno = this.yyleng = 0; @@ -494,7 +494,7 @@ var jsonlint = (function() { }; return this; }, - input: function() { + input: function () { var ch = this._input[0]; this.yytext += ch; this.yyleng++; @@ -505,18 +505,18 @@ var jsonlint = (function() { this._input = this._input.slice(1); return ch; }, - unput: function(ch) { + unput: function (ch) { this._input = ch + this._input; return this; }, - more: function() { + more: function () { this._more = true; return this; }, - less: function(n) { + less: function (n) { this._input = this.match.slice(n) + this._input; }, - pastInput: function() { + pastInput: function () { var past = this.matched.substr( 0, this.matched.length - this.match.length, @@ -525,7 +525,7 @@ var jsonlint = (function() { (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') ); }, - upcomingInput: function() { + upcomingInput: function () { var next = this.match; if (next.length < 20) { next += this._input.substr(0, 20 - next.length); @@ -535,12 +535,12 @@ var jsonlint = (function() { '', ); }, - showPosition: function() { + showPosition: function () { var pre = this.pastInput(); var c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput() + '\n' + c + '^'; }, - next: function() { + next: function () { if (this.done) { return this.EOF; } @@ -619,7 +619,7 @@ var jsonlint = (function() { this.conditionStack[this.conditionStack.length - 1] ].rules; }, - topState: function() { + topState: function () { return this.conditionStack[this.conditionStack.length - 2]; }, pushState: function begin(condition) { @@ -709,14 +709,14 @@ var jsonlint = (function() { })(); exports.parser = jsonlint; -exports.errors = function(input) { +exports.errors = function (input) { try { this.parse(input); } catch (e) { return e.stack; } }; -exports.parse = function() { +exports.parse = function () { return jsonlint.parse.apply(jsonlint, arguments); }; exports.main = function commonjsMain(args) { diff --git a/packages/jest-core/src/TestScheduler.ts b/packages/jest-core/src/TestScheduler.ts index 7da4517b285e..0bf7746a6092 100644 --- a/packages/jest-core/src/TestScheduler.ts +++ b/packages/jest-core/src/TestScheduler.ts @@ -203,13 +203,12 @@ export default class TestScheduler { const {config} = context; if (!testRunners[config.runner]) { const transformer = await createScriptTransformer(config); - const Runner: typeof TestRunner = await transformer.requireAndTranspileModule( - config.runner, - ); + const Runner: typeof TestRunner = + await transformer.requireAndTranspileModule(config.runner); const runner = new Runner(this._globalConfig, { changedFiles: this._context?.changedFiles, - sourcesRelatedToTestsInChangedFiles: this._context - ?.sourcesRelatedToTestsInChangedFiles, + sourcesRelatedToTestsInChangedFiles: + this._context?.sourcesRelatedToTestsInChangedFiles, }); testRunners[config.runner] = runner; contextsByTestRunner.set(runner, context); @@ -350,8 +349,8 @@ export default class TestScheduler { this.addReporter( new CoverageReporter(this._globalConfig, { changedFiles: this._context?.changedFiles, - sourcesRelatedToTestsInChangedFiles: this._context - ?.sourcesRelatedToTestsInChangedFiles, + sourcesRelatedToTestsInChangedFiles: + this._context?.sourcesRelatedToTestsInChangedFiles, }), ); } @@ -382,8 +381,8 @@ export default class TestScheduler { this.addReporter( new CoverageReporter(this._globalConfig, { changedFiles: this._context?.changedFiles, - sourcesRelatedToTestsInChangedFiles: this._context - ?.sourcesRelatedToTestsInChangedFiles, + sourcesRelatedToTestsInChangedFiles: + this._context?.sourcesRelatedToTestsInChangedFiles, }), ); } @@ -418,9 +417,10 @@ export default class TestScheduler { * Get properties of a reporter in an object * to make dealing with them less painful. */ - private _getReporterProps( - reporter: string | Config.ReporterConfig, - ): {path: string; options: Record} { + private _getReporterProps(reporter: string | Config.ReporterConfig): { + path: string; + options: Record; + } { if (typeof reporter === 'string') { return {options: this._options, path: reporter}; } else if (Array.isArray(reporter)) { diff --git a/packages/jest-core/src/__tests__/SearchSource.test.ts b/packages/jest-core/src/__tests__/SearchSource.test.ts index a5e47a851457..968907ea16d5 100644 --- a/packages/jest-core/src/__tests__/SearchSource.test.ts +++ b/packages/jest-core/src/__tests__/SearchSource.test.ts @@ -599,15 +599,14 @@ describe('SearchSource', () => { rootDir, 'RequireRegularModule.js', ); - const sources = await searchSource.findRelatedSourcesFromTestsInChangedFiles( - { + const sources = + await searchSource.findRelatedSourcesFromTestsInChangedFiles({ changedFiles: new Set([requireRegularModule]), repos: { git: new Set(), hg: new Set(), }, - }, - ); + }); expect(sources).toEqual([]); }); @@ -617,15 +616,14 @@ describe('SearchSource', () => { rootDir, 'RequireRegularModule.js', ); - const sources = await searchSource.findRelatedSourcesFromTestsInChangedFiles( - { + const sources = + await searchSource.findRelatedSourcesFromTestsInChangedFiles({ changedFiles: new Set([requireRegularModule]), repos: { git: new Set('/path/to/git'), hg: new Set(), }, - }, - ); + }); expect(sources).toEqual([regularModule]); }); }); diff --git a/packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts b/packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts index 9c812f2ebacc..63f52ff5cfcd 100644 --- a/packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts +++ b/packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts @@ -13,9 +13,8 @@ import {BaseWatchPlugin, JestHookSubscriber, UsageData} from 'jest-watcher'; import SnapshotInteractiveMode from '../SnapshotInteractiveMode'; class UpdateSnapshotInteractivePlugin extends BaseWatchPlugin { - private _snapshotInteractiveMode: SnapshotInteractiveMode = new SnapshotInteractiveMode( - this._stdout, - ); + private _snapshotInteractiveMode: SnapshotInteractiveMode = + new SnapshotInteractiveMode(this._stdout); private _failedSnapshotTestAssertions: Array = []; isInternal: true = true; @@ -45,9 +44,8 @@ class UpdateSnapshotInteractivePlugin extends BaseWatchPlugin { apply(hooks: JestHookSubscriber): void { hooks.onTestRunComplete(results => { - this._failedSnapshotTestAssertions = this.getFailedSnapshotTestAssertions( - results, - ); + this._failedSnapshotTestAssertions = + this.getFailedSnapshotTestAssertions(results); if (this._snapshotInteractiveMode.isActive()) { this._snapshotInteractiveMode.updateWithResults(results); } diff --git a/packages/jest-core/src/runJest.ts b/packages/jest-core/src/runJest.ts index 4c00bba0a370..51af70ed884e 100644 --- a/packages/jest-core/src/runJest.ts +++ b/packages/jest-core/src/runJest.ts @@ -151,9 +151,9 @@ export default async function runJest({ if (changedFilesPromise && globalConfig.watch) { const {repos} = await changedFilesPromise; - const noSCM = (Object.keys(repos) as Array< - keyof ChangedFiles['repos'] - >).every(scm => repos[scm].size === 0); + const noSCM = ( + Object.keys(repos) as Array + ).every(scm => repos[scm].size === 0); if (noSCM) { process.stderr.write( '\n' + diff --git a/packages/jest-core/src/types.ts b/packages/jest-core/src/types.ts index ca7895bb4b42..144ade08f1d6 100644 --- a/packages/jest-core/src/types.ts +++ b/packages/jest-core/src/types.ts @@ -41,8 +41,6 @@ export type FilterResult = { message: string; }; -export type Filter = ( - testPaths: Array, -) => Promise<{ +export type Filter = (testPaths: Array) => Promise<{ filtered: Array; }>; diff --git a/packages/jest-core/src/watch.ts b/packages/jest-core/src/watch.ts index 7cc38c619c32..0ed96aed727c 100644 --- a/packages/jest-core/src/watch.ts +++ b/packages/jest-core/src/watch.ts @@ -363,10 +363,9 @@ export default async function watch( } // Abort test run - const pluginKeys = getSortedUsageRows( - watchPlugins, - globalConfig, - ).map(usage => Number(usage.key).toString(16)); + const pluginKeys = getSortedUsageRows(watchPlugins, globalConfig).map( + usage => Number(usage.key).toString(16), + ); if ( isRunning && testWatcher && diff --git a/packages/jest-create-cache-key-function/src/__tests__/index.test.ts b/packages/jest-create-cache-key-function/src/__tests__/index.test.ts index 09e434634ff6..b724f9f838ab 100644 --- a/packages/jest-create-cache-key-function/src/__tests__/index.test.ts +++ b/packages/jest-create-cache-key-function/src/__tests__/index.test.ts @@ -23,8 +23,9 @@ afterEach(() => { }); test('creation of a cache key', () => { - const createCacheKeyFunction = interopRequireDefault(require('../index')) - .default; + const createCacheKeyFunction = interopRequireDefault( + require('../index'), + ).default; const createCacheKey = createCacheKeyFunction([], ['value']); const hashA = createCacheKey('test', 'test.js', null, { config: {}, diff --git a/packages/jest-docblock/src/index.ts b/packages/jest-docblock/src/index.ts index 0cee7d16c863..0f2a7d15ad07 100644 --- a/packages/jest-docblock/src/index.ts +++ b/packages/jest-docblock/src/index.ts @@ -15,7 +15,8 @@ const commentStartRe = /^\/\*\*/; const docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/; const lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g; const ltrimNewlineRe = /^(\r?\n)+/; -const multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g; +const multilineRe = + /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g; const propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g; const stringStartRe = /(\r?\n|^) *\* ?/g; const STRING_ARRAY: ReadonlyArray = []; @@ -34,9 +35,10 @@ export function parse(docblock: string): Pragmas { return parseWithComments(docblock).pragmas; } -export function parseWithComments( - docblock: string, -): {comments: string; pragmas: Pragmas} { +export function parseWithComments(docblock: string): { + comments: string; + pragmas: Pragmas; +} { const line = detectNewline(docblock) || EOL; docblock = docblock diff --git a/packages/jest-each/src/bind.ts b/packages/jest-each/src/bind.ts index 0e453f385536..e14b46bbc6f8 100644 --- a/packages/jest-each/src/bind.ts +++ b/packages/jest-each/src/bind.ts @@ -29,33 +29,34 @@ type GlobalCallback = ( ) => void; export default ( - cb: GlobalCallback, - supportsDone: boolean = true, -) => (table: Global.EachTable, ...taggedTemplateData: Global.TemplateData) => - function eachBind( - title: string, - test: Global.EachTestFn, - timeout?: number, - ): void { - try { - const tests = isArrayTable(taggedTemplateData) - ? buildArrayTests(title, table) - : buildTemplateTests(title, table, taggedTemplateData); + cb: GlobalCallback, + supportsDone: boolean = true, + ) => + (table: Global.EachTable, ...taggedTemplateData: Global.TemplateData) => + function eachBind( + title: string, + test: Global.EachTestFn, + timeout?: number, + ): void { + try { + const tests = isArrayTable(taggedTemplateData) + ? buildArrayTests(title, table) + : buildTemplateTests(title, table, taggedTemplateData); - return tests.forEach(row => - cb( - row.title, - applyArguments(supportsDone, row.arguments, test), - timeout, - ), - ); - } catch (e) { - const error = new ErrorWithStack(e.message, eachBind); - return cb(title, () => { - throw error; - }); - } - }; + return tests.forEach(row => + cb( + row.title, + applyArguments(supportsDone, row.arguments, test), + timeout, + ), + ); + } catch (e) { + const error = new ErrorWithStack(e.message, eachBind); + return cb(title, () => { + throw error; + }); + } + }; const isArrayTable = (data: Global.TemplateData) => data.length === 0; diff --git a/packages/jest-each/src/index.ts b/packages/jest-each/src/index.ts index b18cfd546271..4436c465f803 100644 --- a/packages/jest-each/src/index.ts +++ b/packages/jest-each/src/index.ts @@ -71,10 +71,10 @@ const each = ( ...data: Global.TemplateData ): ReturnType => install(global as Global, table, ...data); -each.withGlobal = (g: Global) => ( - table: Global.EachTable, - ...data: Global.TemplateData -) => install(g, table, ...data); +each.withGlobal = + (g: Global) => + (table: Global.EachTable, ...data: Global.TemplateData) => + install(g, table, ...data); export {bind}; diff --git a/packages/jest-each/src/table/interpolation.ts b/packages/jest-each/src/table/interpolation.ts index b239878e686b..b2b5160dcd28 100644 --- a/packages/jest-each/src/table/interpolation.ts +++ b/packages/jest-each/src/table/interpolation.ts @@ -23,23 +23,20 @@ export const interpolateVariables = ( .reduce(replaceKeyPathWithValue(template), title) .replace('$#', '' + index); -const getMatchingKeyPaths = (title: string) => ( - matches: Headings, - key: string, -) => matches.concat(title.match(new RegExp(`\\$${key}[\\.\\w]*`, 'g')) || []); +const getMatchingKeyPaths = + (title: string) => (matches: Headings, key: string) => + matches.concat(title.match(new RegExp(`\\$${key}[\\.\\w]*`, 'g')) || []); -const replaceKeyPathWithValue = (template: Template) => ( - title: string, - match: string, -) => { - const keyPath = match.replace('$', '').split('.'); - const value = getPath(template, keyPath); +const replaceKeyPathWithValue = + (template: Template) => (title: string, match: string) => { + const keyPath = match.replace('$', '').split('.'); + const value = getPath(template, keyPath); - if (isPrimitive(value)) { - return title.replace(match, String(value)); - } - return title.replace(match, pretty(value, {maxDepth: 1, min: true})); -}; + if (isPrimitive(value)) { + return title.replace(match, String(value)); + } + return title.replace(match, pretty(value, {maxDepth: 1, min: true})); + }; /* eslint import/export: 0*/ export function getPath< @@ -48,25 +45,25 @@ export function getPath< B extends keyof Obj[A], C extends keyof Obj[A][B], D extends keyof Obj[A][B][C], - E extends keyof Obj[A][B][C][D] + E extends keyof Obj[A][B][C][D], >(obj: Obj, path: [A, B, C, D, E]): Obj[A][B][C][D][E]; export function getPath< Obj extends Template, A extends keyof Obj, B extends keyof Obj[A], C extends keyof Obj[A][B], - D extends keyof Obj[A][B][C] + D extends keyof Obj[A][B][C], >(obj: Obj, path: [A, B, C, D]): Obj[A][B][C][D]; export function getPath< Obj extends Template, A extends keyof Obj, B extends keyof Obj[A], - C extends keyof Obj[A][B] + C extends keyof Obj[A][B], >(obj: Obj, path: [A, B, C]): Obj[A][B][C]; export function getPath< Obj extends Template, A extends keyof Obj, - B extends keyof Obj[A] + B extends keyof Obj[A], >(obj: Obj, path: [A, B]): Obj[A][B]; export function getPath( obj: Obj, diff --git a/packages/jest-environment-jsdom/src/index.ts b/packages/jest-environment-jsdom/src/index.ts index 421370bcf628..e9e508f6e49d 100644 --- a/packages/jest-environment-jsdom/src/index.ts +++ b/packages/jest-environment-jsdom/src/index.ts @@ -38,8 +38,8 @@ class JSDOMEnvironment implements JestEnvironment { virtualConsole: new VirtualConsole().sendTo(options?.console || console), ...config.testEnvironmentOptions, }); - const global = (this.global = (this.dom.window.document - .defaultView as unknown) as Win); + const global = (this.global = this.dom.window.document + .defaultView as unknown as Win); if (!global) { throw new Error('JSDOM did not return a Window object'); diff --git a/packages/jest-fake-timers/src/__tests__/legacyFakeTimers.test.ts b/packages/jest-fake-timers/src/__tests__/legacyFakeTimers.test.ts index 55fb8c75567a..d5fec2bae04f 100644 --- a/packages/jest-fake-timers/src/__tests__/legacyFakeTimers.test.ts +++ b/packages/jest-fake-timers/src/__tests__/legacyFakeTimers.test.ts @@ -31,7 +31,7 @@ describe('FakeTimers', () => { describe('construction', () => { it('installs setTimeout mock', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -43,7 +43,7 @@ describe('FakeTimers', () => { }); it('accepts to promisify setTimeout mock', async () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -57,7 +57,7 @@ describe('FakeTimers', () => { }); it('installs clearTimeout mock', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -69,7 +69,7 @@ describe('FakeTimers', () => { }); it('installs setInterval mock', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -81,7 +81,7 @@ describe('FakeTimers', () => { }); it('installs clearInterval mock', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -94,11 +94,11 @@ describe('FakeTimers', () => { it('mocks process.nextTick if it exists on global', () => { const origNextTick = () => {}; - const global = ({ + const global = { process: { nextTick: origNextTick, }, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -111,10 +111,10 @@ describe('FakeTimers', () => { it('mocks setImmediate if it exists on global', () => { const origSetImmediate = () => {}; - const global = ({ + const global = { process, setImmediate: origSetImmediate, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -128,11 +128,11 @@ describe('FakeTimers', () => { it('mocks clearImmediate if setImmediate is on global', () => { const origSetImmediate = () => {}; const origClearImmediate = () => {}; - const global = ({ + const global = { clearImmediate: origClearImmediate, process, setImmediate: origSetImmediate, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -146,11 +146,11 @@ describe('FakeTimers', () => { describe('runAllTicks', () => { it('runs all ticks, in order', () => { - const global = ({ + const global = { process: { nextTick: () => {}, }, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -179,11 +179,11 @@ describe('FakeTimers', () => { it('does nothing when no ticks have been scheduled', () => { const nextTick = jest.fn(); - const global = ({ + const global = { process: { nextTick, }, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -198,11 +198,11 @@ describe('FakeTimers', () => { }); it('only runs a scheduled callback once', () => { - const global = ({ + const global = { process: { nextTick: () => {}, }, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -226,11 +226,11 @@ describe('FakeTimers', () => { it('cancels a callback even from native nextTick', () => { const nativeNextTick = jest.fn(); - const global = ({ + const global = { process: { nextTick: nativeNextTick, }, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -255,10 +255,10 @@ describe('FakeTimers', () => { it('cancels a callback even from native setImmediate', () => { const nativeSetImmediate = jest.fn(); - const global = ({ + const global = { process, setImmediate: nativeSetImmediate, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -282,11 +282,11 @@ describe('FakeTimers', () => { it('doesnt run a tick callback if native nextTick already did', () => { const nativeNextTick = jest.fn(); - const global = ({ + const global = { process: { nextTick: nativeNextTick, }, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -311,10 +311,10 @@ describe('FakeTimers', () => { it('doesnt run immediate if native setImmediate already did', () => { const nativeSetImmediate = jest.fn(); - const global = ({ + const global = { process, setImmediate: nativeSetImmediate, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -339,10 +339,10 @@ describe('FakeTimers', () => { it('native doesnt run immediate if fake already did', () => { const nativeSetImmediate = jest.fn(); - const global = ({ + const global = { process, setImmediate: nativeSetImmediate, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -366,11 +366,11 @@ describe('FakeTimers', () => { }); it('throws before allowing infinite recursion', () => { - const global = ({ + const global = { process: { nextTick: () => {}, }, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -399,7 +399,7 @@ describe('FakeTimers', () => { describe('runAllTimers', () => { it('runs all timers in order', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -459,10 +459,10 @@ describe('FakeTimers', () => { it('does nothing when no timers have been scheduled', () => { const nativeSetTimeout = jest.fn(); - const global = ({ + const global = { process, setTimeout: nativeSetTimeout, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -475,7 +475,7 @@ describe('FakeTimers', () => { }); it('only runs a setTimeout callback once (ever)', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -496,7 +496,7 @@ describe('FakeTimers', () => { }); it('runs callbacks with arguments after the interval', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -516,10 +516,10 @@ describe('FakeTimers', () => { it('doesnt pass the callback to native setTimeout', () => { const nativeSetTimeout = jest.fn(); - const global = ({ + const global = { process, setTimeout: nativeSetTimeout, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -538,7 +538,7 @@ describe('FakeTimers', () => { }); it('throws before allowing infinite recursion', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -563,7 +563,7 @@ describe('FakeTimers', () => { }); it('also clears ticks', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -585,7 +585,7 @@ describe('FakeTimers', () => { describe('advanceTimersByTime', () => { it('runs timers in order', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -629,7 +629,7 @@ describe('FakeTimers', () => { }); it('does nothing when no timers have been scheduled', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -641,7 +641,7 @@ describe('FakeTimers', () => { timers.advanceTimersByTime(100); }); it('throws before allowing infinite recursion', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -668,7 +668,7 @@ describe('FakeTimers', () => { describe('advanceTimersToNextTimer', () => { it('runs timers in order', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -708,7 +708,7 @@ describe('FakeTimers', () => { }); it('run correct amount of steps', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -747,7 +747,7 @@ describe('FakeTimers', () => { }); it('setTimeout inside setTimeout', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -775,7 +775,7 @@ describe('FakeTimers', () => { }); it('does nothing when no timers have been scheduled', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -790,7 +790,7 @@ describe('FakeTimers', () => { describe('reset', () => { it('resets all pending setTimeouts', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -808,7 +808,7 @@ describe('FakeTimers', () => { }); it('resets all pending setIntervals', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -826,12 +826,12 @@ describe('FakeTimers', () => { }); it('resets all pending ticks callbacks & immediates', () => { - const global = ({ + const global = { process: { nextTick: () => {}, }, setImmediate: () => {}, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -851,7 +851,7 @@ describe('FakeTimers', () => { }); it('resets current advanceTimersByTime time cursor', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -876,10 +876,10 @@ describe('FakeTimers', () => { it('runs all timers in order', () => { const nativeSetImmediate = jest.fn(); - const global = ({ + const global = { process, setImmediate: nativeSetImmediate, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, @@ -933,7 +933,7 @@ describe('FakeTimers', () => { }); it('does not run timers that were cleared in another timer', () => { - const global = ({process} as unknown) as NodeJS.Global; + const global = {process} as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -960,13 +960,13 @@ describe('FakeTimers', () => { const nativeSetInterval = jest.fn(); const nativeSetTimeout = jest.fn(); - const global = ({ + const global = { clearInterval: nativeClearInterval, clearTimeout: nativeClearTimeout, process, setInterval: nativeSetInterval, setTimeout: nativeSetTimeout, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -1010,13 +1010,13 @@ describe('FakeTimers', () => { const nativeSetInterval = jest.fn(); const nativeSetTimeout = jest.fn(); - const global = ({ + const global = { clearInterval: nativeClearInterval, clearTimeout: nativeClearTimeout, process, setInterval: nativeSetInterval, setTimeout: nativeSetTimeout, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -1072,10 +1072,10 @@ describe('FakeTimers', () => { it('resets mock timer functions even if callback throws', () => { const nativeSetTimeout = jest.fn(); - const global = ({ + const global = { process, setTimeout: nativeSetTimeout, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -1106,13 +1106,13 @@ describe('FakeTimers', () => { const nativeClearTimeout = jest.fn(); const nativeClearInterval = jest.fn(); - const global = ({ + const global = { clearInterval: nativeClearInterval, clearTimeout: nativeClearTimeout, process, setInterval: nativeSetInterval, setTimeout: nativeSetTimeout, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -1139,9 +1139,9 @@ describe('FakeTimers', () => { it('resets native process.nextTick when present', () => { const nativeProcessNextTick = jest.fn(); - const global = ({ + const global = { process: {nextTick: nativeProcessNextTick}, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -1163,11 +1163,11 @@ describe('FakeTimers', () => { const nativeSetImmediate = jest.fn(); const nativeClearImmediate = jest.fn(); - const global = ({ + const global = { clearImmediate: nativeClearImmediate, process, setImmediate: nativeSetImmediate, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -1195,13 +1195,13 @@ describe('FakeTimers', () => { const nativeClearTimeout = jest.fn(); const nativeClearInterval = jest.fn(); - const global = ({ + const global = { clearInterval: nativeClearInterval, clearTimeout: nativeClearTimeout, process, setInterval: nativeSetInterval, setTimeout: nativeSetTimeout, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -1228,9 +1228,9 @@ describe('FakeTimers', () => { it('resets mock process.nextTick when present', () => { const nativeProcessNextTick = jest.fn(); - const global = ({ + const global = { process: {nextTick: nativeProcessNextTick}, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const timers = new FakeTimers({ config, global, @@ -1252,11 +1252,11 @@ describe('FakeTimers', () => { const nativeSetImmediate = jest.fn(); const nativeClearImmediate = jest.fn(); - const global = ({ + const global = { clearImmediate: nativeClearImmediate, process, setImmediate: nativeSetImmediate, - } as unknown) as NodeJS.Global; + } as unknown as NodeJS.Global; const fakeTimers = new FakeTimers({ config, global, diff --git a/packages/jest-haste-map/src/__tests__/dependencyExtractor.js b/packages/jest-haste-map/src/__tests__/dependencyExtractor.js index fb82ce7109e3..1a8767af5920 100644 --- a/packages/jest-haste-map/src/__tests__/dependencyExtractor.js +++ b/packages/jest-haste-map/src/__tests__/dependencyExtractor.js @@ -9,7 +9,8 @@ const blockCommentRe = /\/\*[^]*?\*\//g; const lineCommentRe = /\/\/.*/g; -const LOAD_MODULE_RE = /(?:^|[^.]\s*)(\bloadModule\s*?\(\s*?)([`'"])([^`'"]+)(\2\s*?\))/g; +const LOAD_MODULE_RE = + /(?:^|[^.]\s*)(\bloadModule\s*?\(\s*?)([`'"])([^`'"]+)(\2\s*?\))/g; export function extract(code, filePath, defaultDependencyExtractor) { const dependencies = defaultDependencyExtractor(code); diff --git a/packages/jest-haste-map/src/__tests__/index.test.js b/packages/jest-haste-map/src/__tests__/index.test.js index d400e73cbe68..c95ed070998f 100644 --- a/packages/jest-haste-map/src/__tests__/index.test.js +++ b/packages/jest-haste-map/src/__tests__/index.test.js @@ -179,10 +179,7 @@ describe('HasteMap', () => { // Melon! `, [path.join('/', 'project', 'video', 'video.mp4')]: Buffer.from([ - 0xfa, - 0xce, - 0xb0, - 0x0c, + 0xfa, 0xce, 0xb0, 0x0c, ]).toString(), }); mockClocks = createMap({ @@ -1100,11 +1097,8 @@ describe('HasteMap', () => { g: createMap({ [path.join('fruits', 'Strawberry.js')]: H.MODULE, [path.join('fruits', 'another', 'Strawberry.js')]: H.MODULE, - [path.join( - 'fruits', - 'strawberryPackage', - 'package.json', - )]: H.PACKAGE, + [path.join('fruits', 'strawberryPackage', 'package.json')]: + H.PACKAGE, }), }), }), @@ -1635,9 +1629,8 @@ describe('HasteMap', () => { moduleMap.getModule('Pear'); throw new Error('should be unreachable'); } catch (error) { - const { - DuplicateHasteCandidatesError, - } = require('../ModuleMap').default; + const {DuplicateHasteCandidatesError} = + require('../ModuleMap').default; expect(error).toBeInstanceOf(DuplicateHasteCandidatesError); expect(error.hasteName).toBe('Pear'); expect(error.platform).toBe('g'); @@ -1645,13 +1638,8 @@ describe('HasteMap', () => { expect(error.duplicatesSet).toEqual( createMap({ [path.join('/', 'project', 'fruits', 'Pear.js')]: H.MODULE, - [path.join( - '/', - 'project', - 'fruits', - 'another', - 'Pear.js', - )]: H.MODULE, + [path.join('/', 'project', 'fruits', 'another', 'Pear.js')]: + H.MODULE, }), ); expect(wrap(error.message.replace(/\\/g, '/'))).toMatchSnapshot(); @@ -1693,9 +1681,8 @@ describe('HasteMap', () => { hm_it('recovers when the most recent duplicate is fixed', async hm => { await setupDuplicates(hm); - mockFs[ - path.join('/', 'project', 'fruits', 'another', 'Pear.js') - ] = null; + mockFs[path.join('/', 'project', 'fruits', 'another', 'Pear.js')] = + null; mockFs[path.join('/', 'project', 'fruits', 'another', 'Pear2.js')] = ` // Pear too! `; diff --git a/packages/jest-haste-map/src/__tests__/worker.test.js b/packages/jest-haste-map/src/__tests__/worker.test.js index 8412161dc931..20326d12541d 100644 --- a/packages/jest-haste-map/src/__tests__/worker.test.js +++ b/packages/jest-haste-map/src/__tests__/worker.test.js @@ -28,14 +28,7 @@ jest.mock('graceful-fs', () => { // Strawberry! `, [path.join('/project', 'fruits', 'apple.png')]: Buffer.from([ - 137, - 80, - 78, - 71, - 13, - 10, - 26, - 10, + 137, 80, 78, 71, 13, 10, 26, 10, ]), [path.join('/project', 'package.json')]: ` { diff --git a/packages/jest-haste-map/src/crawlers/node.ts b/packages/jest-haste-map/src/crawlers/node.ts index 075498c4702a..58fc9ccf442d 100644 --- a/packages/jest-haste-map/src/crawlers/node.ts +++ b/packages/jest-haste-map/src/crawlers/node.ts @@ -199,9 +199,7 @@ function findNative( }); } -export = async function nodeCrawl( - options: CrawlerOptions, -): Promise<{ +export = async function nodeCrawl(options: CrawlerOptions): Promise<{ removedFiles: FileData; hasteMap: InternalHasteMap; }> { diff --git a/packages/jest-haste-map/src/crawlers/watchman.ts b/packages/jest-haste-map/src/crawlers/watchman.ts index 372f76550f6d..9b20f42e5597 100644 --- a/packages/jest-haste-map/src/crawlers/watchman.ts +++ b/packages/jest-haste-map/src/crawlers/watchman.ts @@ -57,9 +57,7 @@ function WatchmanError(error: Error): Error { return error; } -export = async function watchmanCrawl( - options: CrawlerOptions, -): Promise<{ +export = async function watchmanCrawl(options: CrawlerOptions): Promise<{ changedFiles?: FileData; removedFiles: FileData; hasteMap: InternalHasteMap; diff --git a/packages/jest-haste-map/src/watchers/RecrawlWarning.js b/packages/jest-haste-map/src/watchers/RecrawlWarning.js index 6596efd3fec9..6719fd8278ec 100644 --- a/packages/jest-haste-map/src/watchers/RecrawlWarning.js +++ b/packages/jest-haste-map/src/watchers/RecrawlWarning.js @@ -50,6 +50,7 @@ class RecrawlWarning { } RecrawlWarning.RECRAWL_WARNINGS = []; -RecrawlWarning.REGEXP = /Recrawled this watch (\d+) times, most recently because:\n([^:]+)/; +RecrawlWarning.REGEXP = + /Recrawled this watch (\d+) times, most recently because:\n([^:]+)/; module.exports = RecrawlWarning; diff --git a/packages/jest-jasmine2/src/errorOnPrivate.ts b/packages/jest-jasmine2/src/errorOnPrivate.ts index 7cf3ce070191..1ffe1f0d081c 100644 --- a/packages/jest-jasmine2/src/errorOnPrivate.ts +++ b/packages/jest-jasmine2/src/errorOnPrivate.ts @@ -50,9 +50,9 @@ export function installErrorOnPrivate(global: Global.Global): void { }, ); - (Object.keys( - disabledJasmineMethods, - ) as Array).forEach(methodName => { + ( + Object.keys(disabledJasmineMethods) as Array + ).forEach(methodName => { // @ts-expect-error jasmine[methodName] = () => { throwAtFunction(disabledJasmineMethods[methodName], jasmine[methodName]); diff --git a/packages/jest-jasmine2/src/index.ts b/packages/jest-jasmine2/src/index.ts index 16ef3cb3c6fe..efd1b01c30ec 100644 --- a/packages/jest-jasmine2/src/index.ts +++ b/packages/jest-jasmine2/src/index.ts @@ -31,9 +31,10 @@ export default async function jasmine2( testPath: string, ): Promise { const reporter = new JasmineReporter(globalConfig, config, testPath); - const jasmineFactory = runtime.requireInternalModule< - typeof import('./jasmine/jasmineLight') - >(JASMINE); + const jasmineFactory = + runtime.requireInternalModule( + JASMINE, + ); const jasmine = jasmineFactory.create({ process, testPath, @@ -66,7 +67,7 @@ export default async function jasmine2( return it; }; - return (wrapped as any) as T; + return wrapped as any as T; } environment.global.it = wrapIt(environment.global.it); diff --git a/packages/jest-jasmine2/src/queueRunner.ts b/packages/jest-jasmine2/src/queueRunner.ts index 08087d2569a4..4dcf02f15e17 100644 --- a/packages/jest-jasmine2/src/queueRunner.ts +++ b/packages/jest-jasmine2/src/queueRunner.ts @@ -33,9 +33,7 @@ export type QueueableFn = { type PromiseCallback = (() => void | PromiseLike) | undefined | null; -export default function queueRunner( - options: Options, -): PromiseLike & { +export default function queueRunner(options: Options): PromiseLike & { cancel: () => void; catch: (onRejected?: PromiseCallback) => Promise; } { diff --git a/packages/jest-jasmine2/src/treeProcessor.ts b/packages/jest-jasmine2/src/treeProcessor.ts index c1d5498a4bf5..59d40680a232 100644 --- a/packages/jest-jasmine2/src/treeProcessor.ts +++ b/packages/jest-jasmine2/src/treeProcessor.ts @@ -26,13 +26,8 @@ export type TreeNode = { } & Pick; export default function treeProcessor(options: Options): void { - const { - nodeComplete, - nodeStart, - queueRunnerFactory, - runnableIds, - tree, - } = options; + const {nodeComplete, nodeStart, queueRunnerFactory, runnableIds, tree} = + options; function isEnabled(node: TreeNode, parentEnabled: boolean) { return parentEnabled || runnableIds.indexOf(node.id) !== -1; diff --git a/packages/jest-leak-detector/tsconfig.json b/packages/jest-leak-detector/tsconfig.json index 02131be76e97..af22aef220ca 100644 --- a/packages/jest-leak-detector/tsconfig.json +++ b/packages/jest-leak-detector/tsconfig.json @@ -4,8 +4,5 @@ "rootDir": "src", "outDir": "build" }, - "references": [ - {"path": "../jest-get-type"}, - {"path": "../pretty-format"} - ] + "references": [{"path": "../jest-get-type"}, {"path": "../pretty-format"}] } diff --git a/packages/jest-matcher-utils/src/deepCyclicCopyReplaceable.ts b/packages/jest-matcher-utils/src/deepCyclicCopyReplaceable.ts index 9c3dd0ac9d26..69fb84011e50 100644 --- a/packages/jest-matcher-utils/src/deepCyclicCopyReplaceable.ts +++ b/packages/jest-matcher-utils/src/deepCyclicCopyReplaceable.ts @@ -49,7 +49,7 @@ export default function deepCyclicCopyReplaceable( } else if (isBuiltInObject(value)) { return value; } else if (plugins.DOMElement.test(value)) { - return (((value as unknown) as Element).cloneNode(true) as unknown) as T; + return (value as unknown as Element).cloneNode(true) as unknown as T; } else { return deepCyclicCopyObject(value, cycles); } diff --git a/packages/jest-matcher-utils/src/index.ts b/packages/jest-matcher-utils/src/index.ts index 81352f37951a..84aca72cd345 100644 --- a/packages/jest-matcher-utils/src/index.ts +++ b/packages/jest-matcher-utils/src/index.ts @@ -359,15 +359,13 @@ export const printDiffOrStringify = ( } if (isLineDiffable(expected, received)) { - const { - replacedExpected, - replacedReceived, - } = replaceMatchedToAsymmetricMatcher( - deepCyclicCopyReplaceable(expected), - deepCyclicCopyReplaceable(received), - [], - [], - ); + const {replacedExpected, replacedReceived} = + replaceMatchedToAsymmetricMatcher( + deepCyclicCopyReplaceable(expected), + deepCyclicCopyReplaceable(received), + [], + [], + ); const difference = diffDefault(replacedExpected, replacedReceived, { aAnnotation: expectedLabel, bAnnotation: receivedLabel, diff --git a/packages/jest-message-util/src/index.ts b/packages/jest-message-util/src/index.ts index d838b86b23fd..25ac49e96936 100644 --- a/packages/jest-message-util/src/index.ts +++ b/packages/jest-message-util/src/index.ts @@ -46,8 +46,10 @@ const PATH_NODE_MODULES = `${path.sep}node_modules${path.sep}`; const PATH_JEST_PACKAGES = `${path.sep}jest${path.sep}packages${path.sep}`; // filter for noisy stack trace lines -const JASMINE_IGNORE = /^\s+at(?:(?:.jasmine\-)|\s+jasmine\.buildExpectationResult)/; -const JEST_INTERNALS_IGNORE = /^\s+at.*?jest(-.*?)?(\/|\\)(build|node_modules|packages)(\/|\\)/; +const JASMINE_IGNORE = + /^\s+at(?:(?:.jasmine\-)|\s+jasmine\.buildExpectationResult)/; +const JEST_INTERNALS_IGNORE = + /^\s+at.*?jest(-.*?)?(\/|\\)(build|node_modules|packages)(\/|\\)/; const ANONYMOUS_FN_IGNORE = /^\s+at .*$/; const ANONYMOUS_PROMISE_IGNORE = /^\s+at (new )?Promise \(\).*$/; const ANONYMOUS_GENERATOR_IGNORE = /^\s+at Generator.next \(\).*$/; diff --git a/packages/jest-message-util/tsconfig.json b/packages/jest-message-util/tsconfig.json index 6c9c16f09f5e..8be65ecb2b1e 100644 --- a/packages/jest-message-util/tsconfig.json +++ b/packages/jest-message-util/tsconfig.json @@ -4,8 +4,5 @@ "rootDir": "src", "outDir": "build" }, - "references": [ - {"path": "../jest-types"}, - {"path": "../pretty-format"} - ] + "references": [{"path": "../jest-types"}, {"path": "../pretty-format"}] } diff --git a/packages/jest-mock/src/index.ts b/packages/jest-mock/src/index.ts index 2ed41294e06b..13f229f76de4 100644 --- a/packages/jest-mock/src/index.ts +++ b/packages/jest-mock/src/index.ts @@ -22,7 +22,7 @@ export type MockFunctionMetadataType = export type MockFunctionMetadata< T, Y extends Array, - Type = MockFunctionMetadataType + Type = MockFunctionMetadataType, > = { ref?: number; members?: Record>; @@ -614,10 +614,10 @@ export class ModuleMocker { return finalReturnValue; }, metadata.length || 0); - const f = (this._createMockFunction( + const f = this._createMockFunction( metadata, mockConstructor, - ) as unknown) as Mock; + ) as unknown as Mock; f._isMockFunction = true; f.getMockImplementation = () => this._ensureMockConfig(f).mockImpl; diff --git a/packages/jest-repl/src/cli/runtime-cli.ts b/packages/jest-repl/src/cli/runtime-cli.ts index c9941eb065f6..3c29fe7ef145 100644 --- a/packages/jest-repl/src/cli/runtime-cli.ts +++ b/packages/jest-repl/src/cli/runtime-cli.ts @@ -75,9 +75,8 @@ export async function run( }); const transformer = await createScriptTransformer(config); - const Environment: typeof JestEnvironment = await transformer.requireAndTranspileModule( - config.testEnvironment, - ); + const Environment: typeof JestEnvironment = + await transformer.requireAndTranspileModule(config.testEnvironment); const environment = new Environment(config); setGlobal( diff --git a/packages/jest-reporters/src/CoverageReporter.ts b/packages/jest-reporters/src/CoverageReporter.ts index 1883b39861e4..f7428a383bef 100644 --- a/packages/jest-reporters/src/CoverageReporter.ts +++ b/packages/jest-reporters/src/CoverageReporter.ts @@ -236,9 +236,11 @@ export default class CoverageReporter extends BaseReporter { thresholds: Config.CoverageThresholdValue, actuals: istanbulCoverage.CoverageSummaryData, ) { - return (['statements', 'branches', 'lines', 'functions'] as Array< - keyof istanbulCoverage.CoverageSummaryData - >).reduce>((errors, key) => { + return ( + ['statements', 'branches', 'lines', 'functions'] as Array< + keyof istanbulCoverage.CoverageSummaryData + > + ).reduce>((errors, key) => { const actual = actuals[key].pct; const actualUncovered = actuals[key].total - actuals[key].covered; const threshold = thresholds[key]; diff --git a/packages/jest-reporters/src/SummaryReporter.ts b/packages/jest-reporters/src/SummaryReporter.ts index 1064e759da21..1ed316dbd53b 100644 --- a/packages/jest-reporters/src/SummaryReporter.ts +++ b/packages/jest-reporters/src/SummaryReporter.ts @@ -44,11 +44,8 @@ const NPM_EVENTS = new Set([ 'postrestart', ]); -const { - npm_config_user_agent, - npm_lifecycle_event, - npm_lifecycle_script, -} = process.env; +const {npm_config_user_agent, npm_lifecycle_event, npm_lifecycle_script} = + process.env; export default class SummaryReporter extends BaseReporter { private _estimatedTime: number; diff --git a/packages/jest-runner/src/runTest.ts b/packages/jest-runner/src/runTest.ts index 2f1b89d7cf3a..a4c3677ba6b7 100644 --- a/packages/jest-runner/src/runTest.ts +++ b/packages/jest-runner/src/runTest.ts @@ -106,12 +106,12 @@ async function runTestInternal( const cacheFS = new Map([[path, testSource]]); const transformer = await createScriptTransformer(config, cacheFS); - const TestEnvironment: typeof JestEnvironment = await transformer.requireAndTranspileModule( - testEnvironment, - ); - const testFramework: TestFramework = await transformer.requireAndTranspileModule( - process.env.JEST_JASMINE === '1' ? 'jest-jasmine2' : config.testRunner, - ); + const TestEnvironment: typeof JestEnvironment = + await transformer.requireAndTranspileModule(testEnvironment); + const testFramework: TestFramework = + await transformer.requireAndTranspileModule( + process.env.JEST_JASMINE === '1' ? 'jest-jasmine2' : config.testRunner, + ); const Runtime: typeof RuntimeClass = interopRequireDefault( config.moduleLoader ? require(config.moduleLoader) diff --git a/packages/jest-runtime/src/__tests__/Runtime-statics.test.js b/packages/jest-runtime/src/__tests__/Runtime-statics.test.js index a198c99051e9..34d640f1cd97 100644 --- a/packages/jest-runtime/src/__tests__/Runtime-statics.test.js +++ b/packages/jest-runtime/src/__tests__/Runtime-statics.test.js @@ -37,7 +37,8 @@ describe('Runtime statics', () => { Runtime.createHasteMap(projectConfig, {...options, watch: true}); expect(HasteMap).toBeCalledWith( expect.objectContaining({ - ignorePattern: /\/root\/ignore-1|\/root\/ignore-2|\/watch-root\/ignore-1/, + ignorePattern: + /\/root\/ignore-1|\/root\/ignore-2|\/watch-root\/ignore-1/, watch: true, }), ); diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 0838e25d5b5c..759b66bb39b5 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -833,9 +833,8 @@ export default class Runtime { text, ); - localModule.exports = this._environment.global.JSON.parse( - transformedFile, - ); + localModule.exports = + this._environment.global.JSON.parse(transformedFile); } else if (path.extname(modulePath) === '.node') { localModule.exports = require(modulePath); } else { @@ -951,7 +950,8 @@ export default class Runtime { if (!this._v8CoverageInstrumenter) { throw new Error('You need to call `collectV8Coverage` first.'); } - this._v8CoverageResult = await this._v8CoverageInstrumenter.stopInstrumenting(); + this._v8CoverageResult = + await this._v8CoverageInstrumenter.stopInstrumenting(); } getAllCoverageInfoCopy(): JestEnvironment['global']['__coverage__'] { @@ -1233,9 +1233,8 @@ export default class Runtime { return source; } - let transformedFile: TransformResult | undefined = this._fileTransforms.get( - filename, - ); + let transformedFile: TransformResult | undefined = + this._fileTransforms.get(filename); if (transformedFile) { return transformedFile.code; @@ -1268,9 +1267,8 @@ export default class Runtime { return source; } - let transformedFile: TransformResult | undefined = this._fileTransforms.get( - filename, - ); + let transformedFile: TransformResult | undefined = + this._fileTransforms.get(filename); if (transformedFile) { return transformedFile.code; @@ -1559,10 +1557,12 @@ export default class Runtime { resolve.paths = (moduleName: string) => this._requireResolvePaths(from.filename, moduleName); - const moduleRequire = (options?.isInternalModule - ? (moduleName: string) => - this.requireInternalModule(from.filename, moduleName) - : this.requireModuleOrMock.bind(this, from.filename)) as NodeRequire; + const moduleRequire = ( + options?.isInternalModule + ? (moduleName: string) => + this.requireInternalModule(from.filename, moduleName) + : this.requireModuleOrMock.bind(this, from.filename) + ) as NodeRequire; moduleRequire.extensions = Object.create(null); moduleRequire.resolve = resolve; moduleRequire.cache = (() => { diff --git a/packages/jest-snapshot/src/InlineSnapshots.ts b/packages/jest-snapshot/src/InlineSnapshots.ts index e7a9accaf76e..8652344b49e3 100644 --- a/packages/jest-snapshot/src/InlineSnapshots.ts +++ b/packages/jest-snapshot/src/InlineSnapshots.ts @@ -18,14 +18,16 @@ import type {Config} from '@jest/types'; import type {Frame} from 'jest-message-util'; import {escapeBacktickString} from './utils'; -// @ts-expect-error requireOutside Babel transform -const babelTraverse = (requireOutside( - '@babel/traverse', -) as typeof import('@babel/traverse')).default; -// @ts-expect-error requireOutside Babel transform -const generate = (requireOutside( - '@babel/generator', -) as typeof import('@babel/generator')).default; +// prettier-ignore +const babelTraverse = ( + // @ts-expect-error requireOutside Babel transform + requireOutside('@babel/traverse') as typeof import('@babel/traverse') +).default; +// prettier-ignore +const generate = ( + // @ts-expect-error requireOutside Babel transform + requireOutside('@babel/generator') as typeof import('@babel/generator') +).default; // @ts-expect-error requireOutside Babel transform const {file, templateElement, templateLiteral} = requireOutside( '@babel/types', @@ -130,16 +132,16 @@ const saveSnapshotsForFile = ( } }; -const groupSnapshotsBy = ( - createKey: (inlineSnapshot: InlineSnapshot) => string, -) => (snapshots: Array) => - snapshots.reduce>>( - (object, inlineSnapshot) => { - const key = createKey(inlineSnapshot); - return {...object, [key]: (object[key] || []).concat(inlineSnapshot)}; - }, - {}, - ); +const groupSnapshotsBy = + (createKey: (inlineSnapshot: InlineSnapshot) => string) => + (snapshots: Array) => + snapshots.reduce>>( + (object, inlineSnapshot) => { + const key = createKey(inlineSnapshot); + return {...object, [key]: (object[key] || []).concat(inlineSnapshot)}; + }, + {}, + ); const groupSnapshotsByFrame = groupSnapshotsBy(({frame: {line, column}}) => typeof line === 'number' && typeof column === 'number' @@ -297,64 +299,66 @@ const runPrettier = ( }; // This parser formats snapshots to the correct indentation. -const createFormattingParser = ( - snapshotMatcherNames: Array, - inferredParser: PrettierParserName, -): PrettierCustomParser => (text, parsers, options) => { - // Workaround for https://github.com/prettier/prettier/issues/3150 - options.parser = inferredParser; - - const ast = resolveAst(parsers[inferredParser](text, options)); - babelTraverse(ast, { - CallExpression({node: {arguments: args, callee}}) { - if ( - callee.type !== 'MemberExpression' || - callee.property.type !== 'Identifier' || - !snapshotMatcherNames.includes(callee.property.name) || - !callee.loc || - callee.computed - ) { - return; - } +const createFormattingParser = + ( + snapshotMatcherNames: Array, + inferredParser: PrettierParserName, + ): PrettierCustomParser => + (text, parsers, options) => { + // Workaround for https://github.com/prettier/prettier/issues/3150 + options.parser = inferredParser; + + const ast = resolveAst(parsers[inferredParser](text, options)); + babelTraverse(ast, { + CallExpression({node: {arguments: args, callee}}) { + if ( + callee.type !== 'MemberExpression' || + callee.property.type !== 'Identifier' || + !snapshotMatcherNames.includes(callee.property.name) || + !callee.loc || + callee.computed + ) { + return; + } - let snapshotIndex: number | undefined; - let snapshot: string | undefined; - for (let i = 0; i < args.length; i++) { - const node = args[i]; - if (node.type === 'TemplateLiteral') { - snapshotIndex = i; - snapshot = node.quasis[0].value.raw; + let snapshotIndex: number | undefined; + let snapshot: string | undefined; + for (let i = 0; i < args.length; i++) { + const node = args[i]; + if (node.type === 'TemplateLiteral') { + snapshotIndex = i; + snapshot = node.quasis[0].value.raw; + } + } + if (snapshot === undefined || snapshotIndex === undefined) { + return; } - } - if (snapshot === undefined || snapshotIndex === undefined) { - return; - } - const useSpaces = !options.useTabs; - snapshot = indent( - snapshot, - Math.ceil( - useSpaces - ? callee.loc.start.column / (options.tabWidth ?? 1) - : callee.loc.start.column / 2, // Each tab is 2 characters. - ), - useSpaces ? ' '.repeat(options.tabWidth ?? 1) : '\t', - ); + const useSpaces = !options.useTabs; + snapshot = indent( + snapshot, + Math.ceil( + useSpaces + ? callee.loc.start.column / (options.tabWidth ?? 1) + : callee.loc.start.column / 2, // Each tab is 2 characters. + ), + useSpaces ? ' '.repeat(options.tabWidth ?? 1) : '\t', + ); - const replacementNode = templateLiteral( - [ - templateElement({ - raw: snapshot, - }), - ], - [], - ); - args[snapshotIndex] = replacementNode; - }, - }); + const replacementNode = templateLiteral( + [ + templateElement({ + raw: snapshot, + }), + ], + [], + ); + args[snapshotIndex] = replacementNode; + }, + }); - return ast; -}; + return ast; + }; const simpleDetectParser = (filePath: Config.Path): PrettierParserName => { const extname = path.extname(filePath); diff --git a/packages/jest-snapshot/src/index.ts b/packages/jest-snapshot/src/index.ts index 9aee3860ef2b..3849c7dc4db8 100644 --- a/packages/jest-snapshot/src/index.ts +++ b/packages/jest-snapshot/src/index.ts @@ -279,14 +279,8 @@ const toMatchInlineSnapshot = function ( }; const _toMatchSnapshot = (config: MatchSnapshotConfig) => { - const { - context, - hint, - inlineSnapshot, - isInline, - matcherName, - properties, - } = config; + const {context, hint, inlineSnapshot, isInline, matcherName, properties} = + config; let {received} = config; context.dontThrow && context.dontThrow(); @@ -479,14 +473,8 @@ const _toThrowErrorMatchingSnapshot = ( config: MatchSnapshotConfig, fromPromise?: boolean, ) => { - const { - context, - hint, - inlineSnapshot, - isInline, - matcherName, - received, - } = config; + const {context, hint, inlineSnapshot, isInline, matcherName, received} = + config; context.dontThrow && context.dontThrow(); diff --git a/packages/jest-snapshot/tsconfig.json b/packages/jest-snapshot/tsconfig.json index 8c9e789aa98c..26ace04bd2f0 100644 --- a/packages/jest-snapshot/tsconfig.json +++ b/packages/jest-snapshot/tsconfig.json @@ -12,7 +12,7 @@ {"path": "../jest-matcher-utils"}, {"path": "../jest-message-util"}, {"path": "../jest-resolve"}, - {"path": "../jest-transform" }, + {"path": "../jest-transform"}, {"path": "../jest-types"}, {"path": "../jest-util"}, {"path": "../pretty-format"}, diff --git a/packages/jest-test-result/tsconfig.json b/packages/jest-test-result/tsconfig.json index 4a3022904a19..574a74911579 100644 --- a/packages/jest-test-result/tsconfig.json +++ b/packages/jest-test-result/tsconfig.json @@ -4,8 +4,5 @@ "rootDir": "src", "outDir": "build" }, - "references": [ - {"path": "../jest-console"}, - {"path": "../jest-types"} - ] + "references": [{"path": "../jest-console"}, {"path": "../jest-types"}] } diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index 0cf2de288a88..dca4aa3492ba 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -821,18 +821,19 @@ export async function createTranspilingRequire( resolverPath: string, applyInteropRequireDefault: boolean = false, ) { - const transpiledModule = await transformer.requireAndTranspileModule( - resolverPath, - () => {}, - { - applyInteropRequireDefault, - instrument: false, - supportsDynamicImport: false, // this might be true, depending on node version. - supportsExportNamespaceFrom: false, - supportsStaticESM: false, - supportsTopLevelAwait: false, - }, - ); + const transpiledModule = + await transformer.requireAndTranspileModule( + resolverPath, + () => {}, + { + applyInteropRequireDefault, + instrument: false, + supportsDynamicImport: false, // this might be true, depending on node version. + supportsExportNamespaceFrom: false, + supportsStaticESM: false, + supportsTopLevelAwait: false, + }, + ); return transpiledModule; }; diff --git a/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts b/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts index 0b3dee805b39..29edad4dd816 100644 --- a/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts +++ b/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts @@ -294,8 +294,8 @@ describe('ScriptTransformer', () => { transformIgnorePatterns: ['/node_modules/'], }); - createScriptTransformer = require('../ScriptTransformer') - .createScriptTransformer; + createScriptTransformer = + require('../ScriptTransformer').createScriptTransformer; }; beforeEach(reset); @@ -347,10 +347,11 @@ describe('ScriptTransformer', () => { it('transforms a file async properly', async () => { const scriptTransformer = await createScriptTransformer(config); - const transformedBananaWithCoverage = await scriptTransformer.transformAsync( - '/fruits/banana.js', - getCoverageOptions({collectCoverage: true}), - ); + const transformedBananaWithCoverage = + await scriptTransformer.transformAsync( + '/fruits/banana.js', + getCoverageOptions({collectCoverage: true}), + ); expect(wrap(transformedBananaWithCoverage.code)).toMatchSnapshot(); @@ -359,10 +360,11 @@ describe('ScriptTransformer', () => { expect(fs.readFileSync).toBeCalledWith('/fruits/banana.js', 'utf8'); // in-memory cache - const transformedBananaWithCoverageAgain = await scriptTransformer.transformAsync( - '/fruits/banana.js', - getCoverageOptions({collectCoverage: true}), - ); + const transformedBananaWithCoverageAgain = + await scriptTransformer.transformAsync( + '/fruits/banana.js', + getCoverageOptions({collectCoverage: true}), + ); expect(transformedBananaWithCoverageAgain).toBe( transformedBananaWithCoverage, ); @@ -379,10 +381,11 @@ describe('ScriptTransformer', () => { expect(transformedBananaWithCoverage.code).not.toMatch(/instrumented kiwi/); // If we disable coverage, we get a different result. - const transformedKiwiWithoutCoverage = await scriptTransformer.transformAsync( - '/fruits/kiwi.js', - getCoverageOptions({collectCoverage: false}), - ); + const transformedKiwiWithoutCoverage = + await scriptTransformer.transformAsync( + '/fruits/kiwi.js', + getCoverageOptions({collectCoverage: false}), + ); expect(transformedKiwiWithoutCoverage.code).not.toEqual( transformedKiwiWithCoverage.code, @@ -454,10 +457,9 @@ describe('ScriptTransformer', () => { config = { ...config, - transform: [ - ...incorrectReturnValues, - ...correctReturnValues, - ].map(([_, filePath]) => [filePath, processorName, {}]), + transform: [...incorrectReturnValues, ...correctReturnValues].map( + ([_, filePath]) => [filePath, processorName, {}], + ), }; const scriptTransformer = await createScriptTransformer(config); diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index 49113fa9ce34..5b53f4b637c7 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -40,13 +40,12 @@ export type HasteConfig = { export type CoverageReporterName = keyof ReportOptions; -export type CoverageReporterWithOptions< - K = CoverageReporterName -> = K extends CoverageReporterName - ? ReportOptions[K] extends never - ? never - : [K, Partial] - : never; +export type CoverageReporterWithOptions = + K extends CoverageReporterName + ? ReportOptions[K] extends never + ? never + : [K, Partial] + : never; export type CoverageReporters = Array< CoverageReporterName | CoverageReporterWithOptions diff --git a/packages/jest-util/src/convertDescriptorToString.ts b/packages/jest-util/src/convertDescriptorToString.ts index fbd34948ef1d..6f13d02c1897 100644 --- a/packages/jest-util/src/convertDescriptorToString.ts +++ b/packages/jest-util/src/convertDescriptorToString.ts @@ -9,7 +9,7 @@ // See: https://github.com/facebook/jest/pull/5154 export default function convertDescriptorToString< - T extends number | string | Function | undefined + T extends number | string | Function | undefined, >(descriptor: T): T | string { if ( typeof descriptor === 'string' || diff --git a/packages/jest-util/src/installCommonGlobals.ts b/packages/jest-util/src/installCommonGlobals.ts index 7f3526c8772f..90520a13d91c 100644 --- a/packages/jest-util/src/installCommonGlobals.ts +++ b/packages/jest-util/src/installCommonGlobals.ts @@ -18,7 +18,7 @@ export default function ( ): NodeJS.Global & Config.ConfigGlobals { globalObject.process = createProcessObject(); - const symbol = (globalObject.Symbol as unknown) as SymbolConstructor; + const symbol = globalObject.Symbol as unknown as SymbolConstructor; // Keep a reference to some globals that Jest needs Object.defineProperties(globalObject, { [symbol.for('jest-native-promise')]: { diff --git a/packages/jest-util/tsconfig.json b/packages/jest-util/tsconfig.json index b802dbf5ce24..3046cb6b9b6a 100644 --- a/packages/jest-util/tsconfig.json +++ b/packages/jest-util/tsconfig.json @@ -4,7 +4,5 @@ "rootDir": "src", "outDir": "build" }, - "references": [ - {"path": "../jest-types"} - ] + "references": [{"path": "../jest-types"}] } diff --git a/packages/jest-worker/src/Farm.ts b/packages/jest-worker/src/Farm.ts index 146040c13dd1..1254f1d4565a 100644 --- a/packages/jest-worker/src/Farm.ts +++ b/packages/jest-worker/src/Farm.ts @@ -26,9 +26,8 @@ export default class Farm { private readonly _workerSchedulingPolicy: NonNullable< FarmOptions['workerSchedulingPolicy'] >; - private readonly _cacheKeys: Record = Object.create( - null, - ); + private readonly _cacheKeys: Record = + Object.create(null); private readonly _locks: Array = []; private _offset = 0; private readonly _taskQueue: TaskQueue; diff --git a/packages/jest-worker/src/FifoQueue.ts b/packages/jest-worker/src/FifoQueue.ts index ff9ec1edce73..352daca642be 100644 --- a/packages/jest-worker/src/FifoQueue.ts +++ b/packages/jest-worker/src/FifoQueue.ts @@ -25,9 +25,8 @@ type WorkerQueueValue = { * across the worker specific and shared queue. */ export default class FifoQueue implements TaskQueue { - private _workerQueues: Array< - InternalQueue | undefined - > = []; + private _workerQueues: Array | undefined> = + []; private _sharedQueue = new InternalQueue(); enqueue(task: QueueChildMessage, workerId?: number): void { @@ -38,9 +37,8 @@ export default class FifoQueue implements TaskQueue { let workerQueue = this._workerQueues[workerId]; if (workerQueue == null) { - workerQueue = this._workerQueues[ - workerId - ] = new InternalQueue(); + workerQueue = this._workerQueues[workerId] = + new InternalQueue(); } const sharedTop = this._sharedQueue.peekLast(); diff --git a/packages/jest-worker/src/workers/messageParent.ts b/packages/jest-worker/src/workers/messageParent.ts index 0e65c835a6ab..d4a389055fc0 100644 --- a/packages/jest-worker/src/workers/messageParent.ts +++ b/packages/jest-worker/src/workers/messageParent.ts @@ -10,10 +10,8 @@ import {PARENT_MESSAGE_CUSTOM} from '../types'; const isWorkerThread: boolean = (() => { try { // `Require` here to support Node v10 - const { - isMainThread, - parentPort, - } = require('worker_threads') as typeof import('worker_threads'); + const {isMainThread, parentPort} = + require('worker_threads') as typeof import('worker_threads'); return !isMainThread && parentPort != null; } catch { return false; @@ -26,9 +24,8 @@ export default function messageParent( ): void { if (isWorkerThread) { // `Require` here to support Node v10 - const { - parentPort, - } = require('worker_threads') as typeof import('worker_threads'); + const {parentPort} = + require('worker_threads') as typeof import('worker_threads'); // ! is safe due to `null` check in `isWorkerThread` parentPort!.postMessage([PARENT_MESSAGE_CUSTOM, message]); } else if (typeof parentProcess.send === 'function') { diff --git a/packages/jest/tsconfig.json b/packages/jest/tsconfig.json index f3e9271cd4a7..dd19623b6a88 100644 --- a/packages/jest/tsconfig.json +++ b/packages/jest/tsconfig.json @@ -4,8 +4,5 @@ "rootDir": "src", "outDir": "build" }, - "references": [ - {"path": "../jest-cli"}, - {"path": "../jest-core"} - ] + "references": [{"path": "../jest-cli"}, {"path": "../jest-core"}] } diff --git a/packages/pretty-format/src/__tests__/DOMCollection.test.ts b/packages/pretty-format/src/__tests__/DOMCollection.test.ts index b42c2b6b73db..ad9d89e51a7a 100644 --- a/packages/pretty-format/src/__tests__/DOMCollection.test.ts +++ b/packages/pretty-format/src/__tests__/DOMCollection.test.ts @@ -35,9 +35,10 @@ describe('DOMCollection plugin for object properties', () => { el.setAttribute('name1', 'value1'); el.setAttribute('name2', 'value2'); - expect( - el.attributes, - ).toPrettyPrintTo('{"name1": "value1", "name2": "value2"}', {min: true}); + expect(el.attributes).toPrettyPrintTo( + '{"name1": "value1", "name2": "value2"}', + {min: true}, + ); }); }); diff --git a/packages/pretty-format/src/__tests__/Immutable.test.ts b/packages/pretty-format/src/__tests__/Immutable.test.ts index 7fe9925adf36..9b9ffdc6538e 100644 --- a/packages/pretty-format/src/__tests__/Immutable.test.ts +++ b/packages/pretty-format/src/__tests__/Immutable.test.ts @@ -41,15 +41,17 @@ describe('Immutable.OrderedSet', () => { }); it('supports a single string element', () => { - expect( - Immutable.OrderedSet(['foo']), - ).toPrettyPrintTo('Immutable.OrderedSet ["foo"]', {min: true}); + expect(Immutable.OrderedSet(['foo'])).toPrettyPrintTo( + 'Immutable.OrderedSet ["foo"]', + {min: true}, + ); }); it('supports a single integer element', () => { - expect( - Immutable.OrderedSet([1]), - ).toPrettyPrintTo('Immutable.OrderedSet [1]', {min: true}); + expect(Immutable.OrderedSet([1])).toPrettyPrintTo( + 'Immutable.OrderedSet [1]', + {min: true}, + ); }); it('supports multiple string elements {min: true}', () => { @@ -62,18 +64,17 @@ describe('Immutable.OrderedSet', () => { }); it('supports multiple string elements {min: false}', () => { - expect( - Immutable.OrderedSet(['jhon', 'mike', 'cristian']), - ).toPrettyPrintTo( + expect(Immutable.OrderedSet(['jhon', 'mike', 'cristian'])).toPrettyPrintTo( 'Immutable.OrderedSet [\n "jhon",\n "mike",\n "cristian",\n]', {min: false}, ); }); it('supports multiple integer elements {min: true}', () => { - expect( - Immutable.OrderedSet([1, 2, 3]), - ).toPrettyPrintTo('Immutable.OrderedSet [1, 2, 3]', {min: true}); + expect(Immutable.OrderedSet([1, 2, 3])).toPrettyPrintTo( + 'Immutable.OrderedSet [1, 2, 3]', + {min: true}, + ); }); it('supports multiple integer elements {min: false}', () => { @@ -95,9 +96,7 @@ describe('Immutable.OrderedSet', () => { }); it('supports object elements {min: false}', () => { - expect( - Immutable.OrderedSet([{a: 1, b: 2, c: 3}]), - ).toPrettyPrintTo( + expect(Immutable.OrderedSet([{a: 1, b: 2, c: 3}])).toPrettyPrintTo( 'Immutable.OrderedSet [\n Object {\n "a": 1,\n "b": 2,\n "c": 3,\n },\n]', {min: false}, ); @@ -115,9 +114,7 @@ describe('Immutable.OrderedSet', () => { it('supports React elements {min: false}', () => { const reactElement = React.createElement('Mouse', null, 'Hello World'); - expect( - Immutable.OrderedSet([reactElement, reactElement]), - ).toPrettyPrintTo( + expect(Immutable.OrderedSet([reactElement, reactElement])).toPrettyPrintTo( 'Immutable.OrderedSet [\n \n Hello World\n ,\n]', {min: false}, ); @@ -165,9 +162,10 @@ describe('Immutable.List', () => { }); it('supports multiple integer elements {min: true}', () => { - expect( - Immutable.List([1, 2, 3]), - ).toPrettyPrintTo('Immutable.List [1, 2, 3]', {min: true}); + expect(Immutable.List([1, 2, 3])).toPrettyPrintTo( + 'Immutable.List [1, 2, 3]', + {min: true}, + ); }); it('supports multiple integer elements {min: false}', () => { @@ -177,9 +175,10 @@ describe('Immutable.List', () => { }); it('supports object elements {min: true}', () => { - expect( - Immutable.List([{a: 1, b: 2, c: 3}]), - ).toPrettyPrintTo('Immutable.List [{"a": 1, "b": 2, "c": 3}]', {min: true}); + expect(Immutable.List([{a: 1, b: 2, c: 3}])).toPrettyPrintTo( + 'Immutable.List [{"a": 1, "b": 2, "c": 3}]', + {min: true}, + ); }); it('supports object elements {min: false}', () => { @@ -190,9 +189,7 @@ describe('Immutable.List', () => { it('supports React elements {min: true}', () => { const reactElement = React.createElement('Mouse', null, 'Hello World'); - expect( - Immutable.List([reactElement, reactElement]), - ).toPrettyPrintTo( + expect(Immutable.List([reactElement, reactElement])).toPrettyPrintTo( 'Immutable.List [Hello World, Hello World]', {min: true}, ); @@ -248,9 +245,10 @@ describe('Immutable.Stack', () => { }); it('supports multiple integer elements {min: true}', () => { - expect( - Immutable.Stack([1, 2, 3]), - ).toPrettyPrintTo('Immutable.Stack [1, 2, 3]', {min: true}); + expect(Immutable.Stack([1, 2, 3])).toPrettyPrintTo( + 'Immutable.Stack [1, 2, 3]', + {min: true}, + ); }); it('supports multiple integer elements {min: false}', () => { @@ -276,9 +274,7 @@ describe('Immutable.Stack', () => { it('supports React elements {min: true}', () => { const reactElement = React.createElement('Mouse', null, 'Hello World'); - expect( - Immutable.Stack([reactElement, reactElement]), - ).toPrettyPrintTo( + expect(Immutable.Stack([reactElement, reactElement])).toPrettyPrintTo( 'Immutable.Stack [Hello World, Hello World]', {min: true}, ); @@ -344,9 +340,10 @@ describe('Immutable.Set', () => { }); it('supports object elements {min: true}', () => { - expect( - Immutable.Set([{a: 1, b: 2, c: 3}]), - ).toPrettyPrintTo('Immutable.Set [{"a": 1, "b": 2, "c": 3}]', {min: true}); + expect(Immutable.Set([{a: 1, b: 2, c: 3}])).toPrettyPrintTo( + 'Immutable.Set [{"a": 1, "b": 2, "c": 3}]', + {min: true}, + ); }); it('supports object elements {min: false}', () => { @@ -391,9 +388,10 @@ describe('Immutable.Map', () => { }); it('supports an object with multiple keys {min: true}', () => { - expect( - Immutable.Map({a: 1, b: 2, c: 3}), - ).toPrettyPrintTo('Immutable.Map {"a": 1, "b": 2, "c": 3}', {min: true}); + expect(Immutable.Map({a: 1, b: 2, c: 3})).toPrettyPrintTo( + 'Immutable.Map {"a": 1, "b": 2, "c": 3}', + {min: true}, + ); }); it('supports an object with multiple keys {min: false}', () => { @@ -419,9 +417,7 @@ describe('Immutable.Map', () => { it('supports React elements {min: true}', () => { const reactElement = React.createElement('Mouse', null, 'Hello World'); - expect( - Immutable.Map({a: reactElement, b: reactElement}), - ).toPrettyPrintTo( + expect(Immutable.Map({a: reactElement, b: reactElement})).toPrettyPrintTo( 'Immutable.Map {"a": Hello World, "b": Hello World}', {min: true}, ); @@ -451,9 +447,10 @@ describe('Immutable.OrderedMap', () => { }); it('supports an object with single key', () => { - expect( - Immutable.OrderedMap({a: 1}), - ).toPrettyPrintTo('Immutable.OrderedMap {"a": 1}', {min: true}); + expect(Immutable.OrderedMap({a: 1})).toPrettyPrintTo( + 'Immutable.OrderedMap {"a": 1}', + {min: true}, + ); }); it('supports an object with multiple keys {min: true}', () => { @@ -585,9 +582,10 @@ describe('Immutable.Record', () => { it('supports a record with values {min: true}', () => { const ABRecord = Immutable.Record({a: 1, b: 2}, 'ABRecord'); - expect( - ABRecord({a: 3, b: 4}), - ).toPrettyPrintTo('Immutable.ABRecord {"a": 3, "b": 4}', {min: true}); + expect(ABRecord({a: 3, b: 4})).toPrettyPrintTo( + 'Immutable.ABRecord {"a": 3, "b": 4}', + {min: true}, + ); }); it('supports a record with values {min: false}', () => { @@ -627,9 +625,7 @@ describe('Immutable.Record', () => { const CDRecord = Immutable.Record({c: 3, d: 4}, 'CDRecord'); const ABRecord = Immutable.Record({a: CDRecord(), b: 2}, 'ABRecord'); - expect( - ABRecord(), - ).toPrettyPrintTo( + expect(ABRecord()).toPrettyPrintTo( 'Immutable.ABRecord {"a": Immutable.CDRecord {"c": 3, "d": 4}, "b": 2}', {min: true}, ); @@ -864,9 +860,10 @@ describe('Immutable.Seq', () => { ); }); it('supports a non-empty sequence from array {min: false}', () => { - expect( - Immutable.Seq([0, 1, 2]), - ).toPrettyPrintTo('Immutable.Seq [\n 0,\n 1,\n 2,\n]', {min: false}); + expect(Immutable.Seq([0, 1, 2])).toPrettyPrintTo( + 'Immutable.Seq [\n 0,\n 1,\n 2,\n]', + {min: false}, + ); }); it('supports a non-empty sequence from arguments', () => { diff --git a/scripts/build.js b/scripts/build.js index c9d24f7ee00f..653e0cfa24de 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -37,7 +37,8 @@ const TS_FILES_PATTERN = '**/*.ts'; const IGNORE_PATTERN = '**/__{tests,mocks}__/**'; const PACKAGES_DIR = path.resolve(__dirname, '../packages'); -const INLINE_REQUIRE_EXCLUDE_LIST = /packages\/expect|(jest-(circus|diff|get-type|jasmine2|matcher-utils|message-util|regex-util|snapshot))|pretty-format\//; +const INLINE_REQUIRE_EXCLUDE_LIST = + /packages\/expect|(jest-(circus|diff|get-type|jasmine2|matcher-utils|message-util|regex-util|snapshot))|pretty-format\//; const prettierConfig = prettier.resolveConfig.sync(__filename); prettierConfig.trailingComma = 'none'; diff --git a/website/versioned_docs/version-25.x/ManualMocks.md b/website/versioned_docs/version-25.x/ManualMocks.md index cb050dff3127..7d6088e53a2a 100644 --- a/website/versioned_docs/version-25.x/ManualMocks.md +++ b/website/versioned_docs/version-25.x/ManualMocks.md @@ -115,9 +115,8 @@ describe('listFilesInDirectorySync', () => { test('includes all files in the directory in the summary', () => { const FileSummarizer = require('../FileSummarizer'); - const fileSummary = FileSummarizer.summarizeFilesInDirectorySync( - '/path/to', - ); + const fileSummary = + FileSummarizer.summarizeFilesInDirectorySync('/path/to'); expect(fileSummary.length).toBe(2); }); diff --git a/website/versioned_docs/version-26.x/ManualMocks.md b/website/versioned_docs/version-26.x/ManualMocks.md index 2969e49ea170..8835ead766e9 100644 --- a/website/versioned_docs/version-26.x/ManualMocks.md +++ b/website/versioned_docs/version-26.x/ManualMocks.md @@ -115,9 +115,8 @@ describe('listFilesInDirectorySync', () => { test('includes all files in the directory in the summary', () => { const FileSummarizer = require('../FileSummarizer'); - const fileSummary = FileSummarizer.summarizeFilesInDirectorySync( - '/path/to', - ); + const fileSummary = + FileSummarizer.summarizeFilesInDirectorySync('/path/to'); expect(fileSummary.length).toBe(2); }); diff --git a/yarn.lock b/yarn.lock index 43a9d0731c7b..59642888f96d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17578,11 +17578,11 @@ fsevents@^1.2.7: linkType: hard "prettier@npm:^2.0.0, prettier@npm:^2.0.1, prettier@npm:^2.1.1": - version: 2.2.1 - resolution: "prettier@npm:2.2.1" + version: 2.3.0 + resolution: "prettier@npm:2.3.0" bin: prettier: bin-prettier.js - checksum: 92c6c9f4b87eba1f28466edee57dd18c80d00b858edda77d46d1950d20e6e302b68ee255fc91133ba931e63c4577b5ae30da194d9626a8f3c0177778b91bf056 + checksum: 652640cc8b71bc5277cfb8bf6f161783ca588efcf683c3d630837b39da8d57fef35c9e00ae5855a8e3c75136c42274046c913cc2b2d2968558315f31c6a26981 languageName: node linkType: hard