mirror of
https://github.com/hanzoai/jest.git
synced 2026-09-24 16:59:57 +00:00
chore: errors should be named as such (#14817)
This commit is contained in:
@@ -12,6 +12,7 @@ website/static
|
||||
|
||||
# Third-party script
|
||||
packages/jest-diff/src/cleanupSemantic.ts
|
||||
e2e/native-esm/wasm-bindgen/index_bg.js
|
||||
|
||||
**/.yarn
|
||||
**/.pnp.*
|
||||
|
||||
@@ -425,14 +425,6 @@ module.exports = {
|
||||
'no-unused-vars': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: 'e2e/native-esm/wasm-bindgen/index_bg.js',
|
||||
rules: {
|
||||
'unicorn/prefer-code-point': 'off',
|
||||
'unicorn/prefer-optional-catch-binding': 'off',
|
||||
'unicorn/text-encoding-identifier-case': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: 'packages/jest-mock/src/__tests__/**/*',
|
||||
rules: {
|
||||
@@ -711,7 +703,6 @@ module.exports = {
|
||||
'unicorn/prefer-reflect-apply': 'off',
|
||||
|
||||
// TODO: turn on at some point
|
||||
'unicorn/catch-error-name': 'off',
|
||||
'unicorn/error-message': 'off',
|
||||
'unicorn/no-object-as-default-parameter': 'off',
|
||||
'unicorn/no-typeof-undefined': 'off',
|
||||
|
||||
@@ -33,8 +33,8 @@ test('the fetch fails with an error', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await fetchData();
|
||||
} catch (e) {
|
||||
expect(e).toMatch('error');
|
||||
} catch (error) {
|
||||
expect(error).toMatch('error');
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -64,7 +64,7 @@ If you expect a promise to be rejected, use the `.catch` method. Make sure to ad
|
||||
```js
|
||||
test('the fetch fails with an error', () => {
|
||||
expect.assertions(1);
|
||||
return fetchData().catch(e => expect(e).toMatch('error'));
|
||||
return fetchData().catch(error => expect(error).toMatch('error'));
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ Errors can be handled using the `.catch` method. Make sure to add `expect.assert
|
||||
// Testing for async errors using Promise.catch.
|
||||
it('tests error with promises', () => {
|
||||
expect.assertions(1);
|
||||
return user.getUserName(2).catch(e =>
|
||||
expect(e).toEqual({
|
||||
return user.getUserName(2).catch(error =>
|
||||
expect(error).toEqual({
|
||||
error: 'User with 2 not found.',
|
||||
}),
|
||||
);
|
||||
@@ -126,8 +126,8 @@ it('tests error with async/await', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await user.getUserName(1);
|
||||
} catch (e) {
|
||||
expect(e).toEqual({
|
||||
} catch (error) {
|
||||
expect(error).toEqual({
|
||||
error: 'User with 1 not found.',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ exports[`\`done()\` should not be called more than once 1`] = `
|
||||
> 17 | done();
|
||||
| ^
|
||||
18 | })
|
||||
19 | .catch(err => err);
|
||||
19 | .catch(error => error);
|
||||
20 | });
|
||||
|
||||
at done (__tests__/index.test.js:17:9)
|
||||
|
||||
@@ -32,9 +32,9 @@ describe('JSON Reporter', () => {
|
||||
|
||||
try {
|
||||
jsonResult = JSON.parse(testOutput);
|
||||
} catch (err: any) {
|
||||
} catch (error: any) {
|
||||
throw new Error(
|
||||
`Can't parse the JSON result from ${outputFileName}, ${err.toString()}`,
|
||||
`Can't parse the JSON result from ${outputFileName}, ${error.toString()}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ describe('JSON Reporter', () => {
|
||||
|
||||
try {
|
||||
jsonResult = JSON.parse(result.stdout);
|
||||
} catch (err: any) {
|
||||
} catch (error: any) {
|
||||
throw new Error(
|
||||
`Can't parse the JSON result from stdout${err.toString()}`,
|
||||
`Can't parse the JSON result from stdout${error.toString()}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,9 +79,9 @@ describe('Test Retries', () => {
|
||||
|
||||
try {
|
||||
jsonResult = JSON.parse(testOutput);
|
||||
} catch (err: any) {
|
||||
} catch (error: any) {
|
||||
throw new Error(
|
||||
`Can't parse the JSON result from ${outputFileName}, ${err.toString()}`,
|
||||
`Can't parse the JSON result from ${outputFileName}, ${error.toString()}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -110,9 +110,9 @@ describe('Test Retries', () => {
|
||||
|
||||
try {
|
||||
jsonResult = JSON.parse(testOutput);
|
||||
} catch (err: any) {
|
||||
} catch (error: any) {
|
||||
throw new Error(
|
||||
`Can't parse the JSON result from ${outputFileName}, ${err.toString()}`,
|
||||
`Can't parse the JSON result from ${outputFileName}, ${error.toString()}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -141,9 +141,9 @@ describe('Test Retries', () => {
|
||||
|
||||
try {
|
||||
jsonResult = JSON.parse(testOutput);
|
||||
} catch (err: any) {
|
||||
} catch (error: any) {
|
||||
throw new Error(
|
||||
`Can't parse the JSON result from ${outputFileName}, ${err.toString()}`,
|
||||
`Can't parse the JSON result from ${outputFileName}, ${error.toString()}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('`done()` called more than once', () => {
|
||||
done();
|
||||
done();
|
||||
})
|
||||
.catch(err => err);
|
||||
.catch(error => error);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ function g() {
|
||||
function f() {
|
||||
try {
|
||||
g();
|
||||
} catch (err) {
|
||||
throw buildErrorWithCause('error during f', {cause: err});
|
||||
} catch (error) {
|
||||
throw buildErrorWithCause('error during f', {cause: error});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ function g() {
|
||||
function f() {
|
||||
try {
|
||||
g();
|
||||
} catch (err) {
|
||||
throw buildErrorWithCause('error during f', {cause: err});
|
||||
} catch (error) {
|
||||
throw buildErrorWithCause('error during f', {cause: error});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ describe('parent', () => {
|
||||
try {
|
||||
expect(() => new Promise()).toThrow('Booo');
|
||||
done();
|
||||
} catch (e) {
|
||||
done.fail(e);
|
||||
} catch (error) {
|
||||
done.fail(error);
|
||||
}
|
||||
}, 10);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ async function readConfig() {
|
||||
}
|
||||
console.log(JSON.stringify(await readInitialOptions(config, options)));
|
||||
}
|
||||
readConfig().catch(err => {
|
||||
console.error(err);
|
||||
readConfig().catch(error => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ const config = {
|
||||
|
||||
runCLI({config: JSON.stringify(config)}, [process.cwd()])
|
||||
.then(() => console.log('run-programmatically-mutiple-projects completed'))
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
+2
-2
@@ -151,10 +151,10 @@ export const json = function (
|
||||
...result,
|
||||
json: JSON.parse(result.stdout),
|
||||
};
|
||||
} catch (e: any) {
|
||||
} catch (error: any) {
|
||||
throw new Error(dedent`
|
||||
Can't parse JSON.
|
||||
ERROR: ${e.name} ${e.message}
|
||||
ERROR: ${error.name} ${error.message}
|
||||
STDOUT: ${result.stdout}
|
||||
STDERR: ${result.stderr}
|
||||
`);
|
||||
|
||||
@@ -39,7 +39,7 @@ export default class BaseTestRunner {
|
||||
};
|
||||
})
|
||||
.then(result => onResult(test, result))
|
||||
.catch(err => onFailure(test, err)),
|
||||
.catch(error => onFailure(test, error)),
|
||||
Promise.resolve(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ export default class BaseTestRunner {
|
||||
};
|
||||
})
|
||||
.then(result => onResult(test, result))
|
||||
.catch(err => onFailure(test, err)),
|
||||
.catch(error => onFailure(test, error)),
|
||||
),
|
||||
Promise.resolve(),
|
||||
);
|
||||
|
||||
@@ -42,8 +42,8 @@ it('tests error with rejects', () => {
|
||||
// Testing for async errors using Promise.catch.
|
||||
test('tests error with promises', async () => {
|
||||
expect.assertions(1);
|
||||
return user.getUserName(2).catch(e =>
|
||||
expect(e).toEqual({
|
||||
return user.getUserName(2).catch(error =>
|
||||
expect(error).toEqual({
|
||||
error: 'User with 2 not found.',
|
||||
}),
|
||||
);
|
||||
@@ -54,8 +54,8 @@ it('tests error with async/await', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await user.getUserName(1);
|
||||
} catch (e) {
|
||||
expect(e).toEqual({
|
||||
} catch (error) {
|
||||
expect(error).toEqual({
|
||||
error: 'User with 1 not found.',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ describe('isError', () => {
|
||||
testErrorFromDifferentContext(win => {
|
||||
try {
|
||||
win.document.querySelectorAll('');
|
||||
} catch (e) {
|
||||
return e as Error;
|
||||
} catch (error) {
|
||||
return error as Error;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -71,8 +71,8 @@ describe('.rejects', () => {
|
||||
let error;
|
||||
try {
|
||||
jestExpect(value).rejects.toBe(111);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (rejectedError) {
|
||||
error = rejectedError;
|
||||
}
|
||||
expect(error).toBeDefined();
|
||||
});
|
||||
@@ -81,8 +81,8 @@ describe('.rejects', () => {
|
||||
let error;
|
||||
try {
|
||||
await jestExpect(value).rejects.toBeDefined();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (rejectedError) {
|
||||
error = rejectedError;
|
||||
}
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toMatchSnapshot();
|
||||
@@ -94,8 +94,8 @@ describe('.rejects', () => {
|
||||
let error;
|
||||
try {
|
||||
jestExpect(value).rejects.not.toBe(111);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (rejectedError) {
|
||||
error = rejectedError;
|
||||
}
|
||||
expect(error).toBeDefined();
|
||||
});
|
||||
@@ -104,8 +104,8 @@ describe('.rejects', () => {
|
||||
let error;
|
||||
try {
|
||||
await jestExpect(value).rejects.not.toBeDefined();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (rejectedError) {
|
||||
error = rejectedError;
|
||||
}
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toMatchSnapshot();
|
||||
@@ -116,8 +116,8 @@ describe('.rejects', () => {
|
||||
let error;
|
||||
try {
|
||||
await jestExpect(Promise.resolve(4)).rejects.toBe(4);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (error_) {
|
||||
error = error_;
|
||||
}
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toMatchSnapshot();
|
||||
@@ -148,8 +148,8 @@ describe('.resolves', () => {
|
||||
let error;
|
||||
try {
|
||||
jestExpect(value).resolves.toBeDefined();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (rejectedError) {
|
||||
error = rejectedError;
|
||||
}
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toMatchSnapshot();
|
||||
@@ -159,8 +159,8 @@ describe('.resolves', () => {
|
||||
let error;
|
||||
try {
|
||||
await jestExpect(value).resolves.toBeDefined();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (rejectedError) {
|
||||
error = rejectedError;
|
||||
}
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toMatchSnapshot();
|
||||
@@ -172,8 +172,8 @@ describe('.resolves', () => {
|
||||
let error;
|
||||
try {
|
||||
jestExpect(value).resolves.not.toBeDefined();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (rejectedError) {
|
||||
error = rejectedError;
|
||||
}
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toMatchSnapshot();
|
||||
@@ -183,8 +183,8 @@ describe('.resolves', () => {
|
||||
let error;
|
||||
try {
|
||||
await jestExpect(value).resolves.not.toBeDefined();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (rejectedError) {
|
||||
error = rejectedError;
|
||||
}
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toMatchSnapshot();
|
||||
@@ -195,8 +195,8 @@ describe('.resolves', () => {
|
||||
let error;
|
||||
try {
|
||||
await jestExpect(Promise.reject(4)).resolves.toBe(4);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (error_) {
|
||||
error = error_;
|
||||
}
|
||||
expect(error).toBeDefined();
|
||||
expect(error.message).toMatchSnapshot();
|
||||
|
||||
@@ -193,7 +193,7 @@ const makeResolveMatcher =
|
||||
null,
|
||||
args,
|
||||
),
|
||||
reason => {
|
||||
error => {
|
||||
outerErr.message =
|
||||
`${matcherUtils.matcherHint(
|
||||
matcherName,
|
||||
@@ -202,7 +202,7 @@ const makeResolveMatcher =
|
||||
options,
|
||||
)}\n\n` +
|
||||
'Received promise rejected instead of resolved\n' +
|
||||
`Rejected to value: ${matcherUtils.printReceived(reason)}`;
|
||||
`Rejected to value: ${matcherUtils.printReceived(error)}`;
|
||||
throw outerErr;
|
||||
},
|
||||
);
|
||||
@@ -256,8 +256,8 @@ const makeRejectMatcher =
|
||||
`Resolved to value: ${matcherUtils.printReceived(result)}`;
|
||||
throw outerErr;
|
||||
},
|
||||
reason =>
|
||||
makeThrowingMatcher(matcher, isNot, 'rejects', reason, innerErr).apply(
|
||||
error =>
|
||||
makeThrowingMatcher(matcher, isNot, 'rejects', error, innerErr).apply(
|
||||
null,
|
||||
args,
|
||||
),
|
||||
|
||||
@@ -91,8 +91,8 @@ export const createMatcher = (
|
||||
if (typeof received === 'function') {
|
||||
try {
|
||||
received();
|
||||
} catch (e) {
|
||||
thrown = getThrown(e);
|
||||
} catch (error) {
|
||||
thrown = getThrown(error);
|
||||
}
|
||||
} else {
|
||||
if (!fromPromise) {
|
||||
|
||||
@@ -19,14 +19,14 @@ const findChangedFilesUsingCommand = async (
|
||||
|
||||
try {
|
||||
result = await execa('git', args, {cwd});
|
||||
} catch (e) {
|
||||
if (types.isNativeError(e)) {
|
||||
const err = e as execa.ExecaError;
|
||||
} catch (error) {
|
||||
if (types.isNativeError(error)) {
|
||||
const err = error as execa.ExecaError;
|
||||
// TODO: Should we keep the original `message`?
|
||||
err.message = err.stderr;
|
||||
}
|
||||
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
|
||||
return result.stdout
|
||||
|
||||
@@ -34,14 +34,14 @@ const adapter: SCMAdapter = {
|
||||
|
||||
try {
|
||||
result = await execa('hg', args, {cwd, env});
|
||||
} catch (e) {
|
||||
if (types.isNativeError(e)) {
|
||||
const err = e as execa.ExecaError;
|
||||
} catch (error) {
|
||||
if (types.isNativeError(error)) {
|
||||
const err = error as execa.ExecaError;
|
||||
// TODO: Should we keep the original `message`?
|
||||
err.message = err.stderr;
|
||||
}
|
||||
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
|
||||
return result.stdout
|
||||
|
||||
@@ -38,14 +38,14 @@ const adapter: SCMAdapter = {
|
||||
|
||||
try {
|
||||
result = await execa('sl', args, {cwd, env});
|
||||
} catch (e) {
|
||||
if (types.isNativeError(e)) {
|
||||
const err = e as execa.ExecaError;
|
||||
} catch (error) {
|
||||
if (types.isNativeError(error)) {
|
||||
const err = error as execa.ExecaError;
|
||||
// TODO: Should we keep the original `message`?
|
||||
err.message = err.stderr;
|
||||
}
|
||||
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
|
||||
return result.stdout
|
||||
|
||||
@@ -168,9 +168,9 @@ function startTestsConcurrently(concurrentTests: Array<ConcurrentTestEntry>) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
promise.catch(() => {});
|
||||
test.fn = () => promise;
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
test.fn = () => {
|
||||
throw err;
|
||||
throw error;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,12 +74,12 @@ function verifyDirectoryExists(path: string, key: string) {
|
||||
)} option is not a directory.`,
|
||||
);
|
||||
}
|
||||
} catch (err: any) {
|
||||
if (err instanceof ValidationError) {
|
||||
throw err;
|
||||
} catch (error: any) {
|
||||
if (error instanceof ValidationError) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (err.code === 'ENOENT') {
|
||||
if (error.code === 'ENOENT') {
|
||||
throw createConfigError(
|
||||
` Directory ${chalk.bold(path)} in the ${chalk.bold(
|
||||
key,
|
||||
@@ -91,7 +91,7 @@ function verifyDirectoryExists(path: string, key: string) {
|
||||
throw createConfigError(
|
||||
` Got an error trying to find ${chalk.bold(path)} in the ${chalk.bold(
|
||||
key,
|
||||
)} option.\n\n Error was: ${err.message}`,
|
||||
)} option.\n\n Error was: ${error.message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,13 +121,13 @@ async function registerTsNode(): Promise<Service> {
|
||||
'**': 'cjs',
|
||||
},
|
||||
});
|
||||
} catch (e: any) {
|
||||
if (e.code === 'ERR_MODULE_NOT_FOUND') {
|
||||
} catch (error: any) {
|
||||
if (error.code === 'ERR_MODULE_NOT_FOUND') {
|
||||
throw new Error(
|
||||
`Jest: 'ts-node' is required for the TypeScript configuration files. Make sure it is installed\nError: ${e.message}`,
|
||||
`Jest: 'ts-node' is required for the TypeScript configuration files. Make sure it is installed\nError: ${error.message}`,
|
||||
);
|
||||
}
|
||||
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,8 +347,8 @@ describe('scheduleTests should always dispatch runStart and runComplete events',
|
||||
throw new Error('should throw exception');
|
||||
}
|
||||
expect(result.runExecError).toBeUndefined();
|
||||
} catch (e) {
|
||||
expect(e).toEqual(errorMsg);
|
||||
} catch (error) {
|
||||
expect(error).toEqual(errorMsg);
|
||||
}
|
||||
|
||||
expect(mockReporter.onRunStart).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -199,8 +199,8 @@ const _run10000 = async (
|
||||
filterSetupPromise = (async () => {
|
||||
try {
|
||||
await rawFilter.setup();
|
||||
} catch (err) {
|
||||
return err;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return undefined;
|
||||
})();
|
||||
|
||||
@@ -31,8 +31,8 @@ export default function getChangedFilesPromise(
|
||||
changedSince: globalConfig.changedSince,
|
||||
lastCommit: globalConfig.lastCommit,
|
||||
withAncestor: globalConfig.changedFilesWithAncestor,
|
||||
}).catch(e => {
|
||||
const message = formatExecError(e, configs[0], {noStackTrace: true})
|
||||
}).catch(error => {
|
||||
const message = formatExecError(error, configs[0], {noStackTrace: true})
|
||||
.split('\n')
|
||||
.filter(line => !line.includes('Command failed:'))
|
||||
.join('\n');
|
||||
|
||||
@@ -38,7 +38,7 @@ export default function bind<EachCallback extends Global.TestCallback>(
|
||||
table: Global.EachTable,
|
||||
...taggedTemplateData: Global.TemplateData
|
||||
) => {
|
||||
const error = new ErrorWithStack(undefined, bindWrap);
|
||||
const errorWithStack = new ErrorWithStack(undefined, bindWrap);
|
||||
|
||||
return function eachBind(
|
||||
title: Global.BlockNameLike,
|
||||
@@ -57,7 +57,7 @@ export default function bind<EachCallback extends Global.TestCallback>(
|
||||
row.title,
|
||||
applyArguments(supportsDone, row.arguments, test),
|
||||
timeout,
|
||||
error,
|
||||
errorWithStack,
|
||||
)
|
||||
: cb(
|
||||
row.title,
|
||||
@@ -67,9 +67,12 @@ export default function bind<EachCallback extends Global.TestCallback>(
|
||||
}
|
||||
|
||||
return;
|
||||
} catch (e: any) {
|
||||
const err = new Error(e.message);
|
||||
err.stack = error.stack?.replace(/^Error: /s, `Error: ${e.message}`);
|
||||
} catch (error: any) {
|
||||
const err = new Error(error.message);
|
||||
err.stack = errorWithStack.stack?.replace(
|
||||
/^Error: /s,
|
||||
`Error: ${error.message}`,
|
||||
);
|
||||
|
||||
return cb(title, () => {
|
||||
throw err;
|
||||
|
||||
@@ -324,9 +324,9 @@ export default class FakeTimers<TimerRef = unknown> {
|
||||
let errThrown = false;
|
||||
try {
|
||||
cb();
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
errThrown = true;
|
||||
cbErr = e;
|
||||
cbErr = error;
|
||||
}
|
||||
|
||||
this._global.clearImmediate = prevClearImmediate;
|
||||
|
||||
@@ -376,8 +376,8 @@ describe('HasteMap', () => {
|
||||
|
||||
try {
|
||||
await (await HasteMap.create(config)).build();
|
||||
} catch (err) {
|
||||
expect(err.message).toBe(
|
||||
} catch (error) {
|
||||
expect(error.message).toBe(
|
||||
'jest-haste-map: the `ignorePattern` option must be a RegExp',
|
||||
);
|
||||
}
|
||||
@@ -819,8 +819,8 @@ describe('HasteMap', () => {
|
||||
...defaultConfig,
|
||||
})
|
||||
).build();
|
||||
} catch (err) {
|
||||
expect(err.message).toBe(
|
||||
} catch (error) {
|
||||
expect(error.message).toBe(
|
||||
'Duplicated files or mocks. Please check the console for more info',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -138,8 +138,8 @@ describe('worker', () => {
|
||||
|
||||
try {
|
||||
await worker({computeDependencies: true, filePath: '/kiwi.js', rootDir});
|
||||
} catch (err) {
|
||||
error = err;
|
||||
} catch (thrownError) {
|
||||
error = thrownError;
|
||||
}
|
||||
|
||||
expect(error.message).toBe("Cannot read path '/kiwi.js'.");
|
||||
|
||||
@@ -772,7 +772,7 @@ class HasteMap extends EventEmitter implements IHasteMap {
|
||||
roots: options.roots,
|
||||
};
|
||||
|
||||
const retry = (error: Error) => {
|
||||
const retry = (retryError: Error) => {
|
||||
if (crawl === watchmanCrawl) {
|
||||
this._console.warn(
|
||||
'jest-haste-map: Watchman crawl failed. Retrying once with node ' +
|
||||
@@ -780,18 +780,18 @@ class HasteMap extends EventEmitter implements IHasteMap {
|
||||
" Usually this happens when watchman isn't running. Create an " +
|
||||
"empty `.watchmanconfig` file in your project's root folder or " +
|
||||
'initialize a git or hg repository in your project.\n' +
|
||||
` ${error}`,
|
||||
` ${retryError}`,
|
||||
);
|
||||
return nodeCrawl(crawlerOptions).catch(e => {
|
||||
return nodeCrawl(crawlerOptions).catch(error => {
|
||||
throw new Error(
|
||||
'Crawler retry failed:\n' +
|
||||
` Original error: ${error.message}\n` +
|
||||
` Retry error: ${e.message}\n`,
|
||||
` Original error: ${retryError.message}\n` +
|
||||
` Retry error: ${error.message}\n`,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
throw error;
|
||||
throw retryError;
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
@@ -66,8 +66,8 @@ export async function worker(data: WorkerMessage): Promise<WorkerMetadata> {
|
||||
id = fileData.name;
|
||||
module = [relativeFilePath, H.PACKAGE];
|
||||
}
|
||||
} catch (err: any) {
|
||||
throw new Error(`Cannot parse ${filePath} as JSON: ${err.message}`);
|
||||
} catch (error: any) {
|
||||
throw new Error(`Cannot parse ${filePath} as JSON: ${error.message}`);
|
||||
}
|
||||
} else if (!blacklist.has(filePath.slice(filePath.lastIndexOf('.')))) {
|
||||
// Process a random file that is returned as a MODULE.
|
||||
|
||||
@@ -77,8 +77,8 @@ export default class PCancelable<T> implements PromiseLike<T> {
|
||||
if (typeof this._cancel === 'function') {
|
||||
try {
|
||||
this._cancel();
|
||||
} catch (err) {
|
||||
this._reject(err);
|
||||
} catch (error) {
|
||||
this._reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -452,8 +452,8 @@ export default function jasmineEnv(j$: Jasmine) {
|
||||
let describeReturnValue: unknown | Error;
|
||||
try {
|
||||
describeReturnValue = specDefinitions.call(suite);
|
||||
} catch (e: any) {
|
||||
declarationError = e;
|
||||
} catch (error: any) {
|
||||
declarationError = error;
|
||||
}
|
||||
|
||||
if (isPromise(describeReturnValue)) {
|
||||
|
||||
@@ -21,9 +21,9 @@ export default function pTimeout(
|
||||
clearTimeout(timer);
|
||||
resolve(val);
|
||||
},
|
||||
err => {
|
||||
error => {
|
||||
clearTimeout(timer);
|
||||
reject(err);
|
||||
reject(error);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -55,8 +55,8 @@ export default function queueRunner(options: Options): PromiseLike<void> & {
|
||||
};
|
||||
try {
|
||||
fn.call(options.userContext, next);
|
||||
} catch (e: any) {
|
||||
options.onException(e);
|
||||
} catch (error: any) {
|
||||
options.onException(error);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -50,8 +50,10 @@ const evalCommand: repl.REPLEval = (
|
||||
: transformResult.code;
|
||||
}
|
||||
result = runInThisContext(cmd) as unknown;
|
||||
} catch (e: any) {
|
||||
return callback(isRecoverableError(e) ? new repl.Recoverable(e) : e);
|
||||
} catch (error: any) {
|
||||
return callback(
|
||||
isRecoverableError(error) ? new repl.Recoverable(error) : error,
|
||||
);
|
||||
}
|
||||
return callback(null, result);
|
||||
};
|
||||
|
||||
@@ -140,8 +140,10 @@ export async function run(
|
||||
} else {
|
||||
runtime.requireModule(filePath);
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error(chalk.red(util.types.isNativeError(e) ? e.stack : e));
|
||||
} catch (error: any) {
|
||||
console.error(
|
||||
chalk.red(util.types.isNativeError(error) ? error.stack : error),
|
||||
);
|
||||
process.on('exit', () => {
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
@@ -91,12 +91,12 @@ export default class CoverageReporter extends BaseReporter {
|
||||
.execute(reportContext);
|
||||
}
|
||||
aggregatedResults.coverageMap = map;
|
||||
} catch (e: any) {
|
||||
} catch (error: any) {
|
||||
console.error(
|
||||
chalk.red(`
|
||||
Failed to write coverage reports:
|
||||
ERROR: ${e.toString()}
|
||||
STACK: ${e.stack}
|
||||
ERROR: ${error.toString()}
|
||||
STACK: ${error.stack}
|
||||
`),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -158,9 +158,9 @@ export default class NotifyReporter extends BaseReporter {
|
||||
function loadNotifier(): typeof import('node-notifier') {
|
||||
try {
|
||||
return require('node-notifier');
|
||||
} catch (err: any) {
|
||||
if (err.code !== 'MODULE_NOT_FOUND') {
|
||||
throw err;
|
||||
} catch (error: any) {
|
||||
if (error.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
|
||||
@@ -31,9 +31,9 @@ function statSyncCached(path: string): IPathType {
|
||||
let stat;
|
||||
try {
|
||||
stat = fs.statSync(path, {throwIfNoEntry: false});
|
||||
} catch (e: any) {
|
||||
if (!(e && (e.code === 'ENOENT' || e.code === 'ENOTDIR'))) {
|
||||
throw e;
|
||||
} catch (error: any) {
|
||||
if (!(error && (error.code === 'ENOENT' || error.code === 'ENOTDIR'))) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,10 +130,10 @@ export default class Resolver {
|
||||
paths: paths ? (nodePaths || []).concat(paths) : nodePaths,
|
||||
rootDir: options.rootDir,
|
||||
});
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
// we always wanna throw if it's an internal import
|
||||
if (options.throwIfNotFound || path.startsWith('#')) {
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -174,10 +174,10 @@ export default class Resolver {
|
||||
rootDir: options.rootDir,
|
||||
});
|
||||
return result;
|
||||
} catch (e: unknown) {
|
||||
} catch (error: unknown) {
|
||||
// we always wanna throw if it's an internal import
|
||||
if (options.throwIfNotFound || path.startsWith('#')) {
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -311,11 +311,11 @@ async function runTestInternal(
|
||||
path,
|
||||
sendMessageToJest,
|
||||
);
|
||||
} catch (err: any) {
|
||||
} catch (error: any) {
|
||||
// Access stack before uninstalling sourcemaps
|
||||
err.stack;
|
||||
error.stack;
|
||||
|
||||
throw err;
|
||||
throw error;
|
||||
} finally {
|
||||
if (collectV8Coverage) {
|
||||
await runtime.stopCollectingV8Coverage();
|
||||
|
||||
@@ -26,13 +26,13 @@ describe('Runtime', () => {
|
||||
|
||||
try {
|
||||
sum();
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
if (process.platform === 'win32') {
|
||||
expect(err.stack).toMatch(
|
||||
expect(error.stack).toMatch(
|
||||
/^Error: throwing fn\s+at sum.+\\__tests__\\test_root\\sourcemaps\\(out\\)?throwing-mapped-fn.js:\d+:\d+/,
|
||||
);
|
||||
} else {
|
||||
expect(err.stack).toMatch(
|
||||
expect(error.stack).toMatch(
|
||||
/^Error: throwing fn\s+at sum.+\/__tests__\/test_root\/sourcemaps\/(out\/)?throwing-mapped-fn.js:\d+:\d+/,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ describe('Runtime', () => {
|
||||
let hasThrown = false;
|
||||
try {
|
||||
runtime.requireModule(runtime.__mockRootPath, './throwing.js');
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
hasThrown = true;
|
||||
expect(err.stack).toMatch(/^Error: throwing\s+at Object.<anonymous>/);
|
||||
expect(error.stack).toMatch(/^Error: throwing\s+at Object.<anonymous>/);
|
||||
}
|
||||
expect(hasThrown).toBe(true);
|
||||
});
|
||||
@@ -38,14 +38,14 @@ describe('Runtime', () => {
|
||||
|
||||
try {
|
||||
sum();
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
hasThrown = true;
|
||||
if (process.platform === 'win32') {
|
||||
expect(err.stack).toMatch(
|
||||
expect(error.stack).toMatch(
|
||||
/^Error: throwing fn\s+at sum.+\\__tests__\\test_root\\throwing_fn\.js/,
|
||||
);
|
||||
} else {
|
||||
expect(err.stack).toMatch(
|
||||
expect(error.stack).toMatch(
|
||||
/^Error: throwing fn\s+at sum.+\/__tests__\/test_root\/throwing_fn\.js/,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ describe('Runtime', () => {
|
||||
// are not correctly falling back to 'native' require.
|
||||
try {
|
||||
runtime.requireMock(__filename, './test_root/NativeModule.node');
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (thrownError) {
|
||||
error = thrownError;
|
||||
} finally {
|
||||
expect(error.message).toMatch(
|
||||
/NativeModule.node: file too short|NativeModule.node, 0x0001|not a valid Win\d+ application/,
|
||||
|
||||
@@ -1153,8 +1153,8 @@ export default class Runtime {
|
||||
} else {
|
||||
return this.requireModule<T>(from, moduleName);
|
||||
}
|
||||
} catch (e) {
|
||||
const moduleNotFound = Resolver.tryCastModuleNotFoundError(e);
|
||||
} catch (error) {
|
||||
const moduleNotFound = Resolver.tryCastModuleNotFoundError(error);
|
||||
if (moduleNotFound) {
|
||||
if (
|
||||
moduleNotFound.siblingWithSimilarExtensionFound === null ||
|
||||
@@ -1172,7 +1172,7 @@ export default class Runtime {
|
||||
moduleNotFound.buildMessage(this._config.rootDir);
|
||||
throw moduleNotFound;
|
||||
}
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1477,13 +1477,13 @@ export default class Runtime {
|
||||
|
||||
try {
|
||||
return this._resolveCjsModule(from, moduleName);
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
const module = this._resolver.getMockModule(from, moduleName);
|
||||
|
||||
if (module) {
|
||||
return module;
|
||||
} else {
|
||||
throw err;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1720,8 +1720,8 @@ export default class Runtime {
|
||||
return this.linkAndEvaluateModule(module);
|
||||
},
|
||||
});
|
||||
} catch (e: any) {
|
||||
throw handlePotentialSyntaxError(e);
|
||||
} catch (error: any) {
|
||||
throw handlePotentialSyntaxError(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1946,13 +1946,13 @@ export default class Runtime {
|
||||
let modulePath;
|
||||
try {
|
||||
modulePath = this._resolveCjsModule(from, moduleName);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
const manualMock = this._resolver.getMockModule(from, moduleName);
|
||||
if (manualMock) {
|
||||
this._shouldMockModuleCache.set(moduleID, true);
|
||||
return true;
|
||||
}
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (this._unmockList && this._unmockList.test(modulePath)) {
|
||||
@@ -2017,7 +2017,7 @@ export default class Runtime {
|
||||
let modulePath;
|
||||
try {
|
||||
modulePath = await this._resolveModule(from, moduleName);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
const manualMock = await this._resolver.getMockModuleAsync(
|
||||
from,
|
||||
moduleName,
|
||||
@@ -2026,7 +2026,7 @@ export default class Runtime {
|
||||
this._shouldMockModuleCache.set(moduleID, true);
|
||||
return true;
|
||||
}
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (this._unmockList && this._unmockList.test(modulePath)) {
|
||||
|
||||
@@ -514,8 +514,8 @@ const _toThrowErrorMatchingSnapshot = (
|
||||
} else {
|
||||
try {
|
||||
received();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
} catch (receivedError) {
|
||||
error = receivedError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -637,11 +637,11 @@ class ScriptTransformer {
|
||||
originalCode: content,
|
||||
sourceMapPath,
|
||||
};
|
||||
} catch (e) {
|
||||
if (!(e instanceof Error)) {
|
||||
throw e;
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error)) {
|
||||
throw error;
|
||||
}
|
||||
throw handlePotentialSyntaxError(e);
|
||||
throw handlePotentialSyntaxError(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,11 +683,11 @@ class ScriptTransformer {
|
||||
originalCode: content,
|
||||
sourceMapPath,
|
||||
};
|
||||
} catch (e) {
|
||||
if (!(e instanceof Error)) {
|
||||
throw e;
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error)) {
|
||||
throw error;
|
||||
}
|
||||
throw handlePotentialSyntaxError(e);
|
||||
throw handlePotentialSyntaxError(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,17 +933,17 @@ function readCodeCacheFile(cachePath: string): string | null {
|
||||
const writeCacheFile = (cachePath: string, fileData: string) => {
|
||||
try {
|
||||
writeFileAtomic(cachePath, fileData, {encoding: 'utf8', fsync: false});
|
||||
} catch (e) {
|
||||
if (!(e instanceof Error)) {
|
||||
throw e;
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error)) {
|
||||
throw error;
|
||||
}
|
||||
if (cacheWriteErrorSafeToIgnore(e, cachePath)) {
|
||||
if (cacheWriteErrorSafeToIgnore(error, cachePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.message = `jest: failed to cache transform results in: ${cachePath}\nFailure message: ${e.message}`;
|
||||
error.message = `jest: failed to cache transform results in: ${cachePath}\nFailure message: ${error.message}`;
|
||||
removeFile(cachePath);
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -969,22 +969,22 @@ const readCacheFile = (cachePath: string): string | null => {
|
||||
let fileData;
|
||||
try {
|
||||
fileData = fs.readFileSync(cachePath, 'utf8');
|
||||
} catch (e) {
|
||||
if (!(e instanceof Error)) {
|
||||
throw e;
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error)) {
|
||||
throw error;
|
||||
}
|
||||
// on windows write-file-atomic is not atomic which can
|
||||
// result in this error
|
||||
if (
|
||||
(e as NodeJS.ErrnoException).code === 'ENOENT' &&
|
||||
(error as NodeJS.ErrnoException).code === 'ENOENT' &&
|
||||
process.platform === 'win32'
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
e.message = `jest: failed to read cache file: ${cachePath}\nFailure message: ${e.message}`;
|
||||
error.message = `jest: failed to read cache file: ${cachePath}\nFailure message: ${error.message}`;
|
||||
removeFile(cachePath);
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (fileData == null) {
|
||||
|
||||
@@ -10,9 +10,9 @@ import * as fs from 'graceful-fs';
|
||||
export default function createDirectory(path: string): void {
|
||||
try {
|
||||
fs.mkdirSync(path, {recursive: true});
|
||||
} catch (e: any) {
|
||||
if (e.code !== 'EEXIST') {
|
||||
throw e;
|
||||
} catch (error: any) {
|
||||
if (error.code !== 'EEXIST') {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,12 +90,12 @@ export default function createProcessObject(): typeof Process {
|
||||
try {
|
||||
// This fails on Node 12, but it's already set to 'process'
|
||||
newProcess[Symbol.toStringTag] = 'process';
|
||||
} catch (e: any) {
|
||||
} catch (error: any) {
|
||||
// Make sure it's actually set instead of potentially ignoring errors
|
||||
if (newProcess[Symbol.toStringTag] !== 'process') {
|
||||
e.message = `Unable to set toStringTag on process. Please open up an issue at https://github.com/jestjs/jest\n\n${e.message}`;
|
||||
error.message = `Unable to set toStringTag on process. Please open up an issue at https://github.com/jestjs/jest\n\n${error.message}`;
|
||||
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,18 +210,18 @@ describe('Farm', () => {
|
||||
const farm = new Farm(4, callback);
|
||||
|
||||
const promise = farm.doWork('car', 'plane');
|
||||
let error = null;
|
||||
let thrownError = null;
|
||||
|
||||
workerReply(0, new TypeError('Massively broken'));
|
||||
|
||||
try {
|
||||
await promise;
|
||||
} catch (err) {
|
||||
error = err;
|
||||
} catch (error) {
|
||||
thrownError = error;
|
||||
}
|
||||
|
||||
expect(error).not.toBeNull();
|
||||
expect(error).toBeInstanceOf(TypeError);
|
||||
expect(thrownError).not.toBeNull();
|
||||
expect(thrownError).toBeInstanceOf(TypeError);
|
||||
});
|
||||
|
||||
it('checks that once a sticked task finishes, next time is sent to that worker', async () => {
|
||||
|
||||
@@ -237,8 +237,8 @@ export default class ChildProcessWorker
|
||||
this.state = WorkerStates.OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error looking for out of memory crash', err);
|
||||
} catch (error) {
|
||||
console.error('Error looking for out of memory crash', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -383,11 +383,11 @@ export default class ExperimentalWorker
|
||||
|
||||
try {
|
||||
this._worker.postMessage([CHILD_MESSAGE_MEM_USAGE]);
|
||||
} catch (err: any) {
|
||||
} catch (error: any) {
|
||||
this._memoryUsagePromise = undefined;
|
||||
this._resolveMemoryUsage = undefined;
|
||||
|
||||
rejectCallback(err);
|
||||
rejectCallback(error);
|
||||
}
|
||||
|
||||
return promise;
|
||||
|
||||
@@ -193,8 +193,8 @@ function execFunction(
|
||||
|
||||
try {
|
||||
result = fn.apply(ctx, args);
|
||||
} catch (err: any) {
|
||||
onError(err);
|
||||
} catch (error: any) {
|
||||
onError(error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,11 +114,11 @@ function reportSuccess(result: unknown) {
|
||||
|
||||
try {
|
||||
parentPort!.postMessage([PARENT_MESSAGE_OK, result]);
|
||||
} catch (err: any) {
|
||||
} catch (error: any) {
|
||||
// Handling it here to avoid unhandled `DataCloneError` rejection
|
||||
// which is hard to distinguish on the parent side
|
||||
// (such error doesn't have any message or stack trace)
|
||||
reportClientError(err);
|
||||
reportClientError(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,8 +202,8 @@ function execFunction(
|
||||
|
||||
try {
|
||||
result = fn.apply(ctx, args);
|
||||
} catch (err: any) {
|
||||
onError(err);
|
||||
} catch (error: any) {
|
||||
onError(error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ function testCase(name, fn) {
|
||||
|
||||
try {
|
||||
result = fn();
|
||||
} catch (err) {
|
||||
error = err;
|
||||
} catch (thrownError) {
|
||||
error = thrownError;
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
|
||||
+4
-4
@@ -164,11 +164,11 @@ try {
|
||||
console.log(
|
||||
chalk.inverse.green(' Successfully built TypeScript definition files '),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
console.error(
|
||||
chalk.inverse.red(' Unable to build TypeScript definition files '),
|
||||
);
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
|
||||
console.log(chalk.inverse(' Validating TypeScript definition files '));
|
||||
@@ -247,12 +247,12 @@ try {
|
||||
}),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
console.error(
|
||||
chalk.inverse.red(' Unable to validate TypeScript definition files '),
|
||||
);
|
||||
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
|
||||
console.log(
|
||||
|
||||
+2
-2
@@ -174,12 +174,12 @@ try {
|
||||
}),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
console.error(
|
||||
chalk.inverse.red(' Unable to lint using TypeScript info files '),
|
||||
);
|
||||
|
||||
throw e;
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (allLintResults.length > 0) {
|
||||
|
||||
@@ -49,7 +49,7 @@ request('https://api.opencollective.com/graphql/v2', graphqlQuery)
|
||||
.then(() => {
|
||||
console.log('Fetched 1 file: backers.json');
|
||||
})
|
||||
.catch(e => {
|
||||
console.error('Failed to write backers file:', e);
|
||||
.catch(error => {
|
||||
console.error('Failed to write backers file:', error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
@@ -33,8 +33,8 @@ test('the fetch fails with an error', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await fetchData();
|
||||
} catch (e) {
|
||||
expect(e).toMatch('error');
|
||||
} catch (error) {
|
||||
expect(error).toMatch('error');
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -64,7 +64,7 @@ If you expect a promise to be rejected, use the `.catch` method. Make sure to ad
|
||||
```js
|
||||
test('the fetch fails with an error', () => {
|
||||
expect.assertions(1);
|
||||
return fetchData().catch(e => expect(e).toMatch('error'));
|
||||
return fetchData().catch(error => expect(error).toMatch('error'));
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ Errors can be handled using the `.catch` method. Make sure to add `expect.assert
|
||||
// Testing for async errors using Promise.catch.
|
||||
it('tests error with promises', () => {
|
||||
expect.assertions(1);
|
||||
return user.getUserName(2).catch(e =>
|
||||
expect(e).toEqual({
|
||||
return user.getUserName(2).catch(error =>
|
||||
expect(error).toEqual({
|
||||
error: 'User with 2 not found.',
|
||||
}),
|
||||
);
|
||||
@@ -126,8 +126,8 @@ it('tests error with async/await', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await user.getUserName(1);
|
||||
} catch (e) {
|
||||
expect(e).toEqual({
|
||||
} catch (error) {
|
||||
expect(error).toEqual({
|
||||
error: 'User with 1 not found.',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ test('the fetch fails with an error', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await fetchData();
|
||||
} catch (e) {
|
||||
expect(e).toMatch('error');
|
||||
} catch (error) {
|
||||
expect(error).toMatch('error');
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -64,7 +64,7 @@ If you expect a promise to be rejected, use the `.catch` method. Make sure to ad
|
||||
```js
|
||||
test('the fetch fails with an error', () => {
|
||||
expect.assertions(1);
|
||||
return fetchData().catch(e => expect(e).toMatch('error'));
|
||||
return fetchData().catch(error => expect(error).toMatch('error'));
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ Errors can be handled using the `.catch` method. Make sure to add `expect.assert
|
||||
// Testing for async errors using Promise.catch.
|
||||
it('tests error with promises', () => {
|
||||
expect.assertions(1);
|
||||
return user.getUserName(2).catch(e =>
|
||||
expect(e).toEqual({
|
||||
return user.getUserName(2).catch(error =>
|
||||
expect(error).toEqual({
|
||||
error: 'User with 2 not found.',
|
||||
}),
|
||||
);
|
||||
@@ -126,8 +126,8 @@ it('tests error with async/await', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await user.getUserName(1);
|
||||
} catch (e) {
|
||||
expect(e).toEqual({
|
||||
} catch (error) {
|
||||
expect(error).toEqual({
|
||||
error: 'User with 1 not found.',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ test('the fetch fails with an error', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await fetchData();
|
||||
} catch (e) {
|
||||
expect(e).toMatch('error');
|
||||
} catch (error) {
|
||||
expect(error).toMatch('error');
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -64,7 +64,7 @@ If you expect a promise to be rejected, use the `.catch` method. Make sure to ad
|
||||
```js
|
||||
test('the fetch fails with an error', () => {
|
||||
expect.assertions(1);
|
||||
return fetchData().catch(e => expect(e).toMatch('error'));
|
||||
return fetchData().catch(error => expect(error).toMatch('error'));
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ Errors can be handled using the `.catch` method. Make sure to add `expect.assert
|
||||
// Testing for async errors using Promise.catch.
|
||||
it('tests error with promises', () => {
|
||||
expect.assertions(1);
|
||||
return user.getUserName(2).catch(e =>
|
||||
expect(e).toEqual({
|
||||
return user.getUserName(2).catch(error =>
|
||||
expect(error).toEqual({
|
||||
error: 'User with 2 not found.',
|
||||
}),
|
||||
);
|
||||
@@ -126,8 +126,8 @@ it('tests error with async/await', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await user.getUserName(1);
|
||||
} catch (e) {
|
||||
expect(e).toEqual({
|
||||
} catch (error) {
|
||||
expect(error).toEqual({
|
||||
error: 'User with 1 not found.',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ test('the fetch fails with an error', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await fetchData();
|
||||
} catch (e) {
|
||||
expect(e).toMatch('error');
|
||||
} catch (error) {
|
||||
expect(error).toMatch('error');
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -64,7 +64,7 @@ If you expect a promise to be rejected, use the `.catch` method. Make sure to ad
|
||||
```js
|
||||
test('the fetch fails with an error', () => {
|
||||
expect.assertions(1);
|
||||
return fetchData().catch(e => expect(e).toMatch('error'));
|
||||
return fetchData().catch(error => expect(error).toMatch('error'));
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ Errors can be handled using the `.catch` method. Make sure to add `expect.assert
|
||||
// Testing for async errors using Promise.catch.
|
||||
it('tests error with promises', () => {
|
||||
expect.assertions(1);
|
||||
return user.getUserName(2).catch(e =>
|
||||
expect(e).toEqual({
|
||||
return user.getUserName(2).catch(error =>
|
||||
expect(error).toEqual({
|
||||
error: 'User with 2 not found.',
|
||||
}),
|
||||
);
|
||||
@@ -126,8 +126,8 @@ it('tests error with async/await', async () => {
|
||||
expect.assertions(1);
|
||||
try {
|
||||
await user.getUserName(1);
|
||||
} catch (e) {
|
||||
expect(e).toEqual({
|
||||
} catch (error) {
|
||||
expect(error).toEqual({
|
||||
error: 'User with 1 not found.',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user