storybookjs/testing-vue

Can't access data set in story file

Opened this issue · 4 comments

I have attached a v-model and set the data in my story but when trying to access wrapper.vm.page in my test file it returns undefined. Any ideas?

Screenshot 2022-07-06 at 12 19 22

Test File:

import { mount } from '@vue/test-utils';
import { composeStories } from '@storybook/testing-vue';
import * as stories from './PortalFooter.stories';

const { portalFooter, sign } = composeStories(stories);

describe('PortalFooter', () => {
    test('Page number is set', () => {
        const wrapper = mount(portalFooter());
        console.log(wrapper.vm.page);
    });
});

Hey @martin91s thanks for opening this issue.
I unfortunately do not have experience with @vue/test-utils so I can't help much on that. @elevatebart would you mind chiming in? Thank you!

Hello @martin91s

I am not a specialist of VTU either, but I will do my best to help you.
First, can you do one of the following?

  • Create a reproduction repository
    or
  • Give me the version of node, OS, VTU, vue, testing-vue, jest, and TypeScript (if you use it) that you use.

Thank you in advance.

Sure, I'll get a repo set up and get back to you.
Thanks

https://github.com/martin91s/storybook-jest

Nuxt App, Docs for setting up are in the readme

TestComponent directory has the component, story and test file. It does set the data from the story, the first console log will show this. But trying to access it just returns undefined.
Let me know if you need anything else, thanks