Skip to content

Commit

Permalink
Merge pull request #8 from qiushi1511/apps-docs-add-feat-istanbul
Browse files Browse the repository at this point in the history
Apps docs add feat istanbul
  • Loading branch information
qiushi1511 authored Oct 21, 2024
2 parents 571c014 + 422f101 commit e0cfb2b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
10 changes: 10 additions & 0 deletions apps/docs/app/feat1/page.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, test } from "@jest/globals";
import { render, screen } from "@testing-library/react";
import Page from "./page";

test("Page", () => {
render(<Page />);
expect(
screen.getByRole("heading", { level: 1, name: "Feat 1" })
).toBeDefined();
});
51 changes: 51 additions & 0 deletions apps/docs/app/feat1/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"use client";

import { useState } from "react";

function ToggleContent({
children,
defaultShow = false,
}: {
children?: React.ReactNode;
defaultShow?: boolean;
}) {
const [show, setShow] = useState(defaultShow);
return (
<div>
<button onClick={() => setShow(!show)}>Toggle</button>
{show ? children : null}
</div>
);
}

export default function Page() {
const ranNum = Math.round(Math.random() * 100);

return (
<>
<h1>Feat 1</h1>

<ToggleContent>
<p>
<span>P1:</span>
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.
</p>
</ToggleContent>
<ToggleContent>
<p>
<span>P2:</span>
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.
</p>
</ToggleContent>

{ranNum > 50 && <p>Random number is greater than 50</p>}
{ranNum <= 50 && <p>Random number is less than 50</p>}
</>
);
}
11 changes: 10 additions & 1 deletion apps/docs/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -39,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: [
Expand Down

0 comments on commit e0cfb2b

Please sign in to comment.