File tree 1 file changed +31
-1
lines changed
1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ Use the following pattern for placing naming your test scripts, so Jest can find
10
10
11
11
12
12
13
- ## Sample
13
+ ## Samples
14
+
15
+ ### Plain JavaScript
14
16
15
17
Install with:
16
18
@@ -46,6 +48,13 @@ $ npm install jest -D
46
48
test('Square a number successfully', () => {
47
49
expect(foo(3)).toBe(9)
48
50
})
51
+
52
+ // To group cases, use `describe` and `it` (which is an alias for `test`).
53
+ describe("Hello.vue", () => {
54
+ it("can square a number successfully", () => {
55
+ expect(foo(3)).toEqual(9);
56
+ });
57
+ });
49
58
```
50
59
51
60
Then run as:
@@ -59,3 +68,24 @@ You can also generate a Jest config:
59
68
``` sh
60
69
$ jest --init
61
70
```
71
+
72
+ ### Vue
73
+
74
+ Based on the file generated when adding the [ Vue Jest plugin] ( https://cli.vuejs.org/core-plugins/unit-jest.html ) .
75
+
76
+ - ` Helloworld.spec.js `
77
+ ``` vue
78
+ import Help from "@/components/Hello.vue";
79
+ import { shallowMount } from "@vue/test-utils";
80
+
81
+ describe("Hello.vue", () => {
82
+ it("renders props.message when passed", () => {
83
+ const message = "Hello, world!";
84
+ const wrapper = shallowMount(Hello, {
85
+ propsData: { message },
86
+ });
87
+
88
+ expect(wrapper.text()).toMatch(message);
89
+ });
90
+ });
91
+ ```
You can’t perform that action at this time.
0 commit comments