Skip to content

Commit

Permalink
Introduce jest test setup file
Browse files Browse the repository at this point in the history
A setup file for tests is added to prepare tests.

Signed-off-by: Benedikt Richter <[email protected]>
  • Loading branch information
benedikt-richter committed Dec 23, 2021
1 parent 0e587e2 commit 64af3c8
Show file tree
Hide file tree
Showing 20 changed files with 10 additions and 22 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Expand Down
6 changes: 6 additions & 0 deletions setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: Facebook, Inc. and its affiliates
// SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
//
// SPDX-License-Identifier: Apache-2.0

require('@testing-library/jest-dom/extend-expect');
Original file line number Diff line number Diff line change
Expand Up @@ -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<MainButtonConfig> = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContextMenuItem> = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
1 change: 0 additions & 1 deletion src/Frontend/test-helpers/general-test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 64af3c8

Please sign in to comment.