tests: Only wrap `*.js` files in `describe()`
parent
e1c2c963f0
commit
995e381243
|
@ -47,14 +47,14 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
// version used with Express v4.x) interprets '.' and '*' differently than regexp.
|
// version used with Express v4.x) interprets '.' and '*' differently than regexp.
|
||||||
args.app.get('/tests/frontend/specs/:file([\\d\\D]{0,})', (req, res, next) => {
|
args.app.get('/tests/frontend/specs/:file([\\d\\D]{0,})', (req, res, next) => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const specFilePath = sanitizePath(`specs/${req.params.file}`);
|
const file = sanitizePath(`specs/${req.params.file}`);
|
||||||
const specFileName = path.basename(specFilePath);
|
if (file.endsWith('.js')) {
|
||||||
let content = await fsp.readFile(specFilePath);
|
const content = await fsp.readFile(file);
|
||||||
content = `describe(${JSON.stringify(specFileName)}, function(){${content}});`;
|
|
||||||
if (!specFilePath.endsWith('index.html')) {
|
|
||||||
res.setHeader('content-type', 'application/javascript');
|
res.setHeader('content-type', 'application/javascript');
|
||||||
|
res.send(`describe(${JSON.stringify(path.basename(file))}, function () {\n${content}\n});`);
|
||||||
|
} else {
|
||||||
|
res.sendFile(file);
|
||||||
}
|
}
|
||||||
res.send(content);
|
|
||||||
})().catch((err) => next(err || new Error(err)));
|
})().catch((err) => next(err || new Error(err)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue