Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix local jest run #3218

Merged
merged 14 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 41 additions & 28 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,49 @@
const reportPortalConfig = [
'@reportportal/agent-js-jest',
{
apiKey: process.env.REPORTPORTAL_API_KEY,
endpoint: process.env.REPORTPORTAL_ENDPOINT,
project: process.env.REPORTPORTAL_PROJECT,
launch: 'data-visualizer-app',
attributes: [
{
key: 'dhis2_version',
value: 'master',
},
{
key: 'app_name',
value: 'data-visualizer-app',
},
{
key: 'test_level',
value: 'unit/integration',
},
{
key: 'BRANCH_NAME',
value: process.env.BRANCH_NAME,
},
{
key: 'CI_BUILD_ID',
value: process.env.CI_BUILD_ID,
},
{
key: 'PR_TITLE',
value: process.env.PR_TITLE,
},
],
description: '',
debug: false,
},
]

const isGithubActionsRun = process.env.CI === 'true'

module.exports = {
transformIgnorePatterns: [
'node_modules/(?!(lodash-es|@dhis2/d2-ui-[a-z-]+)/)',
],
setupFilesAfterEnv: ['./config/testSetup.js'],

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: 'data_visualizer_app_master',
attributes: [
{
key: 'version',
value: 'master',
},
{
key: 'app_name',
value: 'data_visualizer_app',
},
{
key: 'test_level',
value: 'unit/integration',
},
],
description: '',
debug: true,
},
],
],
reporters: ['default', ...(isGithubActionsRun ? [reportPortalConfig] : [])],
}
6 changes: 5 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export {
}

const logError = (action, error) => {
console.log(`Error in action ${action}: ${error}`)
const isJestTestRun = process.env.JEST_WORKER_ID !== undefined

if (!isJestTestRun) {
console.log(`Error in action ${action}: ${error}`)
}
}

const adaptAxisItems = (axis) =>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ describe('VisualizationPlugin', () => {
})

it('calls onResponsesReceived callback', async () => {
await canvas()
await canvas({
visualization: {
...defaultCurrentMock,
},
})

expect(defaultProps.onResponsesReceived).toHaveBeenCalled()
expect(defaultProps.onResponsesReceived).toHaveBeenCalledWith([
Expand All @@ -179,13 +183,14 @@ describe('VisualizationPlugin', () => {
const period = 'eons ago'

await canvas({
filters: {
visualization: {
...defaultCurrentMock,
relativePeriodDate: period,
},
})

expect(api.apiFetchAnalytics).toHaveBeenCalled()
expect(api.apiFetchAnalytics.mock.calls[0][2]).toHaveProperty(
expect(api.apiFetchAnalytics.mock.calls[0][1]).toHaveProperty(
'relativePeriodDate',
period
)
Expand Down
1 change: 1 addition & 0 deletions src/components/__tests__/App.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { UnconnectedApp as App } from '../App.js'
import { Snackbar } from '../Snackbar/Snackbar.js'

jest.mock('@dhis2/analytics', () => ({
...jest.requireActual('@dhis2/analytics'),
HendrikThePendric marked this conversation as resolved.
Show resolved Hide resolved
apiFetchOrganisationUnitLevels: jest.fn(),
getPredefinedDimensions: () => {},
visTypeDisplayNames: {},
Expand Down
Loading
Loading