Skip to content

Commit e6e7005

Browse files
committed
2 parents 753550c + 5997627 commit e6e7005

9 files changed

+19
-18
lines changed

demo-app/yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,9 +1493,9 @@ acorn-walk@^6.0.1, acorn-walk@^6.1.1:
14931493
integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==
14941494

14951495
acorn@^5.5.3:
1496-
version "5.7.3"
1497-
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
1498-
integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==
1496+
version "5.7.4"
1497+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e"
1498+
integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==
14991499

15001500
acorn@^6.0.1, acorn@^6.0.7, acorn@^6.1.1, acorn@^6.2.1:
15011501
version "6.3.0"

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/finding-elements-and-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The source code for the test described on this page can be found [here](https://
66

77
## Creating the Components
88

9-
For this example, we will create a `<Child>` and `<Parent>` and component.
9+
For this example, we will create a `<Child>` and `<Parent>` component.
1010

1111
Child:
1212

src/ru/simulating-user-input.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ import { shallowMount } from "@vue/test-utils"
6464
import FormSubmitter from "@/components/FormSubmitter.vue"
6565

6666
describe("FormSubmitter", () => {
67-
it("Показывает сообщение после отправки", () => {
67+
it("Показывает сообщение после отправки", async() => {
6868
const wrapper = shallowMount(FormSubmitter)
6969

7070
wrapper.find("[data-username]").setValue("Алиса")
7171
wrapper.find("form").trigger("submit.prevent")
72+
await wrapper.vm.$nextTick()
7273

7374
expect(wrapper.find(".message").text())
7475
.toBe("Спасибо за ваше сообщение, Алиса.")

src/stubbing-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ it('renders with mount and does initialize API call', () => {
122122
})
123123
```
124124

125-
The test still passes when `yarn test:unit` is run, however the `console.log` is nowhere to be seen. That's because passing `[component]: true` to `stubs` replaced the original component with a _stub_. The external interface is still the same (we can still select is using `find`, since the `name` property, which is used internally by `find`, is still the same). The internal methods, such as `makeApiCall`, are replaced by dummy methods that don't do anything - they are "stubbed out".
125+
The test still passes when `yarn test:unit` is run, however the `console.log` is nowhere to be seen. That's because passing `[component]: true` to `stubs` replaced the original component with a _stub_. The external interface is still the same (we can still select it using `find`, since the `name` property, which is used internally by `find`, is still the same). The internal methods, such as `makeApiCall`, are replaced by dummy methods that don't do anything - they are "stubbed out".
126126

127127
You can also specify the markup to use for the stub, if you like:
128128

src/testing-vuex.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ These tests are to assert that the component behaves correctly based on the curr
1414

1515
Any logic performed by the store, such as mutations and getters, can be tested in isolation. Since Vuex stores are comprised of regular JavaScript functions, they are easily unit tested.
1616

17-
The next guide introduces some techniques to test components that use a Vuex store, and ensure they behave correctly based on the store's state. Later guides discuss testing Vuex in isolation.
17+
The first few guides discuss techniques to test Vuex in isolation considering mutations, actions and getters. Following guides introduce some techniques to test components that use a Vuex store, and ensure they behave correctly based on the store's state.

src/vuex-in-components-mutations-and-actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe("ComponentWithButtons", () => {
9898

9999
Notice the tests are marked `await` and call `nextTick`. See [here](/simulating-user-input.html#writing-the-test) for more details on why.
100100

101-
There is a lot code in the test above - nothing too exciting is happening, though. We create a `localVue` and use Vuex, then create a store, passing a Jest mock function (`jest.fn()`) in place of the `testMutation`. Vuex mutations are always called with two arguments: the first is the current state, and the second is the payload. Since we didn't declare any state for the store, we expect it to be called with an empty object. The second argument is expected to me `{ msg: "Test Commit" }`, which is hard coded in the component.
101+
There is a lot code in the test above - nothing too exciting is happening, though. We create a `localVue` and use Vuex, then create a store, passing a Jest mock function (`jest.fn()`) in place of the `testMutation`. Vuex mutations are always called with two arguments: the first is the current state, and the second is the payload. Since we didn't declare any state for the store, we expect it to be called with an empty object. The second argument is expected to be `{ msg: "Test Commit" }`, which is hard coded in the component.
102102

103103
This is a lot of boilerplate code to write, but is a correct and valid way to verify components are behaving correctly. Another alternative that requires less code is using a mock store. Let's see how to do that for while writing a test to assert `testAction` is dispatched.
104104

src/vuex-in-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default {
2828
</script>
2929
```
3030

31-
We can use `createLocalVue` to create a temporary Vue instance, and install Vuex. Then we simply pass the a new `store` in the component's mounting options. A full test looks like this:
31+
We can use `createLocalVue` to create a temporary Vue instance, and install Vuex. Then we simply pass the new `store` in the component's mounting options. A full test looks like this:
3232

3333
```js
3434
import Vuex from "vuex"

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,9 @@ acorn-jsx@^5.0.0, acorn-jsx@^5.0.2:
11171117
integrity sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==
11181118

11191119
acorn@^6.0.2, acorn@^6.2.1:
1120-
version "6.3.0"
1121-
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.3.0.tgz#0087509119ffa4fc0a0041d1e93a417e68cb856e"
1122-
integrity sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==
1120+
version "6.4.1"
1121+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474"
1122+
integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==
11231123

11241124
acorn@^7.0.0:
11251125
version "7.1.0"

0 commit comments

Comments
 (0)