You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/v2/guide/unit-testing.md
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -22,26 +22,29 @@ You don't have to do anything special in your components to make them testable.
22
22
message:'hello!'
23
23
}
24
24
},
25
-
created () {
25
+
mounted () {
26
26
this.message='bye!'
27
27
}
28
28
}
29
29
</script>
30
30
```
31
31
32
-
Then import the component options along with Vue, and you can make many common assertions (here we are using Jasmine/Jeststyle `expect` assertions just as an example):
32
+
Then import the component along with [Vue Test Utils](https://vue-test-utils.vuejs.org/), and you can make many common assertions (here we are using Jest-style `expect` assertions just as an example):
33
33
34
34
```js
35
-
// Import Vue and the component being tested
36
-
importVuefrom'vue'
37
-
importMyComponentfrom'path/to/MyComponent.vue'
35
+
// Import `shallowMount` from Vue Test Utils and the component being tested
36
+
import { shallowMount } from'@vue/test-utils'
37
+
importMyComponentfrom'./MyComponent.vue'
38
+
39
+
// Mount the component
40
+
constwrapper=shallowMount(MyComponent)
38
41
39
-
// Here are some Jasmine 2.0 tests, though you can
40
-
// use any test runner / assertion library combo you prefer
42
+
// Here are some Jest tests, though you can
43
+
// use any test runner/assertion library combo you prefer
0 commit comments