Skip to content

Commit 9216302

Browse files
committed
fixed jest configuration issue by adding tsconfig for jest
1 parent db70a3a commit 9216302

File tree

6 files changed

+40
-4
lines changed

6 files changed

+40
-4
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {screen, render} from '@testing-library/react';
2+
import '@testing-library/jest-dom/extend-expect';
3+
import FeaturesSection from '../src/pages/components/FeaturesSection';
4+
5+
describe('<FeaturesSection />', () => {
6+
it('renders the core features section', () => {
7+
render(<FeaturesSection />)
8+
})
9+
});

www/jest.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
module.exports = {
3+
preset: 'ts-jest',
4+
testEnvironment: 'jsdom',
5+
transform: {
6+
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
7+
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
8+
'^.+\\.tsx?$': [
9+
'ts-jest',
10+
{
11+
tsconfig: 'tsconfig.jest.json',
12+
},
13+
],
14+
},
15+
};

www/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"dev": "next dev",
88
"postinstall": "prisma generate",
99
"lint": "next lint",
10-
"start": "next start"
10+
"start": "next start",
11+
"test": "jest"
1112
},
1213
"dependencies": {
1314
"@headlessui/react": "^1.7.5",
@@ -30,6 +31,7 @@
3031
"devDependencies": {
3132
"@testing-library/jest-dom": "^5.16.5",
3233
"@testing-library/react": "^13.4.0",
34+
"@types/jest": "^29.2.5",
3335
"@types/node": "^18.0.0",
3436
"@types/react": "^18.0.14",
3537
"@types/react-dom": "^18.0.5",
@@ -39,12 +41,15 @@
3941
"autoprefixer": "^10.4.7",
4042
"eslint": "^8.26.0",
4143
"eslint-config-next": "13.0.2",
44+
"jest": "^29.3.1",
45+
"jest-environment-jsdom": "^29.3.1",
4246
"postcss": "^8.4.14",
4347
"prettier": "^2.7.1",
4448
"prettier-plugin-tailwindcss": "^0.1.13",
4549
"prisma": "^4.5.0",
4650
"tailwindcss": "^3.2.0",
47-
"typescript": "^4.8.4"
51+
"ts-jest": "^29.0.3",
52+
"typescript": "^4.9.4"
4853
},
4954
"ct3aMetadata": {
5055
"initVersion": "6.11.3"

www/prisma/schema.prisma

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ generator client {
66
}
77

88
datasource db {
9-
provider = "sqlite"
9+
provider = "mysql"
1010
url = env("DATABASE_URL")
11+
relationMode = "prisma"
1112
}
1213

1314
model User {
14-
id String @id @default(cuid())
15+
id String @id @default(cuid())
1516
name String
1617
email String
1718
admin Boolean @default(false)

www/tsconfig.jest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"jsx": "react-jsx"
5+
}
6+
}

0 commit comments

Comments
 (0)