salix/back/tests.js

76 lines
1.8 KiB
JavaScript
Raw Normal View History

2022-05-11 17:38:10 +00:00
const Docker = require('../db/docker.js');
let dataSources = require('../loopback/server/datasources.json');
2018-12-21 11:50:28 +00:00
process.on('warning', warning => {
console.log(warning.name);
console.log(warning.message);
console.log(warning.stack);
});
2017-09-08 12:37:55 +00:00
2022-05-11 17:38:10 +00:00
async function test() {
let isCI = false;
2017-09-08 12:37:55 +00:00
2022-05-12 09:43:41 +00:00
if (process.argv[2] === 'ci')
isCI = true;
2017-09-08 12:37:55 +00:00
2022-05-11 17:38:10 +00:00
const container = new Docker();
2017-09-08 12:37:55 +00:00
await container.run(isCI);
2022-05-11 17:38:10 +00:00
dataSources = JSON.parse(JSON.stringify(dataSources));
2018-12-21 11:50:28 +00:00
2022-05-11 17:38:10 +00:00
Object.assign(dataSources.vn, {
host: container.dbConf.host,
port: container.dbConf.port
});
const bootOptions = {dataSources};
const app = require('vn-loopback/server/server');
2022-05-13 09:44:04 +00:00
app.boot(bootOptions);
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
2022-05-13 10:44:21 +00:00
const specReporter = new SpecReporter({
2022-05-13 10:25:35 +00:00
spec: {
displaySuccessful: isCI,
displayPending: isCI
},
summary: {
displayPending: false,
}
2022-05-13 10:44:21 +00:00
});
const reporters = [specReporter];
2022-05-13 10:25:35 +00:00
if (isCI) {
2022-05-13 10:44:21 +00:00
const JunitReporter = require('jasmine-reporters');
const junitReporter = new JunitReporter.JUnitXmlReporter();
reporters.push(junitReporter);
2022-05-13 10:25:35 +00:00
}
const Jasmine = require('jasmine');
const jasmine = new Jasmine({
2022-05-13 10:33:08 +00:00
reporter: reporters
2022-05-13 10:25:35 +00:00
});
if (isCI) jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
2022-05-13 09:44:04 +00:00
const backSpecs = [
'./back/**/*[sS]pec.js',
'./loopback/**/*[sS]pec.js',
'./modules/*/back/**/*.[sS]pec.js'
];
jasmine.loadConfig({
spec_dir: '.',
spec_files: backSpecs,
2022-05-13 09:51:45 +00:00
helpers: [],
2022-05-13 09:37:31 +00:00
});
2022-05-13 09:44:04 +00:00
jasmine.exitOnCompletion = false;
await jasmine.execute();
if (app) await app.disconnect();
if (container) await container.rm();
console.log('app disconnected & container removed');
2022-05-11 17:38:10 +00:00
}
2017-09-08 12:37:55 +00:00
2022-05-11 17:38:10 +00:00
test();