mirror of https://github.com/facebook/jest.git
chore: update prettier to 2.3 (#11397)
This commit is contained in:
parent
c28e485a5e
commit
0a902e10e0
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
21
e2e/Utils.ts
21
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<unknown>) => 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<unknown>) => 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<RegExpExecArray> = [];
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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 }});
|
||||
});
|
||||
`);
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
`);
|
||||
|
|
|
@ -5,6 +5,5 @@
|
|||
"browser": {
|
||||
"./nope.js": "./main.js"
|
||||
},
|
||||
"dependencies": {
|
||||
}
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"jest": {
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
"jest": {
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
"jest": {
|
||||
"collectCoverageFrom": ["*.js"],
|
||||
"collectCoverageFrom": [
|
||||
"*.js"
|
||||
],
|
||||
"transform": {},
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
"jest": {
|
||||
"testEnvironment": "node",
|
||||
"globalSetup": "<rootDir>/setup.js",
|
||||
"transformIgnorePatterns": [
|
||||
]
|
||||
"transformIgnorePatterns": []
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
{
|
||||
"jest": {
|
||||
"moduleNameMapper": {
|
||||
"\\.(css|less)$": ["no-such-module", "no-such-module-2"]
|
||||
"\\.(css|less)$": [
|
||||
"no-such-module",
|
||||
"no-such-module-2"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
"name": "native-esm-typescript",
|
||||
"version": "1.0.0",
|
||||
"jest": {
|
||||
"extensionsToTreatAsEsm": [".ts"],
|
||||
"extensionsToTreatAsEsm": [
|
||||
".ts"
|
||||
],
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,4 +3,3 @@
|
|||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"module": "commonjs",
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,29 +38,27 @@ export default class BaseTestRunner {
|
|||
(promise, test) =>
|
||||
mutex(() =>
|
||||
promise
|
||||
.then(
|
||||
async (): Promise<TestResult> => {
|
||||
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<TestResult> => {
|
||||
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)),
|
||||
),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"module": "commonjs",
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"module": "commonjs",
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"jest": {
|
||||
"watchPlugins": ["./my-watch-plugin.cjs"]
|
||||
"watchPlugins": [
|
||||
"./my-watch-plugin.cjs"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
"type": "module",
|
||||
"jest": {
|
||||
"watchPlugins": ["./my-watch-plugin.js"]
|
||||
"watchPlugins": [
|
||||
"./my-watch-plugin.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"jest": {
|
||||
"watchPlugins": ["./my-watch-plugin.js"]
|
||||
"watchPlugins": [
|
||||
"./my-watch-plugin.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"jest": {
|
||||
"watchPlugins": ["./my-watch-plugin.mjs"]
|
||||
"watchPlugins": [
|
||||
"./my-watch-plugin.mjs"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{
|
||||
"version": "27.0.0-next.9",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*"
|
||||
]
|
||||
"packages": ["packages/*"]
|
||||
}
|
||||
|
|
|
@ -8,21 +8,23 @@ jest.mock('./App', () => () => <div>Hello world</div>);
|
|||
|
||||
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";
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -141,101 +141,105 @@ 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<any>,
|
||||
outerErr: JestAssertionError,
|
||||
): PromiseMatcherFn => (...args) => {
|
||||
const options = {
|
||||
isNot,
|
||||
promise: 'resolves',
|
||||
const makeResolveMatcher =
|
||||
(
|
||||
matcherName: string,
|
||||
matcher: RawMatcherFn,
|
||||
isNot: boolean,
|
||||
actual: Promise<any>,
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
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 makeRejectMatcher =
|
||||
(
|
||||
matcherName: string,
|
||||
matcher: RawMatcherFn,
|
||||
isNot: boolean,
|
||||
actual: Promise<any> | (() => Promise<any>),
|
||||
outerErr: JestAssertionError,
|
||||
): PromiseMatcherFn =>
|
||||
(...args) => {
|
||||
const options = {
|
||||
isNot,
|
||||
promise: 'rejects',
|
||||
};
|
||||
|
||||
const actualWrapper: Promise<any> =
|
||||
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 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 makeRejectMatcher = (
|
||||
matcherName: string,
|
||||
matcher: RawMatcherFn,
|
||||
isNot: boolean,
|
||||
actual: Promise<any> | (() => Promise<any>),
|
||||
outerErr: JestAssertionError,
|
||||
): PromiseMatcherFn => (...args) => {
|
||||
const options = {
|
||||
isNot,
|
||||
promise: 'rejects',
|
||||
};
|
||||
|
||||
const actualWrapper: Promise<any> =
|
||||
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 makeThrowingMatcher = (
|
||||
matcher: RawMatcherFn,
|
||||
isNot: boolean,
|
||||
|
|
|
@ -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<object, boolean> = 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]);
|
||||
}
|
||||
seenReferences.set(subset[key], true);
|
||||
const subsetEqualityWithContext =
|
||||
(seenReferences: WeakMap<object, boolean> = new WeakMap()) =>
|
||||
(object: any, subset: any): boolean | undefined => {
|
||||
if (!isObjectWithKeys(subset)) {
|
||||
return undefined;
|
||||
}
|
||||
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 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);
|
||||
}
|
||||
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);
|
||||
};
|
||||
|
|
|
@ -4,7 +4,5 @@
|
|||
"rootDir": "src",
|
||||
"outDir": "build"
|
||||
},
|
||||
"references": [
|
||||
{"path": "../jest-types"}
|
||||
]
|
||||
"references": [{"path": "../jest-types"}]
|
||||
}
|
||||
|
|
|
@ -23,12 +23,10 @@ const jestAdapter = async (
|
|||
testPath: string,
|
||||
sendMessageToJest?: TestFileEvent,
|
||||
): Promise<TestResult> => {
|
||||
const {
|
||||
initialize,
|
||||
runAndTransformResultsToJestFormat,
|
||||
} = runtime.requireInternalModule<typeof import('./jestAdapterInit')>(
|
||||
FRAMEWORK_INITIALIZER,
|
||||
);
|
||||
const {initialize, runAndTransformResultsToJestFormat} =
|
||||
runtime.requireInternalModule<typeof import('./jestAdapterInit')>(
|
||||
FRAMEWORK_INITIALIZER,
|
||||
);
|
||||
|
||||
const {globals, snapshotState} = await initialize({
|
||||
config,
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
@ -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', () => ({
|
||||
|
|
|
@ -35,13 +35,8 @@ const generateConfigFile = (
|
|||
results: Record<string, unknown>,
|
||||
generateEsm = false,
|
||||
): string => {
|
||||
const {
|
||||
useTypescript,
|
||||
coverage,
|
||||
coverageProvider,
|
||||
clearMocks,
|
||||
environment,
|
||||
} = results;
|
||||
const {useTypescript, coverage, coverageProvider, clearMocks, environment} =
|
||||
results;
|
||||
|
||||
const overrides: Record<string, unknown> = {};
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<string, unknown>} {
|
||||
private _getReporterProps(reporter: string | Config.ReporterConfig): {
|
||||
path: string;
|
||||
options: Record<string, unknown>;
|
||||
} {
|
||||
if (typeof reporter === 'string') {
|
||||
return {options: this._options, path: reporter};
|
||||
} else if (Array.isArray(reporter)) {
|
||||
|
|
|
@ -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]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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<AssertionLocation> = [];
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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<keyof ChangedFiles['repos']>
|
||||
).every(scm => repos[scm].size === 0);
|
||||
if (noSCM) {
|
||||
process.stderr.write(
|
||||
'\n' +
|
||||
|
|
|
@ -41,8 +41,6 @@ export type FilterResult = {
|
|||
message: string;
|
||||
};
|
||||
|
||||
export type Filter = (
|
||||
testPaths: Array<string>,
|
||||
) => Promise<{
|
||||
export type Filter = (testPaths: Array<string>) => Promise<{
|
||||
filtered: Array<FilterResult>;
|
||||
}>;
|
||||
|
|
|
@ -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 &&
|
||||
|
|
|
@ -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: {},
|
||||
|
|
|
@ -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<string> = [];
|
||||
|
@ -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
|
||||
|
|
|
@ -29,33 +29,34 @@ type GlobalCallback = (
|
|||
) => void;
|
||||
|
||||
export default <EachCallback extends Global.TestCallback>(
|
||||
cb: GlobalCallback,
|
||||
supportsDone: boolean = true,
|
||||
) => (table: Global.EachTable, ...taggedTemplateData: Global.TemplateData) =>
|
||||
function eachBind(
|
||||
title: string,
|
||||
test: Global.EachTestFn<EachCallback>,
|
||||
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<EachCallback>,
|
||||
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;
|
||||
|
||||
|
|
|
@ -71,10 +71,10 @@ const each = (
|
|||
...data: Global.TemplateData
|
||||
): ReturnType<typeof install> => 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};
|
||||
|
||||
|
|
|
@ -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 extends Template, A extends keyof Obj>(
|
||||
obj: Obj,
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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!
|
||||
`;
|
||||
|
|
|
@ -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')]: `
|
||||
{
|
||||
|
|
|
@ -199,9 +199,7 @@ function findNative(
|
|||
});
|
||||
}
|
||||
|
||||
export = async function nodeCrawl(
|
||||
options: CrawlerOptions,
|
||||
): Promise<{
|
||||
export = async function nodeCrawl(options: CrawlerOptions): Promise<{
|
||||
removedFiles: FileData;
|
||||
hasteMap: InternalHasteMap;
|
||||
}> {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -50,9 +50,9 @@ export function installErrorOnPrivate(global: Global.Global): void {
|
|||
},
|
||||
);
|
||||
|
||||
(Object.keys(
|
||||
disabledJasmineMethods,
|
||||
) as Array<DisabledJasmineMethodsKeys>).forEach(methodName => {
|
||||
(
|
||||
Object.keys(disabledJasmineMethods) as Array<DisabledJasmineMethodsKeys>
|
||||
).forEach(methodName => {
|
||||
// @ts-expect-error
|
||||
jasmine[methodName] = () => {
|
||||
throwAtFunction(disabledJasmineMethods[methodName], jasmine[methodName]);
|
||||
|
|
|
@ -31,9 +31,10 @@ export default async function jasmine2(
|
|||
testPath: string,
|
||||
): Promise<TestResult> {
|
||||
const reporter = new JasmineReporter(globalConfig, config, testPath);
|
||||
const jasmineFactory = runtime.requireInternalModule<
|
||||
typeof import('./jasmine/jasmineLight')
|
||||
>(JASMINE);
|
||||
const jasmineFactory =
|
||||
runtime.requireInternalModule<typeof import('./jasmine/jasmineLight')>(
|
||||
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);
|
||||
|
|
|
@ -33,9 +33,7 @@ export type QueueableFn = {
|
|||
|
||||
type PromiseCallback = (() => void | PromiseLike<void>) | undefined | null;
|
||||
|
||||
export default function queueRunner(
|
||||
options: Options,
|
||||
): PromiseLike<void> & {
|
||||
export default function queueRunner(options: Options): PromiseLike<void> & {
|
||||
cancel: () => void;
|
||||
catch: (onRejected?: PromiseCallback) => Promise<void>;
|
||||
} {
|
||||
|
|
|
@ -26,13 +26,8 @@ export type TreeNode = {
|
|||
} & Pick<Suite, 'getResult' | 'parentSuite' | 'result' | 'markedPending'>;
|
||||
|
||||
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;
|
||||
|
|
|
@ -4,8 +4,5 @@
|
|||
"rootDir": "src",
|
||||
"outDir": "build"
|
||||
},
|
||||
"references": [
|
||||
{"path": "../jest-get-type"},
|
||||
{"path": "../pretty-format"}
|
||||
]
|
||||
"references": [{"path": "../jest-get-type"}, {"path": "../pretty-format"}]
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ export default function deepCyclicCopyReplaceable<T>(
|
|||
} 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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 <anonymous>.*$/;
|
||||
const ANONYMOUS_PROMISE_IGNORE = /^\s+at (new )?Promise \(<anonymous>\).*$/;
|
||||
const ANONYMOUS_GENERATOR_IGNORE = /^\s+at Generator.next \(<anonymous>\).*$/;
|
||||
|
|
|
@ -4,8 +4,5 @@
|
|||
"rootDir": "src",
|
||||
"outDir": "build"
|
||||
},
|
||||
"references": [
|
||||
{"path": "../jest-types"},
|
||||
{"path": "../pretty-format"}
|
||||
]
|
||||
"references": [{"path": "../jest-types"}, {"path": "../pretty-format"}]
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ export type MockFunctionMetadataType =
|
|||
export type MockFunctionMetadata<
|
||||
T,
|
||||
Y extends Array<unknown>,
|
||||
Type = MockFunctionMetadataType
|
||||
Type = MockFunctionMetadataType,
|
||||
> = {
|
||||
ref?: number;
|
||||
members?: Record<string, MockFunctionMetadata<T, Y>>;
|
||||
|
@ -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<T, Y>;
|
||||
) as unknown as Mock<T, Y>;
|
||||
f._isMockFunction = true;
|
||||
f.getMockImplementation = () => this._ensureMockConfig(f).mockImpl;
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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<Array<string>>((errors, key) => {
|
||||
return (
|
||||
['statements', 'branches', 'lines', 'functions'] as Array<
|
||||
keyof istanbulCoverage.CoverageSummaryData
|
||||
>
|
||||
).reduce<Array<string>>((errors, key) => {
|
||||
const actual = actuals[key].pct;
|
||||
const actualUncovered = actuals[key].total - actuals[key].covered;
|
||||
const threshold = thresholds[key];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -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 = (() => {
|
||||
|
|
|
@ -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<InlineSnapshot>) =>
|
||||
snapshots.reduce<Record<string, Array<InlineSnapshot>>>(
|
||||
(object, inlineSnapshot) => {
|
||||
const key = createKey(inlineSnapshot);
|
||||
return {...object, [key]: (object[key] || []).concat(inlineSnapshot)};
|
||||
},
|
||||
{},
|
||||
);
|
||||
const groupSnapshotsBy =
|
||||
(createKey: (inlineSnapshot: InlineSnapshot) => string) =>
|
||||
(snapshots: Array<InlineSnapshot>) =>
|
||||
snapshots.reduce<Record<string, Array<InlineSnapshot>>>(
|
||||
(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<string>,
|
||||
inferredParser: PrettierParserName,
|
||||
): PrettierCustomParser => (text, parsers, options) => {
|
||||
// Workaround for https://github.com/prettier/prettier/issues/3150
|
||||
options.parser = inferredParser;
|
||||
const createFormattingParser =
|
||||
(
|
||||
snapshotMatcherNames: Array<string>,
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
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',
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
const replacementNode = templateLiteral(
|
||||
[
|
||||
templateElement({
|
||||
raw: snapshot,
|
||||
}),
|
||||
],
|
||||
[],
|
||||
);
|
||||
args[snapshotIndex] = replacementNode;
|
||||
},
|
||||
});
|
||||
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',
|
||||
);
|
||||
|
||||
return ast;
|
||||
};
|
||||
const replacementNode = templateLiteral(
|
||||
[
|
||||
templateElement({
|
||||
raw: snapshot,
|
||||
}),
|
||||
],
|
||||
[],
|
||||
);
|
||||
args[snapshotIndex] = replacementNode;
|
||||
},
|
||||
});
|
||||
|
||||
return ast;
|
||||
};
|
||||
|
||||
const simpleDetectParser = (filePath: Config.Path): PrettierParserName => {
|
||||
const extname = path.extname(filePath);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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"},
|
||||
|
|
|
@ -4,8 +4,5 @@
|
|||
"rootDir": "src",
|
||||
"outDir": "build"
|
||||
},
|
||||
"references": [
|
||||
{"path": "../jest-console"},
|
||||
{"path": "../jest-types"}
|
||||
]
|
||||
"references": [{"path": "../jest-console"}, {"path": "../jest-types"}]
|
||||
}
|
||||
|
|
|
@ -821,18 +821,19 @@ export async function createTranspilingRequire(
|
|||
resolverPath: string,
|
||||
applyInteropRequireDefault: boolean = false,
|
||||
) {
|
||||
const transpiledModule = await transformer.requireAndTranspileModule<TModuleType>(
|
||||
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<TModuleType>(
|
||||
resolverPath,
|
||||
() => {},
|
||||
{
|
||||
applyInteropRequireDefault,
|
||||
instrument: false,
|
||||
supportsDynamicImport: false, // this might be true, depending on node version.
|
||||
supportsExportNamespaceFrom: false,
|
||||
supportsStaticESM: false,
|
||||
supportsTopLevelAwait: false,
|
||||
},
|
||||
);
|
||||
|
||||
return transpiledModule;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<ReportOptions[K]>]
|
||||
: never;
|
||||
export type CoverageReporterWithOptions<K = CoverageReporterName> =
|
||||
K extends CoverageReporterName
|
||||
? ReportOptions[K] extends never
|
||||
? never
|
||||
: [K, Partial<ReportOptions[K]>]
|
||||
: never;
|
||||
|
||||
export type CoverageReporters = Array<
|
||||
CoverageReporterName | CoverageReporterWithOptions
|
||||
|
|
|
@ -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' ||
|
||||
|
|
|
@ -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')]: {
|
||||
|
|
|
@ -4,7 +4,5 @@
|
|||
"rootDir": "src",
|
||||
"outDir": "build"
|
||||
},
|
||||
"references": [
|
||||
{"path": "../jest-types"}
|
||||
]
|
||||
"references": [{"path": "../jest-types"}]
|
||||
}
|
||||
|
|
|
@ -26,9 +26,8 @@ export default class Farm {
|
|||
private readonly _workerSchedulingPolicy: NonNullable<
|
||||
FarmOptions['workerSchedulingPolicy']
|
||||
>;
|
||||
private readonly _cacheKeys: Record<string, WorkerInterface> = Object.create(
|
||||
null,
|
||||
);
|
||||
private readonly _cacheKeys: Record<string, WorkerInterface> =
|
||||
Object.create(null);
|
||||
private readonly _locks: Array<boolean> = [];
|
||||
private _offset = 0;
|
||||
private readonly _taskQueue: TaskQueue;
|
||||
|
|
|
@ -25,9 +25,8 @@ type WorkerQueueValue = {
|
|||
* across the worker specific and shared queue.
|
||||
*/
|
||||
export default class FifoQueue implements TaskQueue {
|
||||
private _workerQueues: Array<
|
||||
InternalQueue<WorkerQueueValue> | undefined
|
||||
> = [];
|
||||
private _workerQueues: Array<InternalQueue<WorkerQueueValue> | undefined> =
|
||||
[];
|
||||
private _sharedQueue = new InternalQueue<QueueChildMessage>();
|
||||
|
||||
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<WorkerQueueValue>();
|
||||
workerQueue = this._workerQueues[workerId] =
|
||||
new InternalQueue<WorkerQueueValue>();
|
||||
}
|
||||
|
||||
const sharedTop = this._sharedQueue.peekLast();
|
||||
|
|
|
@ -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') {
|
||||
|
|
|
@ -4,8 +4,5 @@
|
|||
"rootDir": "src",
|
||||
"outDir": "build"
|
||||
},
|
||||
"references": [
|
||||
{"path": "../jest-cli"},
|
||||
{"path": "../jest-core"}
|
||||
]
|
||||
"references": [{"path": "../jest-cli"}, {"path": "../jest-core"}]
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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 <Mouse>\n Hello World\n </Mouse>,\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 [<Mouse>Hello World</Mouse>, <Mouse>Hello World</Mouse>]',
|
||||
{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 [<Mouse>Hello World</Mouse>, <Mouse>Hello World</Mouse>]',
|
||||
{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": <Mouse>Hello World</Mouse>, "b": <Mouse>Hello World</Mouse>}',
|
||||
{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', () => {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue