Skip to content

Commit 665f60c

Browse files
mark-de-haanktsn
authored andcommitted
Add a try-catch to the testAction helper method example (#776)
When an error occurs in an assertion, you receive the message that your promise hook was not closed within 2 seconds. By catching the error, we can call done(error) (this works for standard vue-cli template) 1. This makes sure the test is properly closed 2. The assertion error is logged to the console
1 parent 7aad4a3 commit 665f60c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

docs/en/testing.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,16 @@ const testAction = (action, payload, state, expectedMutations, done) => {
9292
// mock commit
9393
const commit = (type, payload) => {
9494
const mutation = expectedMutations[count]
95-
expect(mutation.type).to.equal(type)
96-
if (payload) {
97-
expect(mutation.payload).to.deep.equal(payload)
95+
96+
try {
97+
expect(mutation.type).to.equal(type)
98+
if (payload) {
99+
expect(mutation.payload).to.deep.equal(payload)
100+
}
101+
} catch(error) {
102+
done(error)
98103
}
104+
99105
count++
100106
if (count >= expectedMutations.length) {
101107
done()

0 commit comments

Comments
 (0)