From 349a83b64715e2587cf233d2498011ca139edb2c Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 21 Oct 2024 17:44:14 +0800 Subject: [PATCH 1/3] apps/docs: add /feat1 page --- apps/docs/app/feat1/page.tsx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 apps/docs/app/feat1/page.tsx diff --git a/apps/docs/app/feat1/page.tsx b/apps/docs/app/feat1/page.tsx new file mode 100644 index 0000000..ba3d649 --- /dev/null +++ b/apps/docs/app/feat1/page.tsx @@ -0,0 +1,30 @@ +"use client"; + +import { useState } from "react"; + +function ToggleContent({ children }: { children?: React.ReactNode }) { + const [show, setShow] = useState(false); + return ( +
+ + {show ? children : null} +
+ ); +} + +export default function Page() { + return ( + <> +

Feat 1

+ + +

+ Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorem, + voluptatem mollitia suscipit odio eos fugiat eum in molestias itaque + ex magni fuga deleniti dolores. Accusamus blanditiis reiciendis ab + quibusdam saepe. +

+
+ + ); +} From 8567f9567f6a0442db0ec89e18bb38c869d7298c Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 21 Oct 2024 18:45:00 +0800 Subject: [PATCH 2/3] Update test coverages with Jest --- apps/docs/app/feat1/page.test.tsx | 10 ++++++++++ apps/docs/app/feat1/page.tsx | 25 +++++++++++++++++++++++-- apps/docs/jest.config.ts | 9 +++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 apps/docs/app/feat1/page.test.tsx diff --git a/apps/docs/app/feat1/page.test.tsx b/apps/docs/app/feat1/page.test.tsx new file mode 100644 index 0000000..d72f0d6 --- /dev/null +++ b/apps/docs/app/feat1/page.test.tsx @@ -0,0 +1,10 @@ +import { expect, test } from "@jest/globals"; +import { render, screen } from "@testing-library/react"; +import Page from "./page"; + +test("Page", () => { + render(); + expect( + screen.getByRole("heading", { level: 1, name: "Feat 1" }) + ).toBeDefined(); +}); diff --git a/apps/docs/app/feat1/page.tsx b/apps/docs/app/feat1/page.tsx index ba3d649..2b2a05f 100644 --- a/apps/docs/app/feat1/page.tsx +++ b/apps/docs/app/feat1/page.tsx @@ -2,8 +2,14 @@ import { useState } from "react"; -function ToggleContent({ children }: { children?: React.ReactNode }) { - const [show, setShow] = useState(false); +function ToggleContent({ + children, + defaultShow = false, +}: { + children?: React.ReactNode; + defaultShow?: boolean; +}) { + const [show, setShow] = useState(defaultShow); return (
@@ -13,18 +19,33 @@ function ToggleContent({ children }: { children?: React.ReactNode }) { } export default function Page() { + const ranNum = Math.round(Math.random() * 100); + return ( <>

Feat 1

+ P1: + Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorem, + voluptatem mollitia suscipit odio eos fugiat eum in molestias itaque + ex magni fuga deleniti dolores. Accusamus blanditiis reiciendis ab + quibusdam saepe. +

+
+ +

+ P2: Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorem, voluptatem mollitia suscipit odio eos fugiat eum in molestias itaque ex magni fuga deleniti dolores. Accusamus blanditiis reiciendis ab quibusdam saepe.

+ + {ranNum > 50 &&

Random number is greater than 50

} + {ranNum <= 50 &&

Random number is less than 50

} ); } diff --git a/apps/docs/jest.config.ts b/apps/docs/jest.config.ts index ce34bb7..989b118 100644 --- a/apps/docs/jest.config.ts +++ b/apps/docs/jest.config.ts @@ -27,6 +27,15 @@ const config: Config = { // Indicates whether the coverage information should be collected while executing the test collectCoverage: true, + collectCoverageFrom: [ + "**/*.{ts,tsx,s,mjs,mts}", + "!jest.config.ts", + "!next.config.mjs", + "!**/*.d.ts", + "!**/node_modules/**", + "!**/vendor/**", + ], + // An array of glob patterns indicating a set of files for which coverage information should be collected // collectCoverageFrom: undefined, From 422f101067a3f88dc48f2bae4a1371311f2f0f32 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 21 Oct 2024 18:54:36 +0800 Subject: [PATCH 3/3] Use istanbul instead --- apps/docs/jest.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/jest.config.ts b/apps/docs/jest.config.ts index 989b118..f4e53c0 100644 --- a/apps/docs/jest.config.ts +++ b/apps/docs/jest.config.ts @@ -48,7 +48,7 @@ const config: Config = { // ], // Indicates which provider should be used to instrument code for coverage - coverageProvider: "v8", + coverageProvider: "babel", // A list of reporter names that Jest uses when writing coverage reports // coverageReporters: [