tests: Switch to promisified `readFile`

pull/5050/head
Richard Hansen 2021-05-09 16:36:47 -04:00
parent 6cf27a7133
commit 998e77ec25
1 changed files with 6 additions and 9 deletions

View File

@ -46,20 +46,17 @@ exports.expressCreateServer = (hookName, args, cb) => {
return filePath;
};
args.app.get('/tests/frontend/specs/*', (req, res) => {
const specFilePath = url2FilePath(req.url);
const specFileName = path.basename(specFilePath);
fs.readFile(specFilePath, (err, content) => {
if (err) { return res.send(500); }
args.app.get('/tests/frontend/specs/*', (req, res, next) => {
(async () => {
const specFilePath = url2FilePath(req.url);
const specFileName = path.basename(specFilePath);
let content = await fsp.readFile(specFilePath);
content = `describe(${JSON.stringify(specFileName)}, function(){${content}});`;
if (!specFilePath.endsWith('index.html')) {
res.setHeader('content-type', 'application/javascript');
}
res.send(content);
});
})().catch((err) => next(err || new Error(err)));
});
args.app.get('/tests/frontend/*', (req, res) => {