79 lines
1.9 KiB
JavaScript
79 lines
1.9 KiB
JavaScript
const Docker = require('../db/docker.js');
|
|
let dataSources = require('../loopback/server/datasources.json');
|
|
|
|
process.on('warning', warning => {
|
|
console.log(warning.name);
|
|
console.log(warning.message);
|
|
console.log(warning.stack);
|
|
});
|
|
|
|
process.on('exit', async function() {
|
|
if (container) await container.rm();
|
|
});
|
|
|
|
let container;
|
|
async function test() {
|
|
let isCI = false;
|
|
|
|
if (process.argv[2] === 'ci')
|
|
isCI = true;
|
|
|
|
container = new Docker();
|
|
|
|
await container.run(isCI);
|
|
dataSources = JSON.parse(JSON.stringify(dataSources));
|
|
|
|
Object.assign(dataSources.vn, {
|
|
host: container.dbConf.host,
|
|
port: container.dbConf.port
|
|
});
|
|
|
|
const bootOptions = {dataSources};
|
|
const app = require('vn-loopback/server/server');
|
|
await new Promise((resolve, reject) => {
|
|
app.boot(bootOptions,
|
|
err => err ? reject(err) : resolve());
|
|
});
|
|
|
|
const Jasmine = require('jasmine');
|
|
const jasmine = new Jasmine();
|
|
|
|
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
|
jasmine.addReporter(new SpecReporter({
|
|
spec: {
|
|
displaySuccessful: isCI,
|
|
displayPending: isCI
|
|
},
|
|
summary: {
|
|
displayPending: false,
|
|
}
|
|
}));
|
|
|
|
if (isCI) {
|
|
const JunitReporter = require('jasmine-reporters');
|
|
jasmine.addReporter(new JunitReporter.JUnitXmlReporter());
|
|
|
|
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
|
|
jasmine.exitOnCompletion = true;
|
|
}
|
|
|
|
const backSpecs = [
|
|
'./back/**/*[sS]pec.js',
|
|
'./loopback/**/*[sS]pec.js',
|
|
'./modules/*/back/**/*.[sS]pec.js'
|
|
];
|
|
|
|
jasmine.loadConfig({
|
|
spec_dir: '.',
|
|
spec_files: backSpecs,
|
|
helpers: [],
|
|
});
|
|
|
|
await jasmine.execute();
|
|
if (app) await app.disconnect();
|
|
if (container) await container.rm();
|
|
console.log('App disconnected & container removed');
|
|
}
|
|
|
|
test();
|