#Testing Stories with Cypress on NextJS

2 messages · Page 1 of 1 (latest)

prime yew
#

Hello, I'm setting up cypress to test my stories. For this, I'm using "composeStories" like this:

import * as stories from "..."
const { Default } = composeStories(stories);

describe('MyComp', () => {
  it('renders', () => {

    cy.mount(<Default />)
  })
})

The problem is that it seems that my stories loader configuration is ignored.

const meta: Meta<typeof MyComp> = {
  component: MyComp,
  loaders: [
    async ({ args, globals: { ... } }) => {
      return {
        ...
      };
    },
  ],
  render: (args, { loaded: loaderProps }) => (
    <MyComp {...loaderProps} {...args} />
  ),
};

export default meta;
type Story = StoryObj<typeof MyComp>;

export const Default: Story = {
  args: { ...  },
};

How can I trigger the loader and use composeStories ? I'm a bit lost...

Thanks for helping

prime yew
#

Another way for me would be using globals. But, here again, how to retrieve globals in CY test 🤷🏽‍♂️