mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
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()`.
This commit is contained in:
parent
e4f011df76
commit
c714ff1014
1 changed files with 26 additions and 24 deletions
|
@ -30,7 +30,8 @@ const findSpecs = async (specDir) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.expressCreateServer = (hookName, args, cb) => {
|
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 = [];
|
const modules = [];
|
||||||
await Promise.all(Object.entries(plugins.plugins).map(async ([plugin, def]) => {
|
await Promise.all(Object.entries(plugins.plugins).map(async ([plugin, def]) => {
|
||||||
let {package: {path: pluginPath}} = 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);
|
console.debug('Sent browser the following test spec modules:', modules);
|
||||||
res.setHeader('content-type', 'application/javascript');
|
res.setHeader('content-type', 'application/javascript');
|
||||||
res.end(`window.frontendTestSpecs = ${JSON.stringify(modules, null, 2)};\n`);
|
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/');
|
const rootTestFolder = path.join(settings.root, 'src/tests/frontend/');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue