From c2bda7425f30498e56bd0532827a08d1bd662ed0 Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Mon, 11 Dec 2023 14:05:33 +0100 Subject: [PATCH] chore(report-portal): run reports only when env is setup --- jest.config.js | 57 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/jest.config.js b/jest.config.js index cc2ddffb6..e3850c4d3 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,34 @@ +const reportPortalConfig = [ + '@reportportal/agent-js-jest', + { + apiKey: process.env.REPORTPORTAL_API_KEY, + endpoint: process.env.REPORTPORTAL_ENDPOINT, + project: process.env.REPORTPORTAL_PROJECT, + launch: 'aggregate_data_entry_app_master', + attributes: [ + { + key: 'version', + value: 'master', + }, + { + key: 'app_name', + value: 'aggregate_data_entry_app', + }, + { + key: 'test_level', + value: 'unit/integration', + }, + ], + description: '', + debug: true, + }, +] + +const isReportPortalSetup = + process.env.REPORTPORTAL_API_KEY !== undefined && + process.env.REPORTPORTAL_ENDPOINT !== undefined && + process.env.REPORTPORTAL_PROJECT !== undefined + module.exports = { setupFilesAfterEnv: ['/src/test-utils/setup-tests.js'], collectCoverageFrom: ['src/**/*.{js,jsx}'], @@ -12,30 +43,6 @@ module.exports = { testRunner: 'jest-circus/runner', reporters: [ 'default', - [ - '@reportportal/agent-js-jest', - { - apiKey: process.env.REPORTPORTAL_API_KEY, - endpoint: process.env.REPORTPORTAL_ENDPOINT, - project: process.env.REPORTPORTAL_PROJECT, - launch: 'aggregate_data_entry_app_master', - attributes: [ - { - key: 'version', - value: 'master', - }, - { - key: 'app_name', - value: 'aggregate_data_entry_app', - }, - { - key: 'test_level', - value: 'unit/integration', - }, - ], - description: '', - debug: true, - }, - ], + ...(isReportPortalSetup ? [reportPortalConfig] : []), ], }