From a5d262671d5c23624d3fb2031daccb4e313dbad1 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 29 Mar 2024 22:19:23 +0100 Subject: [PATCH] refs #6436 feat: extend BeforeAll --- back/tests-helper.js | 14 ++++++++++++-- back/tests.js | 3 +-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/back/tests-helper.js b/back/tests-helper.js index b88fa1fd6..e4878c4a2 100644 --- a/back/tests-helper.js +++ b/back/tests-helper.js @@ -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(); + diff --git a/back/tests.js b/back/tests.js index 50698eb92..f446b3483 100644 --- a/back/tests.js +++ b/back/tests.js @@ -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();