Skip to content

Commit 2f3dff3

Browse files
authored
Merge pull request #4 from Bibimbap-Team/2-setup-ci
Initialize CI
2 parents 5223fc0 + fc47841 commit 2f3dff3

File tree

6 files changed

+5326
-5
lines changed

6 files changed

+5326
-5
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Set NODE_ENV
17+
run: echo "NODE_ENV=development" >> $GITHUB_ENV
18+
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '20' # Changed to 20, as 22 is not yet stable
26+
cache: 'yarn'
27+
28+
- name: Install Yarn
29+
run: corepack enable
30+
31+
- name: Install dependencies
32+
run: yarn install --frozen-lockfile
33+
34+
- name: Run unit tests
35+
run: yarn run test

__tests__/landing.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import '@testing-library/jest-dom';
2+
import { render, screen } from '@testing-library/react';
3+
import Home from '@/app/page';
4+
5+
it('renders main page with the text "Get started by editing"', () => {
6+
render(<Home />);
7+
const text = screen.getByText(/Get started by editing/i);
8+
expect(text).toBeInTheDocument();
9+
});

bun.lockb

-143 KB
Binary file not shown.

jest.config.ts

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
/**
2+
* For a detailed explanation regarding each configuration property, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
import type {Config} from 'jest';
7+
import nextJest from 'next/jest.js';
8+
9+
const createJestConfig = nextJest({
10+
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
11+
dir: './',
12+
})
13+
14+
const config: Config = {
15+
// All imported modules in your tests should be mocked automatically
16+
// automock: false,
17+
18+
// Stop running tests after `n` failures
19+
// bail: 0,
20+
21+
// The directory where Jest should store its cached dependency information
22+
// cacheDirectory: "/private/var/folders/2h/yypwh_6j3xq21vcnxr6g082w0000gn/T/jest_dx",
23+
24+
// Automatically clear mock calls, instances, contexts and results before every test
25+
clearMocks: true,
26+
27+
// Indicates whether the coverage information should be collected while executing the test
28+
collectCoverage: true,
29+
30+
// An array of glob patterns indicating a set of files for which coverage information should be collected
31+
// collectCoverageFrom: undefined,
32+
33+
// The directory where Jest should output its coverage files
34+
coverageDirectory: "coverage",
35+
36+
// An array of regexp pattern strings used to skip coverage collection
37+
// coveragePathIgnorePatterns: [
38+
// "/node_modules/"
39+
// ],
40+
41+
// Indicates which provider should be used to instrument code for coverage
42+
coverageProvider: "v8",
43+
44+
// A list of reporter names that Jest uses when writing coverage reports
45+
// coverageReporters: [
46+
// "json",
47+
// "text",
48+
// "lcov",
49+
// "clover"
50+
// ],
51+
52+
// An object that configures minimum threshold enforcement for coverage results
53+
// coverageThreshold: undefined,
54+
55+
// A path to a custom dependency extractor
56+
// dependencyExtractor: undefined,
57+
58+
// Make calling deprecated APIs throw helpful error messages
59+
// errorOnDeprecated: false,
60+
61+
// The default configuration for fake timers
62+
// fakeTimers: {
63+
// "enableGlobally": false
64+
// },
65+
66+
// Force coverage collection from ignored files using an array of glob patterns
67+
// forceCoverageMatch: [],
68+
69+
// A path to a module which exports an async function that is triggered once before all test suites
70+
// globalSetup: undefined,
71+
72+
// A path to a module which exports an async function that is triggered once after all test suites
73+
// globalTeardown: undefined,
74+
75+
// A set of global variables that need to be available in all test environments
76+
// globals: {},
77+
78+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
79+
// maxWorkers: "50%",
80+
81+
// An array of directory names to be searched recursively up from the requiring module's location
82+
// moduleDirectories: [
83+
// "node_modules"
84+
// ],
85+
86+
// An array of file extensions your modules use
87+
// moduleFileExtensions: [
88+
// "js",
89+
// "mjs",
90+
// "cjs",
91+
// "jsx",
92+
// "ts",
93+
// "tsx",
94+
// "json",
95+
// "node"
96+
// ],
97+
98+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
99+
// moduleNameMapper: {},
100+
101+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
102+
// modulePathIgnorePatterns: [],
103+
104+
// Activates notifications for test results
105+
// notify: false,
106+
107+
// An enum that specifies notification mode. Requires { notify: true }
108+
// notifyMode: "failure-change",
109+
110+
// A preset that is used as a base for Jest's configuration
111+
// preset: undefined,
112+
113+
// Run tests from one or more projects
114+
// projects: undefined,
115+
116+
// Use this configuration option to add custom reporters to Jest
117+
// reporters: undefined,
118+
119+
// Automatically reset mock state before every test
120+
// resetMocks: false,
121+
122+
// Reset the module registry before running each individual test
123+
// resetModules: false,
124+
125+
// A path to a custom resolver
126+
// resolver: undefined,
127+
128+
// Automatically restore mock state and implementation before every test
129+
// restoreMocks: false,
130+
131+
// The root directory that Jest should scan for tests and modules within
132+
// rootDir: undefined,
133+
134+
// A list of paths to directories that Jest should use to search for files in
135+
// roots: [
136+
// "<rootDir>"
137+
// ],
138+
139+
// Allows you to use a custom runner instead of Jest's default test runner
140+
// runner: "jest-runner",
141+
142+
// The paths to modules that run some code to configure or set up the testing environment before each test
143+
// setupFiles: [],
144+
145+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
146+
// setupFilesAfterEnv: [],
147+
148+
// The number of seconds after which a test is considered as slow and reported as such in the results.
149+
// slowTestThreshold: 5,
150+
151+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
152+
// snapshotSerializers: [],
153+
154+
// The test environment that will be used for testing
155+
testEnvironment: "jsdom",
156+
157+
// Options that will be passed to the testEnvironment
158+
// testEnvironmentOptions: {},
159+
160+
// Adds a location field to test results
161+
// testLocationInResults: false,
162+
163+
// The glob patterns Jest uses to detect test files
164+
// testMatch: [
165+
// "**/__tests__/**/*.[jt]s?(x)",
166+
// "**/?(*.)+(spec|test).[tj]s?(x)"
167+
// ],
168+
169+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
170+
// testPathIgnorePatterns: [
171+
// "/node_modules/"
172+
// ],
173+
174+
// The regexp pattern or array of patterns that Jest uses to detect test files
175+
// testRegex: [],
176+
177+
// This option allows the use of a custom results processor
178+
// testResultsProcessor: undefined,
179+
180+
// This option allows use of a custom test runner
181+
// testRunner: "jest-circus/runner",
182+
183+
// A map from regular expressions to paths to transformers
184+
// transform: undefined,
185+
186+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
187+
// transformIgnorePatterns: [
188+
// "/node_modules/",
189+
// "\\.pnp\\.[^\\/]+$"
190+
// ],
191+
192+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
193+
// unmockedModulePathPatterns: undefined,
194+
195+
// Indicates whether each individual test should be reported during the run
196+
// verbose: undefined,
197+
198+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
199+
// watchPathIgnorePatterns: [],
200+
201+
// Whether to use watchman for file crawling
202+
// watchman: true,
203+
};
204+
205+
export default createJestConfig(config);

