From 48e3c24c6e1946f2f5c9a069c22a5a41ad8f3202 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Fri, 14 Jun 2024 14:11:32 +0100 Subject: [PATCH] refactor: Update import statement for jest in setupTest.js This commit updates the import statement for jest in the setupTest.js file. The previous import statement used "globals" as the module name, which is incorrect. The correct module name is "jest". This change ensures that the jest module is imported correctly, improving the accuracy and reliability of the test setup. --- CommonUI/src/Tests/Components/404.test.tsx | 1 + CommonUI/src/Tests/Components/Alert.test.tsx | 1 + CommonUI/src/Tests/Components/Badge.test.tsx | 1 + CommonUI/src/Tests/Components/BasicForm.test.tsx | 1 + CommonUI/src/Tests/Components/Breadcrumbs.test.tsx | 2 +- CommonUI/src/Tests/Components/Button.test.tsx | 1 + CommonUI/src/Tests/Components/Card.test.tsx | 1 + CommonUI/src/Tests/Components/ColorViewer.test.tsx | 1 + CommonUI/src/Tests/Components/ComponentsModal.test.tsx | 1 - CommonUI/src/Tests/Components/Dropdown.test.tsx | 2 +- CommonUI/src/Tests/Components/DuplicateModel.test.tsx | 2 +- CommonUI/src/Tests/Components/Loader.test.tsx | 3 +-- CommonUI/src/Tests/Components/OrderedStatesList.test.tsx | 2 +- CommonUI/src/Tests/Components/Pagination.test.tsx | 2 +- CommonUI/src/Tests/Components/Pill.test.tsx | 2 +- CommonUI/src/Tests/Components/Probe.test.tsx | 2 +- CommonUI/src/Tests/Components/ProgressBar.test.tsx | 2 +- CommonUI/src/Tests/Components/RadioButtons.test.tsx | 2 +- CommonUI/src/Tests/Components/SideOver.test.tsx | 2 +- CommonUI/src/Tests/Components/Tabs.test.tsx | 2 +- CommonUI/src/Tests/Components/TextArea.test.tsx | 2 +- CommonUI/src/Tests/Components/Toast.test.tsx | 2 +- Probe/Tests/Utils/PingMonitor.test.skip.ts | 2 +- eslint.config.js | 1 + 24 files changed, 23 insertions(+), 17 deletions(-) diff --git a/CommonUI/src/Tests/Components/404.test.tsx b/CommonUI/src/Tests/Components/404.test.tsx index ff0372c1a1..55f66b6452 100644 --- a/CommonUI/src/Tests/Components/404.test.tsx +++ b/CommonUI/src/Tests/Components/404.test.tsx @@ -5,6 +5,7 @@ import Route from "Common/Types/API/Route"; import URL from "Common/Types/API/URL"; import Email from "Common/Types/Email"; import * as React from "react"; +import { describe, expect, jest } from "@jest/globals"; // Mock the Navigation module to avoid real navigation jest.mock("../../Utils/Navigation", () => { diff --git a/CommonUI/src/Tests/Components/Alert.test.tsx b/CommonUI/src/Tests/Components/Alert.test.tsx index d9e97cb6bc..170e40df48 100644 --- a/CommonUI/src/Tests/Components/Alert.test.tsx +++ b/CommonUI/src/Tests/Components/Alert.test.tsx @@ -2,6 +2,7 @@ import Alert, { AlertType } from "../../Components/Alerts/Alert"; import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render, screen } from "@testing-library/react"; import React from "react"; +import { describe, expect, jest } from "@jest/globals"; describe("alert tests", () => { test("it should render all props passed", () => { diff --git a/CommonUI/src/Tests/Components/Badge.test.tsx b/CommonUI/src/Tests/Components/Badge.test.tsx index 2e3622eec2..e93abc3b2e 100644 --- a/CommonUI/src/Tests/Components/Badge.test.tsx +++ b/CommonUI/src/Tests/Components/Badge.test.tsx @@ -2,6 +2,7 @@ import Badge, { BadgeType } from "../../Components/Badge/Badge"; import "@testing-library/jest-dom/extend-expect"; import { render, screen } from "@testing-library/react"; import React from "react"; +import { describe, expect, test } from "@jest/globals"; describe("Badge", () => { test("it should render all props", () => { diff --git a/CommonUI/src/Tests/Components/BasicForm.test.tsx b/CommonUI/src/Tests/Components/BasicForm.test.tsx index 5571bdb9bb..fa18e00d9a 100644 --- a/CommonUI/src/Tests/Components/BasicForm.test.tsx +++ b/CommonUI/src/Tests/Components/BasicForm.test.tsx @@ -8,6 +8,7 @@ import userEvent from "@testing-library/user-event"; import { UserEvent } from "@testing-library/user-event/dist/types/setup/setup"; import Route from "Common/Types/API/Route"; import * as React from "react"; +import { describe, expect, jest } from "@jest/globals"; describe("BasicForm test", () => { const fields: Fields> = [ diff --git a/CommonUI/src/Tests/Components/Breadcrumbs.test.tsx b/CommonUI/src/Tests/Components/Breadcrumbs.test.tsx index 6c872afef1..a79eaeaced 100644 --- a/CommonUI/src/Tests/Components/Breadcrumbs.test.tsx +++ b/CommonUI/src/Tests/Components/Breadcrumbs.test.tsx @@ -1,6 +1,6 @@ import Breadcrumbs from "../../Components/Breadcrumbs/Breadcrumbs"; import Navigation from "../../Utils/Navigation"; -import { describe, expect, test } from "@jest/globals"; +import { describe, expect, test, jest } from "@jest/globals"; import Route from "Common/Types/API/Route"; import Link from "Common/Types/Link"; import * as React from "react"; diff --git a/CommonUI/src/Tests/Components/Button.test.tsx b/CommonUI/src/Tests/Components/Button.test.tsx index a9abdfe0a7..d5bc1a685f 100644 --- a/CommonUI/src/Tests/Components/Button.test.tsx +++ b/CommonUI/src/Tests/Components/Button.test.tsx @@ -8,6 +8,7 @@ import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render, screen } from "@testing-library/react"; import IconProp from "Common/Types/Icon/IconProp"; import React from "react"; +import { describe, expect, jest } from "@jest/globals"; describe("Button", () => { test("it should render correctly with title and icon", () => { diff --git a/CommonUI/src/Tests/Components/Card.test.tsx b/CommonUI/src/Tests/Components/Card.test.tsx index 964807790b..8c1eea9d7e 100644 --- a/CommonUI/src/Tests/Components/Card.test.tsx +++ b/CommonUI/src/Tests/Components/Card.test.tsx @@ -7,6 +7,7 @@ import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render, screen } from "@testing-library/react"; import IconProp from "Common/Types/Icon/IconProp"; import React, { ReactElement } from "react"; +import { describe, expect, jest } from "@jest/globals"; describe("Card", () => { const props: ComponentProps = { diff --git a/CommonUI/src/Tests/Components/ColorViewer.test.tsx b/CommonUI/src/Tests/Components/ColorViewer.test.tsx index 85dd2c6aa2..5117ce5bde 100644 --- a/CommonUI/src/Tests/Components/ColorViewer.test.tsx +++ b/CommonUI/src/Tests/Components/ColorViewer.test.tsx @@ -3,6 +3,7 @@ import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render } from "@testing-library/react"; import Color from "Common/Types/Color"; import * as React from "react"; +import { describe, expect, jest } from "@jest/globals"; describe("Color Viewer", () => { test("Render the component", () => { diff --git a/CommonUI/src/Tests/Components/ComponentsModal.test.tsx b/CommonUI/src/Tests/Components/ComponentsModal.test.tsx index adc7fdb32d..9c2b461e05 100644 --- a/CommonUI/src/Tests/Components/ComponentsModal.test.tsx +++ b/CommonUI/src/Tests/Components/ComponentsModal.test.tsx @@ -10,7 +10,6 @@ import ComponentMetadata, { } from "Common/Types/Workflow/Component"; import React from "react"; - /// @dev we use different UUID for (id & title), description, and category to ensure that the component is unique type GetComponentMetadataFunction = (category?: string) => ComponentMetadata; diff --git a/CommonUI/src/Tests/Components/Dropdown.test.tsx b/CommonUI/src/Tests/Components/Dropdown.test.tsx index 8e76e7acb3..d8dd1e8f0d 100644 --- a/CommonUI/src/Tests/Components/Dropdown.test.tsx +++ b/CommonUI/src/Tests/Components/Dropdown.test.tsx @@ -2,7 +2,7 @@ import Dropdown, { DropdownOption } from "../../Components/Dropdown/Dropdown"; import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render, screen } from "@testing-library/react"; import React from "react"; - +import { describe, expect, jest } from "@jest/globals"; describe("Dropdown", () => { const options: DropdownOption[] = [ { value: "1", label: "1" }, diff --git a/CommonUI/src/Tests/Components/DuplicateModel.test.tsx b/CommonUI/src/Tests/Components/DuplicateModel.test.tsx index ceea1bad2e..de1b4821fa 100644 --- a/CommonUI/src/Tests/Components/DuplicateModel.test.tsx +++ b/CommonUI/src/Tests/Components/DuplicateModel.test.tsx @@ -1,7 +1,7 @@ import DuplicateModel from "../../Components/DuplicateModel/DuplicateModel"; import { ModelField } from "../../Components/Forms/ModelForm"; import Select from "../../Utils/BaseDatabase/Select"; -import { describe, expect, it } from "@jest/globals"; +import { describe, expect, it, jest } from "@jest/globals"; import { fireEvent, render, diff --git a/CommonUI/src/Tests/Components/Loader.test.tsx b/CommonUI/src/Tests/Components/Loader.test.tsx index e7327062bf..e4a0e95b43 100644 --- a/CommonUI/src/Tests/Components/Loader.test.tsx +++ b/CommonUI/src/Tests/Components/Loader.test.tsx @@ -3,8 +3,7 @@ import "@testing-library/jest-dom/extend-expect"; import { render, screen } from "@testing-library/react"; import Color from "Common/Types/Color"; import React from "react"; -import { describe, expect } from "@jest/globals"; - +import { describe, expect, test } from "@jest/globals"; describe("Loader tests", () => { test("it should render if bar loader show up", () => { diff --git a/CommonUI/src/Tests/Components/OrderedStatesList.test.tsx b/CommonUI/src/Tests/Components/OrderedStatesList.test.tsx index db64133a10..ceb41d44c8 100644 --- a/CommonUI/src/Tests/Components/OrderedStatesList.test.tsx +++ b/CommonUI/src/Tests/Components/OrderedStatesList.test.tsx @@ -5,7 +5,7 @@ import { describe, expect, it } from "@jest/globals"; import "@testing-library/jest-dom"; import { render, screen } from "@testing-library/react"; import React from "react"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, jest } from "@jest/globals"; describe("OrderedSateList", () => { interface ItemData { diff --git a/CommonUI/src/Tests/Components/Pagination.test.tsx b/CommonUI/src/Tests/Components/Pagination.test.tsx index 8f6cf89431..3830f939ee 100644 --- a/CommonUI/src/Tests/Components/Pagination.test.tsx +++ b/CommonUI/src/Tests/Components/Pagination.test.tsx @@ -5,7 +5,7 @@ import { describe, expect, it } from "@jest/globals"; import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import React from "react"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, jest } from "@jest/globals"; describe("Pagination", () => { it("renders Component", () => { diff --git a/CommonUI/src/Tests/Components/Pill.test.tsx b/CommonUI/src/Tests/Components/Pill.test.tsx index 0c1501a704..3afed41fad 100644 --- a/CommonUI/src/Tests/Components/Pill.test.tsx +++ b/CommonUI/src/Tests/Components/Pill.test.tsx @@ -3,7 +3,7 @@ import "@testing-library/jest-dom/extend-expect"; import { render, screen } from "@testing-library/react"; import Color from "Common/Types/Color"; import * as React from "react"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, test } from "@jest/globals"; describe("", () => { test("Checking text", () => { diff --git a/CommonUI/src/Tests/Components/Probe.test.tsx b/CommonUI/src/Tests/Components/Probe.test.tsx index e02baf84af..8987aef467 100644 --- a/CommonUI/src/Tests/Components/Probe.test.tsx +++ b/CommonUI/src/Tests/Components/Probe.test.tsx @@ -4,7 +4,7 @@ import { render, screen } from "@testing-library/react"; import ObjectID from "Common/Types/ObjectID"; import Probe from "Model/Models/Probe"; import * as React from "react"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, test } from "@jest/globals"; describe("ProbeElement Component", () => { const mockProbe: Probe = new Probe(); diff --git a/CommonUI/src/Tests/Components/ProgressBar.test.tsx b/CommonUI/src/Tests/Components/ProgressBar.test.tsx index bd43b834c0..0f5003172d 100644 --- a/CommonUI/src/Tests/Components/ProgressBar.test.tsx +++ b/CommonUI/src/Tests/Components/ProgressBar.test.tsx @@ -2,7 +2,7 @@ import ProgressBar from "../../Components/ProgressBar/ProgressBar"; import "@testing-library/jest-dom/extend-expect"; import { render, screen } from "@testing-library/react"; import * as React from "react"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, test } from "@jest/globals"; describe("ProgressBar Component", () => { function getProgressBar(): HTMLElement { diff --git a/CommonUI/src/Tests/Components/RadioButtons.test.tsx b/CommonUI/src/Tests/Components/RadioButtons.test.tsx index 06b731dd27..07cd47d8ed 100644 --- a/CommonUI/src/Tests/Components/RadioButtons.test.tsx +++ b/CommonUI/src/Tests/Components/RadioButtons.test.tsx @@ -4,7 +4,7 @@ import RadioButtons, { import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render } from "@testing-library/react"; import React from "react"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, jest, test } from "@jest/globals"; describe("RadioButtons", () => { const options: RadioButton[] = [ diff --git a/CommonUI/src/Tests/Components/SideOver.test.tsx b/CommonUI/src/Tests/Components/SideOver.test.tsx index f979500749..5e8738e7be 100644 --- a/CommonUI/src/Tests/Components/SideOver.test.tsx +++ b/CommonUI/src/Tests/Components/SideOver.test.tsx @@ -2,7 +2,7 @@ import SideOver, { ComponentProps } from "../../Components/SideOver/SideOver"; import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render, screen } from "@testing-library/react"; import React, { ReactElement } from "react"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, jest, test } from "@jest/globals"; describe("SideOver", () => { const childElementText: string = "child element"; diff --git a/CommonUI/src/Tests/Components/Tabs.test.tsx b/CommonUI/src/Tests/Components/Tabs.test.tsx index 7e43133311..30f60352d4 100644 --- a/CommonUI/src/Tests/Components/Tabs.test.tsx +++ b/CommonUI/src/Tests/Components/Tabs.test.tsx @@ -3,7 +3,7 @@ import Tabs from "../../Components/Tabs/Tabs"; import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render } from "@testing-library/react"; import React from "react"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, jest, test } from "@jest/globals"; describe("Tabs", () => { const activeClass: string = "bg-gray-100 text-gray-700"; diff --git a/CommonUI/src/Tests/Components/TextArea.test.tsx b/CommonUI/src/Tests/Components/TextArea.test.tsx index c2b1609160..65eea7e9a4 100644 --- a/CommonUI/src/Tests/Components/TextArea.test.tsx +++ b/CommonUI/src/Tests/Components/TextArea.test.tsx @@ -2,7 +2,7 @@ import TextArea from "../../Components/TextArea/TextArea"; import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render } from "@testing-library/react"; import React from "react"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, test, jest } from "@jest/globals"; describe("TextArea", () => { test("renders textarea element with initialValue only", () => { diff --git a/CommonUI/src/Tests/Components/Toast.test.tsx b/CommonUI/src/Tests/Components/Toast.test.tsx index 02c4d11fd3..4c116e480e 100644 --- a/CommonUI/src/Tests/Components/Toast.test.tsx +++ b/CommonUI/src/Tests/Components/Toast.test.tsx @@ -5,7 +5,7 @@ import userEvent from "@testing-library/user-event"; import { UserEvent } from "@testing-library/user-event/dist/types/setup/setup"; import OneUptimeDate from "Common/Types/Date"; import * as React from "react"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, test } from "@jest/globals"; describe("Test for Toast.tsx", () => { test("should render the component", () => { diff --git a/Probe/Tests/Utils/PingMonitor.test.skip.ts b/Probe/Tests/Utils/PingMonitor.test.skip.ts index 0e0ffc8488..f870a13032 100644 --- a/Probe/Tests/Utils/PingMonitor.test.skip.ts +++ b/Probe/Tests/Utils/PingMonitor.test.skip.ts @@ -5,7 +5,7 @@ import Hostname from "Common/Types/API/Hostname"; import BadDataException from "Common/Types/Exception/BadDataException"; import IPv4 from "Common/Types/IP/IPv4"; import PositiveNumber from "Common/Types/PositiveNumber"; -import { describe, expect } from "@jest/globals"; +import { describe, expect, jest, test } from "@jest/globals"; describe("Ping", () => { jest.setTimeout(240000); diff --git a/eslint.config.js b/eslint.config.js index 6afbbe0b1d..ee17f13410 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -194,6 +194,7 @@ export default tseslint.config( globals: { ...globals.browser, ...globals.node, + JSX: true, }, parserOptions: { project: ["./tsconfig.json"], // Specify it only for TypeScript files