Get argTypes from both the default export and the individual story. Useful for a per-component beforeEach or top-of-test declaration. Note that you'll want to return undefined from beforeEach
beforeEach
describe("SomeComponent", () => { beforeEach(() => { stubStoryActions(SomeComponent, stories); }); it("should render ok and call someAction on init", () => { cy.mount(<SomeComponent {...this.actions} />); cy.get("@actions").its("someAction").should("be.calledWith", ""); });});
it("should do something", () => { // could just be `const actions = { someAction: cy.stub(), ... }` const actions = stubStoryActions(SomeStory, stories); cy.mount(<SomeStory {...actions} />); cy.dataCy("something").click().then(() => { expect(actions.someAction).to.have.callCount(1); }); // or without the promise cy.dataCy("something").click(); cy.get("@actions").its("someAction").should("have.callCount", 2);});
Mostly an internal detail: precedence order, 3 through end will have essentially the same effect
Optional
Get argTypes from both the default export and the individual story. Useful for a per-component beforeEach or top-of-test declaration. Note that you'll want to return undefined from
beforeEach
Mostly an internal detail: precedence order, 3 through end will have essentially the same effect