package.json

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,32 @@
77
"dev": "next dev",
88
"build": "next build",
99
"start": "next start",
10-
"lint": "next lint"
10+
"lint": "next lint",
11+
"test": "jest",
12+
"test:watch": "jest --watch"
1113
},
1214
"dependencies": {
15+
"next": "14.2.4",
1316
"react": "^18",
1417
"react-dom": "^18",
15-
"next": "14.2.4"
18+
"ts-node": "^10.9.2"
1619
},
1720
"devDependencies": {
18-
"typescript": "^5",
21+
"@testing-library/dom": "^10.3.2",
22+
"@testing-library/jest-dom": "^6.4.6",
23+
"@testing-library/react": "^16.0.0",
24+
"@testing-library/user-event": "^14.5.2",
25+
"@types/jest": "^29.5.12",
1926
"@types/node": "^20",
2027
"@types/react": "^18",
2128
"@types/react-dom": "^18",
29+
"eslint": "^8",
30+
"eslint-config-next": "14.2.4",
31+
"jest": "^29.7.0",
32+
"jest-cli": "^29.7.0",
33+
"jest-environment-jsdom": "^29.7.0",
2234
"postcss": "^8",
2335
"tailwindcss": "^3.4.1",
24-
"eslint": "^8",
25-
"eslint-config-next": "14.2.4"
36+
"typescript": "^5"
2637
}
2738
}

0 commit comments

Comments
 (0)