2024-01-15 11:35:23 +00:00
|
|
|
const path = require('path');
|
2024-01-25 23:09:24 +00:00
|
|
|
const Myt = require('@verdnatura/myt/myt');
|
|
|
|
const Run = require('@verdnatura/myt/myt-run');
|
2022-05-11 17:38:10 +00:00
|
|
|
let dataSources = require('../loopback/server/datasources.json');
|
2018-12-21 11:50:28 +00:00
|
|
|
|
2024-01-15 11:35:23 +00:00
|
|
|
let myt;
|
|
|
|
|
2017-09-10 18:04:22 +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
|
|
|
|
2023-12-07 19:05:54 +00:00
|
|
|
process.on('SIGUSR2', async() => {
|
2024-01-15 11:35:23 +00:00
|
|
|
if (myt) await myt.deinit();
|
2023-12-07 19:05:54 +00:00
|
|
|
});
|
|
|
|
|
2022-10-06 09:32:13 +00:00
|
|
|
process.on('exit', async function() {
|
2024-01-15 11:35:23 +00:00
|
|
|
if (myt) await myt.deinit();
|
2022-10-06 09:32:13 +00:00
|
|
|
});
|
|
|
|
|
2022-05-11 17:38:10 +00:00
|
|
|
async function test() {
|
2024-01-15 11:35:23 +00:00
|
|
|
const isCI = process.argv[2] === 'ci';
|
2017-09-08 12:37:55 +00:00
|
|
|
|
2024-01-15 11:35:23 +00:00
|
|
|
myt = new Myt();
|
|
|
|
await myt.init({
|
|
|
|
workspace: path.join(__dirname, '..'),
|
|
|
|
random: true,
|
2024-01-28 11:40:13 +00:00
|
|
|
ci: isCI,
|
|
|
|
network: isCI ? 'jenkins' : null
|
2024-01-15 11:35:23 +00:00
|
|
|
});
|
|
|
|
const {dbConfig} = await myt.run(Run);
|
2017-09-08 12:37:55 +00:00
|
|
|
|
2022-05-11 17:38:10 +00:00
|
|
|
dataSources = JSON.parse(JSON.stringify(dataSources));
|
|
|
|
Object.assign(dataSources.vn, {
|
2024-01-15 11:35:23 +00:00
|
|
|
host: dbConfig.host,
|
|
|
|
port: dbConfig.port
|
2022-05-11 17:38:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const bootOptions = {dataSources};
|
|
|
|
const app = require('vn-loopback/server/server');
|
2023-02-28 10:19:41 +00:00
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
app.boot(bootOptions,
|
|
|
|
err => err ? reject(err) : resolve());
|
|
|
|
});
|
2023-05-11 11:54:42 +00:00
|
|
|
// FIXME: Workaround to wait for loopback to be ready
|
|
|
|
await app.models.Application.status();
|
2022-05-13 09:44:04 +00:00
|
|
|
|
2022-05-13 10:51:02 +00:00
|
|
|
const Jasmine = require('jasmine');
|
|
|
|
const jasmine = new Jasmine();
|
|
|
|
|
2022-05-13 09:44:04 +00:00
|
|
|
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
2022-05-13 10:51:02 +00:00
|
|
|
jasmine.addReporter(new SpecReporter({
|
2022-05-13 10:25:35 +00:00
|
|
|
spec: {
|
|
|
|
displaySuccessful: isCI,
|
|
|
|
displayPending: isCI
|
|
|
|
},
|
|
|
|
summary: {
|
|
|
|
displayPending: false,
|
|
|
|
}
|
2022-05-13 10:51:02 +00:00
|
|
|
}));
|
2022-05-13 10:25:35 +00:00
|
|
|
|
2022-10-05 11:32:43 +00:00
|
|
|
if (isCI) {
|
|
|
|
const JunitReporter = require('jasmine-reporters');
|
|
|
|
jasmine.addReporter(new JunitReporter.JUnitXmlReporter());
|
2022-05-13 10:25:35 +00:00
|
|
|
|
2022-10-05 11:38:17 +00:00
|
|
|
jasmine.exitOnCompletion = true;
|
2024-01-10 06:46:11 +00:00
|
|
|
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 900000;
|
2022-10-05 11:32:43 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
await jasmine.execute();
|
|
|
|
if (app) await app.disconnect();
|
2024-01-15 11:35:23 +00:00
|
|
|
if (myt) await myt.deinit();
|
2022-10-05 12:14:05 +00:00
|
|
|
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();
|