Open
Description
Repeated in couple of Jest Runners.
the tryExtensions
function tryExtensions(filepath, config) {
const { extensions } = getWorkspacesAndExtensions(config.cwd);
const hasExtension = path.extname(filepath).length > 0;
if (hasExtension) {
return filepath;
}
const extension = extensions.find((ext) => fs.existsSync(filepath + ext));
if (!extension) {
throw new Error(`Cannot find input file: ${filepath}`);
}
return filepath + extension;
}
the tryCatch
(notice that it doesn't have hasError
now) and better signature.
function isObject(val) {
return val && typeof val === 'object' && !Array.isArray(val);
}
async function tryCatch(fn, onError) {
try {
return await fn();
} catch (err) {
if (typeof onError === 'function') {
return {
error: onError(err),
};
}
if (isObject(onError)) {
return {
error: fail({
start: onError.start,
end: new Date(),
test: {
path: onError.testPath,
title: 'Rollup',
errorMessage: `jest-runner-rollup: ${err.stack || err.message}`,
},
}),
};
}
const now = new Date();
return {
error: fail({
start: now,
end: now,
test: {
path: '___rollup-runner-failing.js',
title: 'Rollup',
errorMessage: `jest-runner-rollup: ${err.stack || err.message}`,
},
}),
};
}
}
Metadata
Metadata
Assignees
Labels
This issue may be useful, and needs some attention.It's clear what the subject of the issue is about, and what the resolution should be.This issue is being worked on, and has someone assigned.Most issues will probably be for additions or changes. Expected that this will result in a PR.Good for newcomers and first-timer contributors
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity