storybookjs / testing-vue

MIT License
10 stars 6 forks source link

Can't access data set in story file #7

Open martin91s opened 2 years ago

martin91s commented 2 years ago

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);
    });
});
yannbf commented 2 years ago

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!

elevatebart commented 2 years ago

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?

Thank you in advance.

martin91s commented 2 years ago

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

martin91s commented 2 years ago

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