@@ -24,30 +24,31 @@ npm install --save-dev vue-testing-library
2424 babel-plugin-transform-runtime
2525```
2626
27- ```
27+ ``` json
2828// package.json
29- "scripts": {
30- "test": "jest"
31- }
29+ "scripts" : {
30+ "test" : " jest"
31+ }
3232
33- "jest": {
34- "moduleDirectories": [
35- "node_modules",
36- "src"
37- ],
38- "moduleFileExtensions": [
39- "js",
40- "vue"
41- ],
42- "testPathIgnorePatterns": [
43- "/node_modules/"
44- ],
45- "transform": {
46- "^.+\\.js$": "<rootDir>/node_modules/babel-jest",
47- ".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
48- }
33+ "jest" : {
34+ "moduleDirectories" : [
35+ " node_modules" ,
36+ " src"
37+ ],
38+ "moduleFileExtensions" : [
39+ " js" ,
40+ " vue"
41+ ],
42+ "testPathIgnorePatterns" : [
43+ " /node_modules/"
44+ ],
45+ "transform" : {
46+ "^.+\\ .js$" : " <rootDir>/node_modules/babel-jest" ,
47+ ".*\\ .(vue)$" : " <rootDir>/node_modules/vue-jest"
4948 }
50-
49+ }
50+ ```
51+ ```
5152// .babelrc
5253{
5354 "presets": [
@@ -67,14 +68,16 @@ npm install --save-dev vue-testing-library
6768 }
6869 }
6970}
70-
71+ ```
72+ ``` html
7173// src/TestComponent.vue
7274<template >
7375 <div >
7476 <span data-testid =" test1" >Hello World</span >
7577 </div >
7678</template >
77-
79+ ```
80+ ``` js
7881// src/TestComponent.spec.js
7982import ' jest-dom/extend-expect'
8083import { render } from ' vue-testing-library'
@@ -99,9 +102,9 @@ helper methods
991022 . RenderOptions - an object containing additional information to be passed to
100103 @vue/test-utils mount. This can include:
101104
102- - store - The object definition of a Vuex store, if present ` render ` will
105+ - store - The object definition of a Vuex store. If present, ` render ` will
103106 configure a Vuex store and pass to mount.
104- - routes - A set of routes, if present render will configure VueRouter and pass
107+ - routes - A set of routes. If present, render will configure VueRouter and pass
105108 to mount.
106109
107110 All additional render options are passed to the vue-test-utils mount function
@@ -119,16 +122,16 @@ In particular, the `wait` utility can be very important in Vue components,
119122@vue/test-utils has succeeded in making the majority of updates happen
120123synchronously however there are occasions when wait will allow the DOM to
121124update. For example, see
122- [ ` here ` ] ( https://github.com/dfcook /vue-testing-library/tree/master/tests/__tests__/validate-plugin .js ) .
125+ [ ` here ` ] ( https://github.com/testing-library /vue-testing-library/tree/master/tests/__tests__/end-to-end .js ) .
123126
124127## Examples
125128
126129You'll find examples of testing with different libraries in
127- [ the test directory] ( https://github.com/dfcook /vue-testing-library/tree/master/tests/__tests__ ) .
130+ [ the test directory] ( https://github.com/testing-library /vue-testing-library/tree/master/tests/__tests__ ) .
128131Some included are:
129132
130- - [ ` vuex ` ] ( https://github.com/dfcook /vue-testing-library/tree /master/tests/__tests__/vuex.js )
131- - [ ` vue-router ` ] ( https://github.com/dfcook /vue-testing-library/tree/master/tests/__tests__/vue-router.js )
132- - [ ` vee-validate ` ] ( https://github.com/dfcook /vue-testing-library/tree/master/tests/__tests__/validate-plugin.js )
133+ - [ ` vuex ` ] ( https://github.com/testing-library /vue-testing-library/blob /master/tests/__tests__/vuex.js )
134+ - [ ` vue-router ` ] ( https://github.com/testing-library /vue-testing-library/tree/master/tests/__tests__/vue-router.js )
135+ - [ ` vee-validate ` ] ( https://github.com/testing-library /vue-testing-library/tree/master/tests/__tests__/validate-plugin.js )
133136
134- [ gh ] : https://github.com/dfcook /vue-testing-library
137+ [ gh ] : https://github.com/testing-library /vue-testing-library
0 commit comments