Skip to content

Commit c0ea7ec

Browse files
committed
docs: add README
1 parent 63932cb commit c0ea7ec

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# vue-test-utils-typescript-example
2+
3+
> Example project using TypeScript, Jest + vue-test-utils together
4+
5+
This is based on the `vue-cli` 3 `basic` template. Test-specific changes include:
6+
7+
### Additional Dependencies
8+
9+
- `vue-test-utils`
10+
- `jest`
11+
- `ts-jest` (for TypeScript compilation in tests)
12+
- `vue-jest` (for handling `*.vue` files in tests)
13+
- `jest-serializer-vue` (for snapshot tests)
14+
15+
### Additional Configuration
16+
17+
#### `package.json`
18+
19+
The following configurations are recommended for Jest:
20+
21+
``` js
22+
{
23+
"jest": {
24+
"moduleFileExtensions": [
25+
"js",
26+
"json",
27+
"ts",
28+
// tell Jest to handle *.vue files
29+
"vue"
30+
],
31+
"transform": {
32+
// process TypeScript files
33+
"^.+\\.ts$": "ts-jest",
34+
// process *.vue files with vue-jest
35+
".*\\.(vue)$": "vue-jest"
36+
},
37+
// support the same @ -> src alias mapping in source code
38+
"moduleNameMapper": {
39+
"^@/(.*)$": "<rootDir>/src/$1"
40+
},
41+
// serializer for snapshots
42+
"snapshotSerializers": [
43+
"jest-serializer-vue"
44+
]
45+
}
46+
}
47+
```
48+
49+
### Build Commands
50+
51+
``` bash
52+
# install dependencies
53+
npm install
54+
55+
# serve with hot reload at localhost:8080
56+
npm run dev
57+
58+
# build for production with minification
59+
npm run build
60+
61+
# run tests
62+
npm test
63+
```

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"serve": "vue-cli-service serve",
77
"build": "vue-cli-service build",
88
"lint": "vue-cli-service lint",
9+
"test": "npm run test:unit",
910
"test:unit": "jest"
1011
},
1112
"dependencies": {

0 commit comments

Comments
 (0)