2024-02-09 08:23:00 +00:00
|
|
|
/* eslint-disable no-console */
|
2022-05-13 15:09:41 +00:00
|
|
|
require('@babel/register')({presets: ['@babel/env']});
|
|
|
|
require('core-js/stable');
|
|
|
|
require('regenerator-runtime/runtime');
|
2023-01-25 09:10:25 +00:00
|
|
|
require('vn-loopback/server/boot/date')();
|
2024-02-09 08:23:00 +00:00
|
|
|
const getopts = require('getopts');
|
2022-05-13 15:09:41 +00:00
|
|
|
|
2024-01-25 23:09:24 +00:00
|
|
|
const path = require('path');
|
|
|
|
const Myt = require('@verdnatura/myt/myt');
|
|
|
|
const Run = require('@verdnatura/myt/myt-run');
|
|
|
|
|
2022-05-13 15:09:41 +00:00
|
|
|
const axios = require('axios');
|
2024-02-13 15:21:01 +00:00
|
|
|
const e2eConfig = require('./helpers/config.js');
|
2022-05-13 15:09:41 +00:00
|
|
|
const log = require('fancy-log');
|
|
|
|
|
|
|
|
process.on('warning', warning => {
|
|
|
|
console.log(warning.name);
|
|
|
|
console.log(warning.message);
|
|
|
|
console.log(warning.stack);
|
|
|
|
});
|
|
|
|
|
|
|
|
async function test() {
|
2024-02-09 08:23:00 +00:00
|
|
|
const opts = getopts(process.argv.slice(2), {
|
|
|
|
boolean: ['show']
|
|
|
|
});
|
2024-02-13 15:21:01 +00:00
|
|
|
if (opts.show)
|
|
|
|
process.env.E2E_SHOW = true;
|
2022-05-13 15:09:41 +00:00
|
|
|
|
2024-02-09 08:23:00 +00:00
|
|
|
console.log('Building and running DB container.');
|
2024-01-25 23:09:24 +00:00
|
|
|
const myt = new Myt();
|
2024-02-13 15:21:01 +00:00
|
|
|
await myt.init({workspace: path.join(__dirname, '..')});
|
2024-01-25 23:09:24 +00:00
|
|
|
await myt.run(Run);
|
2024-02-09 08:23:00 +00:00
|
|
|
await myt.deinit();
|
2022-05-13 15:09:41 +00:00
|
|
|
|
|
|
|
const Jasmine = require('jasmine');
|
|
|
|
const jasmine = new Jasmine();
|
|
|
|
|
|
|
|
const specFiles = [
|
2024-07-08 10:00:36 +00:00
|
|
|
`./e2e/paths/01*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/02*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/03*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/04*/*[sS]pec.js`,
|
2022-05-13 15:09:41 +00:00
|
|
|
`./e2e/paths/05*/*[sS]pec.js`,
|
2024-07-08 10:00:36 +00:00
|
|
|
`./e2e/paths/06*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/07*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/08*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/09*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/10*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/11*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/12*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/13*/*[sS]pec.js`,
|
|
|
|
`./e2e/paths/**/*[sS]pec.js`
|
2022-05-13 15:09:41 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
jasmine.loadConfig({
|
|
|
|
spec_dir: '.',
|
|
|
|
spec_files: specFiles,
|
|
|
|
helpers: [],
|
|
|
|
random: false,
|
|
|
|
});
|
|
|
|
|
2024-01-25 13:58:48 +00:00
|
|
|
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
|
|
|
jasmine.addReporter(new SpecReporter({
|
|
|
|
spec: {
|
|
|
|
displaySuccessful: false,
|
|
|
|
displayPending: false,
|
|
|
|
displayDuration: false,
|
|
|
|
displayFailed: true,
|
|
|
|
displayErrorMessages: true,
|
|
|
|
},
|
|
|
|
summary: {
|
|
|
|
displayPending: false,
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2022-05-13 15:09:41 +00:00
|
|
|
await backendStatus();
|
|
|
|
|
|
|
|
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
|
|
|
await jasmine.execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function backendStatus() {
|
2024-02-09 08:23:00 +00:00
|
|
|
log('Awaiting backend connection.');
|
2022-05-13 15:09:41 +00:00
|
|
|
|
|
|
|
const milliseconds = 1000;
|
|
|
|
const maxAttempts = 10;
|
|
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
let timer;
|
|
|
|
let attempts = 1;
|
|
|
|
timer = setInterval(async() => {
|
|
|
|
try {
|
|
|
|
attempts++;
|
|
|
|
const url = `${e2eConfig.url}/api/Applications/status`;
|
|
|
|
const {data} = await axios.get(url);
|
|
|
|
|
|
|
|
if (data == true) {
|
|
|
|
clearInterval(timer);
|
|
|
|
log('Backend connection stablished!');
|
|
|
|
resolve(attempts);
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
if (error && attempts >= maxAttempts) {
|
|
|
|
log('Could not connect to backend');
|
|
|
|
process.exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, milliseconds);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
test();
|