diff --git a/package.json b/package.json index f2f72e7fe..e9d281c69 100644 --- a/package.json +++ b/package.json @@ -87,10 +87,10 @@ "build:dev:win32": "yarn generate-notice && cross-env DISABLE_ESLINT_PLUGIN=true react-scripts build && tsc -p src/ElectronBackend", "build:prod": "yarn generate-notice && react-scripts build && tsc -p src/ElectronBackend", "compile-all": "tsc -p ./ && tsc --noEmit -p src/ElectronBackend", - "test:unit": "react-scripts test --watchAll=false --testPathIgnorePatterns=src/e2e-tests --testPathIgnorePatterns=src/Frontend/integration-tests", - "test:local": "react-scripts test --watchAll=false src/ --testPathIgnorePatterns=src/e2e-tests --testMatch=[ \"**/__tests__/**/*.ts?(x)\" ]", - "test:all": "react-scripts test --watchAll=false src/ --testPathIgnorePatterns=src/e2e-tests --testMatch=[ \"**/__(tests|tests-ci)__/**/*.ts?(x)\", \"**/?(*.)+(test).ts?(x)\" ] && yarn test:e2e", - "test:integration-ci": "react-scripts test --watchAll=false src/Frontend/integration-tests --testMatch=[ \"**/__(tests|tests-ci)__/**/*.ts?(x)\", \"**/?(*.)+(test).ts?(x)\" ]", + "test:unit": "react-scripts test --watchAll=false --setupFilesAfterEnv=./setupTests.js --testPathIgnorePatterns=src/e2e-tests --testPathIgnorePatterns=src/Frontend/integration-tests", + "test:local": "react-scripts test --watchAll=false src/ --setupFilesAfterEnv=./setupTests.js --testPathIgnorePatterns=src/e2e-tests --testMatch=[ \"**/__tests__/**/*.ts?(x)\" ]", + "test:all": "react-scripts test --watchAll=false src/ --setupFilesAfterEnv=./setupTests.js --testPathIgnorePatterns=src/e2e-tests --testMatch=[ \"**/__(tests|tests-ci)__/**/*.ts?(x)\", \"**/?(*.)+(test).ts?(x)\" ] && yarn test:e2e", + "test:integration-ci": "react-scripts test --watchAll=false src/Frontend/integration-tests --setupFilesAfterEnv=./setupTests.js --testMatch=[ \"**/__(tests|tests-ci)__/**/*.ts?(x)\", \"**/?(*.)+(test).ts?(x)\" ]", "test:e2e": "run-script-os", "test:e2e:darwin:linux": "concurrently -s first -k true \"yarn build:dev; BROWSER=none react-scripts start\" \"wait-on http://127.0.0.1:3000 && react-scripts test --watchAll=false --detectOpenHandles --forceExit src/e2e-tests\"", "test:e2e:win32": "concurrently -s first -k true \"yarn build:dev & cross-env BROWSER=none react-scripts start\" \"wait-on http://127.0.0.1:3000 && react-scripts test --watchAll=false --detectOpenHandles --forceExit src/e2e-tests\"", diff --git a/setupTests.js b/setupTests.js new file mode 100644 index 000000000..7e3f72424 --- /dev/null +++ b/setupTests.js @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: Facebook, Inc. and its affiliates +// SPDX-FileCopyrightText: TNG Technology Consulting GmbH +// +// SPDX-License-Identifier: Apache-2.0 + +require('@testing-library/jest-dom/extend-expect'); diff --git a/src/Frontend/Components/ButtonGroup/__tests__/ButtonGroup.test.tsx b/src/Frontend/Components/ButtonGroup/__tests__/ButtonGroup.test.tsx index 5c9503496..3b828216e 100644 --- a/src/Frontend/Components/ButtonGroup/__tests__/ButtonGroup.test.tsx +++ b/src/Frontend/Components/ButtonGroup/__tests__/ButtonGroup.test.tsx @@ -9,7 +9,6 @@ import { fireEvent, render, screen } from '@testing-library/react'; import { doNothing } from '../../../util/do-nothing'; import { ButtonText } from '../../../enums/enums'; import { ContextMenuItem } from '../../ContextMenu/ContextMenu'; -import '@testing-library/jest-dom/extend-expect'; describe('Button group', () => { const mainButtonConfigs: Array = [ diff --git a/src/Frontend/Components/ConfirmDeletionGloballyPopup/__tests__/ConfirmDeletionGloballyPopup.test.tsx b/src/Frontend/Components/ConfirmDeletionGloballyPopup/__tests__/ConfirmDeletionGloballyPopup.test.tsx index 2c7881e28..db792f32f 100644 --- a/src/Frontend/Components/ConfirmDeletionGloballyPopup/__tests__/ConfirmDeletionGloballyPopup.test.tsx +++ b/src/Frontend/Components/ConfirmDeletionGloballyPopup/__tests__/ConfirmDeletionGloballyPopup.test.tsx @@ -7,7 +7,6 @@ import { renderComponentWithStore } from '../../../test-helpers/render-component import { screen } from '@testing-library/react'; import React from 'react'; import { ConfirmDeletionGloballyPopup } from '../ConfirmDeletionGloballyPopup'; -import '@testing-library/jest-dom/extend-expect'; describe('The ConfirmDeletionGloballyPopup', () => { test('renders', () => { diff --git a/src/Frontend/Components/ConfirmDeletionPopup/__tests__/ConfirmDeletionPopup.test.tsx b/src/Frontend/Components/ConfirmDeletionPopup/__tests__/ConfirmDeletionPopup.test.tsx index 63050f0c0..e3ae6a99e 100644 --- a/src/Frontend/Components/ConfirmDeletionPopup/__tests__/ConfirmDeletionPopup.test.tsx +++ b/src/Frontend/Components/ConfirmDeletionPopup/__tests__/ConfirmDeletionPopup.test.tsx @@ -7,7 +7,6 @@ import { renderComponentWithStore } from '../../../test-helpers/render-component import { screen } from '@testing-library/react'; import React from 'react'; import { ConfirmDeletionPopup } from '../ConfirmDeletionPopup'; -import '@testing-library/jest-dom/extend-expect'; describe('The ConfirmDeletionPopup', () => { test('renders', () => { diff --git a/src/Frontend/Components/ConfirmationPopup/__tests__/ConfirmationPopup.test.tsx b/src/Frontend/Components/ConfirmationPopup/__tests__/ConfirmationPopup.test.tsx index 0d46df4bb..27dc53c6c 100644 --- a/src/Frontend/Components/ConfirmationPopup/__tests__/ConfirmationPopup.test.tsx +++ b/src/Frontend/Components/ConfirmationPopup/__tests__/ConfirmationPopup.test.tsx @@ -8,7 +8,6 @@ import { ConfirmationPopup } from '../ConfirmationPopup'; import { fireEvent, screen } from '@testing-library/react'; import React from 'react'; import { ButtonText } from '../../../enums/enums'; -import '@testing-library/jest-dom/extend-expect'; describe('The ConfirmationPopup', () => { test('renders and calls onClick function', () => { diff --git a/src/Frontend/Components/ContextMenu/__tests__/ContextMenu.test.tsx b/src/Frontend/Components/ContextMenu/__tests__/ContextMenu.test.tsx index db0ce93f1..4b9d29cd3 100644 --- a/src/Frontend/Components/ContextMenu/__tests__/ContextMenu.test.tsx +++ b/src/Frontend/Components/ContextMenu/__tests__/ContextMenu.test.tsx @@ -8,7 +8,6 @@ import { fireEvent, render, screen } from '@testing-library/react'; import { ButtonText } from '../../../enums/enums'; import { doNothing } from '../../../util/do-nothing'; import { ContextMenu, ContextMenuItem } from '../ContextMenu'; -import '@testing-library/jest-dom/extend-expect'; const onClickMock = jest.fn(); const testMenuItems: Array = [ diff --git a/src/Frontend/Components/ErrorBoundary/__tests__/ErrorBoundary.test.tsx b/src/Frontend/Components/ErrorBoundary/__tests__/ErrorBoundary.test.tsx index 7309f6ba9..601632c30 100644 --- a/src/Frontend/Components/ErrorBoundary/__tests__/ErrorBoundary.test.tsx +++ b/src/Frontend/Components/ErrorBoundary/__tests__/ErrorBoundary.test.tsx @@ -11,7 +11,6 @@ import { renderComponentWithStore } from '../../../test-helpers/render-component import { ErrorBoundary } from '../ErrorBoundary'; import { IpcChannel } from '../../../../shared/ipc-channels'; import { screen } from '@testing-library/react'; -import '@testing-library/jest-dom/extend-expect'; let originalIpcRenderer: IpcRenderer; diff --git a/src/Frontend/Components/ErrorPopup/__tests__/ErrorPopup.test.tsx b/src/Frontend/Components/ErrorPopup/__tests__/ErrorPopup.test.tsx index 7ba5c08f7..b903e2886 100644 --- a/src/Frontend/Components/ErrorPopup/__tests__/ErrorPopup.test.tsx +++ b/src/Frontend/Components/ErrorPopup/__tests__/ErrorPopup.test.tsx @@ -7,7 +7,6 @@ import React from 'react'; import { renderComponentWithStore } from '../../../test-helpers/render-component-with-store'; import { ErrorPopup } from '../ErrorPopup'; import { screen } from '@testing-library/react'; -import '@testing-library/jest-dom/extend-expect'; describe('Error popup ', () => { test('renders', () => { diff --git a/src/Frontend/Components/FetchLicenseInformationButton/__tests__/FetchLicenseInformationButton.test.tsx b/src/Frontend/Components/FetchLicenseInformationButton/__tests__/FetchLicenseInformationButton.test.tsx index 5ab5237c7..e4694c8d5 100644 --- a/src/Frontend/Components/FetchLicenseInformationButton/__tests__/FetchLicenseInformationButton.test.tsx +++ b/src/Frontend/Components/FetchLicenseInformationButton/__tests__/FetchLicenseInformationButton.test.tsx @@ -19,7 +19,6 @@ import { Store } from 'redux'; import { Provider } from 'react-redux'; import { act, renderHook } from '@testing-library/react-hooks'; import { getTemporaryPackageInfo } from '../../../state/selectors/all-views-resource-selectors'; -import '@testing-library/jest-dom/extend-expect'; describe('FetchLicenseInformationButton', () => { it('renders disabled button', () => { diff --git a/src/Frontend/Components/FilteredList/__tests__/FilteredList.test.tsx b/src/Frontend/Components/FilteredList/__tests__/FilteredList.test.tsx index c5b175d47..d9e11d32f 100644 --- a/src/Frontend/Components/FilteredList/__tests__/FilteredList.test.tsx +++ b/src/Frontend/Components/FilteredList/__tests__/FilteredList.test.tsx @@ -8,7 +8,6 @@ import React, { ReactElement } from 'react'; import { Attributions } from '../../../../shared/shared-types'; import { renderComponentWithStore } from '../../../test-helpers/render-component-with-store'; import { FilteredList } from '../FilteredList'; -import '@testing-library/jest-dom/extend-expect'; describe('The FilteredList', () => { test('has search functionality', () => { diff --git a/src/Frontend/Components/ListCard/__tests__/ListCard.test.tsx b/src/Frontend/Components/ListCard/__tests__/ListCard.test.tsx index 365f3198b..fc4b9de10 100644 --- a/src/Frontend/Components/ListCard/__tests__/ListCard.test.tsx +++ b/src/Frontend/Components/ListCard/__tests__/ListCard.test.tsx @@ -8,7 +8,6 @@ import { render, screen } from '@testing-library/react'; import { doNothing } from '../../../util/do-nothing'; import { ListCard } from '../ListCard'; import { Checkbox } from '../../Checkbox/Checkbox'; -import '@testing-library/jest-dom/extend-expect'; describe('The ListCard', () => { test('renders text with no count', () => { diff --git a/src/Frontend/Components/NotificationPopup/__tests__/NotificationPopup.test.tsx b/src/Frontend/Components/NotificationPopup/__tests__/NotificationPopup.test.tsx index 661e44cab..980afa8c8 100644 --- a/src/Frontend/Components/NotificationPopup/__tests__/NotificationPopup.test.tsx +++ b/src/Frontend/Components/NotificationPopup/__tests__/NotificationPopup.test.tsx @@ -6,7 +6,6 @@ import { fireEvent, render, screen } from '@testing-library/react'; import React from 'react'; import { NotificationPopup } from '../NotificationPopup'; -import '@testing-library/jest-dom/extend-expect'; describe('NotificationPopup', () => { test('renders open popup with text', () => { diff --git a/src/Frontend/Components/ProgressBar/__tests__/ProgressBar.test.tsx b/src/Frontend/Components/ProgressBar/__tests__/ProgressBar.test.tsx index e1deae595..ac720d165 100644 --- a/src/Frontend/Components/ProgressBar/__tests__/ProgressBar.test.tsx +++ b/src/Frontend/Components/ProgressBar/__tests__/ProgressBar.test.tsx @@ -14,7 +14,6 @@ import { import { renderComponentWithStore } from '../../../test-helpers/render-component-with-store'; import { ProgressBar } from '../ProgressBar'; import { setProgressBarData } from '../../../state/actions/resource-actions/all-views-simple-actions'; -import '@testing-library/jest-dom/extend-expect'; describe('ProgressBar', () => { jest.useFakeTimers(); diff --git a/src/Frontend/Components/ProjectMetadataPopup/__tests__/ProjectMetadataPopup.test.tsx b/src/Frontend/Components/ProjectMetadataPopup/__tests__/ProjectMetadataPopup.test.tsx index db16dfa81..56c445bf1 100644 --- a/src/Frontend/Components/ProjectMetadataPopup/__tests__/ProjectMetadataPopup.test.tsx +++ b/src/Frontend/Components/ProjectMetadataPopup/__tests__/ProjectMetadataPopup.test.tsx @@ -12,7 +12,6 @@ import React from 'react'; import { ProjectMetadataPopup } from '../ProjectMetadataPopup'; import { ProjectMetadata } from '../../../../shared/shared-types'; import { setProjectMetadata } from '../../../state/actions/resource-actions/all-views-simple-actions'; -import '@testing-library/jest-dom/extend-expect'; describe('The ProjectMetadataPopup', () => { test('displays metadata', () => { diff --git a/src/Frontend/Components/ResourceBrowser/__tests__/ResourceBrowser.test.tsx b/src/Frontend/Components/ResourceBrowser/__tests__/ResourceBrowser.test.tsx index 9716f7473..ddd7d49e7 100644 --- a/src/Frontend/Components/ResourceBrowser/__tests__/ResourceBrowser.test.tsx +++ b/src/Frontend/Components/ResourceBrowser/__tests__/ResourceBrowser.test.tsx @@ -29,7 +29,6 @@ import { getSelectedResourceId } from '../../../state/selectors/audit-view-resou import { isEqual } from 'lodash'; import { addResolvedExternalAttribution } from '../../../state/actions/resource-actions/audit-view-simple-actions'; import { collapseFolderByClickingOnIcon } from '../../../test-helpers/resource-browser-test-helpers'; -import '@testing-library/jest-dom/extend-expect'; describe('ResourceBrowser', () => { test('renders working tree', () => { diff --git a/src/Frontend/Components/ResourcePathPopup/__tests__/ResourcePathPopup.test.tsx b/src/Frontend/Components/ResourcePathPopup/__tests__/ResourcePathPopup.test.tsx index d7d8e78fa..14fbe2009 100644 --- a/src/Frontend/Components/ResourcePathPopup/__tests__/ResourcePathPopup.test.tsx +++ b/src/Frontend/Components/ResourcePathPopup/__tests__/ResourcePathPopup.test.tsx @@ -21,7 +21,6 @@ import { import { setSelectedResourceId } from '../../../state/actions/resource-actions/audit-view-simple-actions'; import { screen } from '@testing-library/react'; import { useAppDispatch } from '../../../state/hooks'; -import '@testing-library/jest-dom/extend-expect'; interface HelperComponentProps { isExternalAttribution: boolean; diff --git a/src/Frontend/Components/ResourcesList/__tests__/ResourcesList.test.tsx b/src/Frontend/Components/ResourcesList/__tests__/ResourcesList.test.tsx index 6298a4c00..24a837d48 100644 --- a/src/Frontend/Components/ResourcesList/__tests__/ResourcesList.test.tsx +++ b/src/Frontend/Components/ResourcesList/__tests__/ResourcesList.test.tsx @@ -16,7 +16,6 @@ import { } from '../../../state/selectors/audit-view-resource-selectors'; import { setSelectedResourceId } from '../../../state/actions/resource-actions/audit-view-simple-actions'; import { ResourcesListBatch } from '../../../types/types'; -import '@testing-library/jest-dom/extend-expect'; describe('The ResourcesList', () => { const resourceIdsOfSelectedAttributionId = [ diff --git a/src/Frontend/Components/StyledTreeItemLabel/__tests__/StyledTreeItemLabel.test.tsx b/src/Frontend/Components/StyledTreeItemLabel/__tests__/StyledTreeItemLabel.test.tsx index d76b73ccc..cc419c57d 100644 --- a/src/Frontend/Components/StyledTreeItemLabel/__tests__/StyledTreeItemLabel.test.tsx +++ b/src/Frontend/Components/StyledTreeItemLabel/__tests__/StyledTreeItemLabel.test.tsx @@ -7,7 +7,6 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; import { StyledTreeItemLabel } from '../StyledTreeItemLabel'; -import '@testing-library/jest-dom/extend-expect'; describe('StyledTreeItemLabel', () => { test('renders a file without information', () => { diff --git a/src/Frontend/test-helpers/general-test-helpers.ts b/src/Frontend/test-helpers/general-test-helpers.ts index f2683618a..45048f031 100644 --- a/src/Frontend/test-helpers/general-test-helpers.ts +++ b/src/Frontend/test-helpers/general-test-helpers.ts @@ -4,7 +4,6 @@ // SPDX-License-Identifier: Apache-2.0 import { act, fireEvent, Screen, within } from '@testing-library/react'; -import '@testing-library/jest-dom/extend-expect'; import { Attributions, ParsedFileContent,