Skip to content

Commit 0568bba

Browse files
authored
Merge pull request #64 from ssu-commerce/feature/SCF-55
SCF-63
2 parents b60e6f2 + b81cad4 commit 0568bba

File tree

7 files changed

+57
-2
lines changed

7 files changed

+57
-2
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import "@testing-library/jest-dom";
2+
import { render, screen } from "@testing-library/react";
3+
import Page from "../app/page";
4+
5+
describe("Page", () => {
6+
it("renders a heading", () => {
7+
render(<Page />);
8+
9+
const heading = screen.getByText("main");
10+
11+
expect(heading).toBeInTheDocument();
12+
});
13+
});

apps/commerce/jest.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const nextJest = require("next/jest");
2+
3+
const createJestConfig = nextJest({
4+
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
5+
dir: "./",
6+
});
7+
8+
// Add any custom config to be passed to Jest
9+
const customJestConfig = {
10+
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
11+
testEnvironment: "jsdom",
12+
};
13+
14+
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
15+
module.exports = createJestConfig(customJestConfig);

apps/commerce/jest.setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Learn more: https://github.com/testing-library/jest-dom
2+
import "@testing-library/jest-dom"; // Learn more: https://github.com/testing-library/jest-dom

apps/commerce/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"dev": "next dev --port 3001",
77
"build": "next build",
88
"start": "next start",
9+
"test": "jest",
10+
"test:watch": "jest --watch",
911
"lint": "next lint --fix",
1012
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
1113
},
@@ -29,13 +31,18 @@
2931
"zustand": "^4.5.2"
3032
},
3133
"devDependencies": {
34+
"@sc-config/jest": "workspace:*",
3235
"@next/eslint-plugin-next": "^13.4.19",
3336
"@svgr/webpack": "^8.1.0",
3437
"@tanstack/eslint-plugin-query": "^5.17.7",
38+
"@testing-library/jest-dom": "^6.1.4",
39+
"@testing-library/react": "^14.0.0",
3540
"@types/node": "^18.17.0",
3641
"@types/react": "^18.2.0",
3742
"@types/react-dom": "^18.2.0",
3843
"eslint-config-sc": "workspace:*",
44+
"jest": "^29.7.0",
45+
"jest-environment-jsdom": "^29.6.4",
3946
"tsconfig-sc": "workspace:*",
4047
"typescript": "^5.2.2"
4148
}

apps/commerce/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"**/*.tsx",
1717
".next/types/**/*.ts",
1818
"global.d.ts",
19-
"styles.d.ts"
19+
"styles.d.ts",
20+
"jest.config.js",
21+
"jest.setup.js"
2022
],
2123
"exclude": ["node_modules"]
2224
}

pnpm-lock.yaml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"scripts": {
66
"dev": "storybook dev -p 6006",
77
"build": "storybook build --docs",
8+
"build-storybook": "storybook build --docs",
89
"preview-storybook": "serve storybook-static",
910
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf storybook-static",
1011
"lint": "eslint src/ --fix",
1112
"test": "concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"npx http-server storybook-static --port 6006 --silent\" \"npx wait-on tcp:6006 && pnpm test-storybook\"",
1213
"test:watch": "test-storybook --watch",
13-
"chromatic": "npx chromatic"
14+
"chromatic": "npx chromatic --project-token=chpt_bcfcb25b665220e"
1415
},
1516
"dependencies": {
1617
"@sc/shared": "workspace:*",

0 commit comments

Comments
 (0)