Skip to content

Commit

Permalink
add unit test with Vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
ettorepuccetti committed Jan 7, 2024
1 parent 549bc9c commit 74d69c2
Show file tree
Hide file tree
Showing 7 changed files with 1,146 additions and 7 deletions.
14 changes: 13 additions & 1 deletion NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ git push -u -f origin main
Launch a new container for mysql:

```bash
docker run --name mysql-dbname -e MYSQL_ROOT_PASSWORD=secret -p 3307:3307 -d mysql
docker run --name mysql-dbname -e MYSQL_ROOT_PASSWORD=secret -p 3307:3306 -d mysql
```

on port mapping [here](https://stackoverflow.com/questions/41637013/docker-mysql-on-different-port)

Configure the `DATABASE_URL` in the `.env` file:

```Properties
Expand All @@ -40,3 +42,13 @@ content: [
"@/lib/**/*.{ts,tsx}",
]
```

## Vitest

### Mocking prisma

[guide](https://www.prisma.io/blog/testing-series-1-8eRB5p0Y8o#why-mock-prisma-client)

### Mock trpc

[guide](https://tawaldevuniverse.hashnode.dev/some-tips-when-using-t3-stack-unit-testing-with-trpc-procedures-environment-setup)
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"cypress-mobile": "cypress open --config viewportWidth=375,viewportHeight=667",
"cypress-run-e2e": "cypress run --config video=false",
"cypress-run-component": "cypress run --config video=false --component",
"prepare": "husky install"
"prepare": "husky install",
"test": "vitest"
},
"lint-staged": {
"*": "prettier --ignore-unknown --write"
Expand Down Expand Up @@ -64,7 +65,9 @@
"prisma": "^5.7.1",
"tailwindcss": "^3.3.5",
"ts-node": "^10.9.2",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"vitest": "^1.1.3",
"vitest-mock-extended": "^1.3.1"
},
"ct3aMetadata": {
"initVersion": "7.25.0"
Expand Down
Loading

0 comments on commit 74d69c2

Please sign in to comment.