tests: Let Express handle errors when serving `frontendTestSpecs.js`
Express v4.x doesn't understand Promises so we have to manually catch Promise rejections and pass the error object to `next()`.pull/5050/head
parent
e4f011df76
commit
c714ff1014
|
@ -30,7 +30,8 @@ const findSpecs = async (specDir) => {
|
|||
};
|
||||
|
||||
exports.expressCreateServer = (hookName, args, cb) => {
|
||||
args.app.get('/tests/frontend/frontendTestSpecs.js', async (req, res) => {
|
||||
args.app.get('/tests/frontend/frontendTestSpecs.js', (req, res, next) => {
|
||||
(async () => {
|
||||
const modules = [];
|
||||
await Promise.all(Object.entries(plugins.plugins).map(async ([plugin, def]) => {
|
||||
let {package: {path: pluginPath}} = def;
|
||||
|
@ -54,6 +55,7 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
|||
console.debug('Sent browser the following test spec modules:', modules);
|
||||
res.setHeader('content-type', 'application/javascript');
|
||||
res.end(`window.frontendTestSpecs = ${JSON.stringify(modules, null, 2)};\n`);
|
||||
})().catch((err) => next(err || new Error(err)));
|
||||
});
|
||||
|
||||
const rootTestFolder = path.join(settings.root, 'src/tests/frontend/');
|
||||
|
|
Loading…
Reference in New Issue