authelia/scripts/authelia-scripts-unittest

49 lines
1.1 KiB
Plaintext
Raw Normal View History

2019-02-22 09:27:54 +00:00
#!/usr/bin/env node
var program = require('commander');
var spawn = require('child_process').spawn;
program
.option('--forbid-only', 'Forbid only and pending filters.')
2019-02-22 09:27:54 +00:00
.parse(process.argv);
async function runTests(patterns) {
2019-02-22 09:27:54 +00:00
return new Promise((resolve, reject) => {
let mochaArgs = ['--require', 'ts-node/register', '--require', './spec-helper.js', '--colors'];
if (program.forbidOnly) {
mochaArgs = ['--forbid-only', '--forbid-pending'].concat(mochaArgs);
}
const mocha = spawn('./node_modules/.bin/mocha', mochaArgs.concat(patterns), {
2019-02-22 09:27:54 +00:00
env: {
...process.env,
'TS_NODE_PROJECT': './server/tsconfig.json'
}
});
mocha.stdout.pipe(process.stdout);
mocha.stderr.pipe(process.stderr);
mocha.on('exit', (status) => {
if (status == 0) {
resolve();
}
reject(new Error('Status code ' + status));
});
});
}
async function test() {
await runTests([
'server/src/**/*.spec.ts',
'shared/**/*.spec.ts'
]);
2019-02-22 09:27:54 +00:00
}
test()
.then(() => {
process.exit(0);
}, (err) => {
process.exit(1);
});