callCount is undefined when testing with sinon #1473
Unanswered
lefta
asked this question in
Help and Questions
Replies: 1 comment
-
I finally managed to get spies working by calling the store once before mounting the component. Both the following snippets are working : const pinia = createTestingPinia({ createSpy: spy })
const app = useStore()
mount(Application, { global: { plugins: [pinia] } })
expect(app.initialize.callCount).to.equal(1) const pinia = createTestingPinia({ createSpy: spy })
useStore()
mount(Application, { global: { plugins: [pinia] } })
const app = useStore()
expect(app.initialize.callCount).to.equal(1) It looks like the store needs to be registered before mounting the component. However I could not find anything about this behavior in the docs (sorry if I'm blind). Is it still a bug ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Reproduction
See below
Steps to reproduce the bug
package.json
test.js
Run
Expected behavior
The test passes
Actual behavior
The test fails with
Additional information
When a store defines an initial state, the stubbed actions lose their
callCount
property. When the store have no initial state, or when it is called directly (not as part of a component), everything works as expected. The following changes both make the test pass :Line 11
// state: () => ({ ready: false }),
Lines 29 => 32
Beta Was this translation helpful? Give feedback.
All reactions