Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Can't access data set in story file #7

Open
martin91s opened this issue Jul 6, 2022 · 4 comments
Open

Can't access data set in story file #7

martin91s opened this issue Jul 6, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@martin91s
Copy link

martin91s commented Jul 6, 2022

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);
    });
});

@martin91s martin91s added the bug Something isn't working label Jul 6, 2022
@yannbf
Copy link
Member

yannbf commented Jul 6, 2022

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
Copy link
Contributor

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.

@martin91s
Copy link
Author

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

@martin91s
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants