Skip to content

Commit 4253b45

Browse files
committed
Fix flake in store-spec
1 parent 3a807fd commit 4253b45

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

examples/blogs__vue-vuex-rest/cypress/e2e/store-spec.cy.js

+19-10
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,25 @@ describe('Store actions', () => {
350350

351351
getStore()
352352
.its('state')
353-
.should('deep.equal', {
354-
loading: false,
355-
todos: [
356-
{
357-
title: 'a new todo',
358-
completed: false,
359-
id: '1',
360-
},
361-
],
362-
newTodo: '',
353+
.should((state) => {
354+
// The vue store returns a proxy object, with getters over the various props.
355+
// _.deepClone() resolves these getters into a primitive object, so we can
356+
// assert on the values directly.
357+
358+
// It's important to us a callback form of .should() here, rather than
359+
// .then(Cypress._.deepClone()), because .then() doesn't retry. See
360+
// https://on.cypress.io/should#Function for a fuller explanation.
361+
expect(Cypress._.cloneDeep(state)).to.deep.equal({
362+
loading: false,
363+
todos: [
364+
{
365+
title: 'a new todo',
366+
completed: false,
367+
id: '1',
368+
},
369+
],
370+
newTodo: '',
371+
})
363372
})
364373
})
365374

0 commit comments

Comments
 (0)