Closed
Description
Reproduction
Thank you so much for such a great lib.
I found a little bug when testing store that use this.$nuxt
TypeError: Cannot destructure property '$config' of 'this.$nuxt' as it is undefined.
Sandbox: https://codesandbox.io/s/competent-field-w3j63?file=/test/use-main-store-error.spec.js
Steps to reproduce the behavior
- Inside
actions
usethis.$nuxt
to access the nuxt context - Test the action =>
yarn test
- See error
Expected behavior
The test should pass because $nuxt
should exist in this context
Actual behavior
The test throw an error
TypeError: Cannot destructure property '$config' of 'this.$nuxt' as it is undefined.
Additional information
I found a little workaround in my test to avoid this error
File: https://codesandbox.io/s/competent-field-w3j63?file=/test/use-main-store-working.spec.js
beforeEach(() => {
const pinia = setActivePinia(createPinia());
const contextMock = {
$config: {
CONFIG_1: 1
}
};
pinia._p.push(({ store }) => {
Object.defineProperty(store, "$nuxt", { value: contextMock });
});
});