refs #6436 feat: extend BeforeAll

This commit is contained in:
Javier Segarra 2024-03-29 22:19:23 +01:00
parent bfb6b25d1a
commit a5d262671d
2 changed files with 13 additions and 4 deletions

View File

@ -10,7 +10,7 @@ async function init() {
host: process.env.DB_HOST,
port: process.env.DB_PORT
});
customBeforeAll();
const bootOptions = {dataSources};
await new Promise((resolve, reject) => {
app.boot(bootOptions,
@ -24,7 +24,16 @@ async function deinit() {
console.log('Stopping backend.');
await app.disconnect();
}
function customBeforeAll() {
Object.assign(beforeAll, {
ctx: {
req: {
accessToken: {userId: 9},
headers: {origin: 'http://localhost'},
}
}
});
}
module.exports = {
init,
deinit
@ -32,3 +41,4 @@ module.exports = {
if (require.main === module)
init();

View File

@ -84,13 +84,12 @@ async function test() {
'loopback/**/*[sS]pec.js',
'modules/*/back/**/*.[sS]pec.js'
],
helpers: []
helpers: [`back/tests-helper.js`]
};
if (PARALLEL) {
const ParallelRunner = require('jasmine/parallel');
runner = new ParallelRunner({numWorkers: 1});
config.helpers.push(`back/tests-helper.js`);
} else {
const Jasmine = require('jasmine');
runner = new Jasmine();