Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 4x 5x 4x 4x 4x 4x 4x 4x 4x 5x 5x 5x 3x 3x 3x 3x 3x 3x 3x 3x 5x 5x 2x 5x 2x 2x 2x 2x | import { composeStories } from "@storybook/react"; import React from "react"; import { stubStoryActions } from "orphic-cypress"; import * as sbPreview from "dot-storybook/preview"; import * as stories from "./index.stories"; const { ArgtypeActionStub, ImplicitArgtypeActionStubViaRegex } = composeStories( stories, sbPreview ); // With the caveat of argTypesRegex not carrying over from the main parameters // all of the nuance expressed in ./BeforeEach.stories.tsx and // ./PerStoryArgs.stories.tsx can be represented in external cases as well describe("ExternalTests", () => { describe("with argType explicitly provided", () => { describe("direct approach", () => { it("should call the proper stubs", function () { const actions = stubStoryActions(ArgtypeActionStub, stories); cy.mount(<ArgtypeActionStub {...actions} />); cy.dataCy("count").should("contain", 0); // can expect directly on actions cy.dataCy("button") .click() .then(() => expect(actions.onClick).to.be.calledOnceWith(0)); // name on actions is `onClick` cy.get("@actions").its("onClick").should("be.calledOnceWith", 0); // but the action string also functions as an alias cy.get("@myClickStub").should("be.calledOnceWith", 0); // would also come from regex cy.get("@argTypesRegex.onClick").should("be.calledOnceWith", 0); cy.dataCy("count").should("contain", 1); }); }); describe("in before each", () => { beforeEach(() => { stubStoryActions(ArgtypeActionStub, stories); }); it("should stub tests when argtype is explicitly provided", function () { cy.mount(<ArgtypeActionStub {...this.actions} />); cy.dataCy("count").should("contain", 0); // can expect directly on actions cy.dataCy("button") .click() .then(() => expect(this.actions.onClick).to.be.calledOnceWith(0)); cy.get("@actions").its("onClick").should("be.calledOnceWith", 0); cy.get("@myClickStub").should("be.calledOnceWith", 0); cy.get("@argTypesRegex.onClick").should("be.calledOnceWith", 0); }); }); }); describe("without argtype explicitly provided", () => { describe("direct approach", () => { it("should call the proper stubs", function () { const actions = stubStoryActions( ImplicitArgtypeActionStubViaRegex, stories ); cy.mount(<ImplicitArgtypeActionStubViaRegex {...actions} />); cy.dataCy("count").should("contain", 0); // can expect directly on actions cy.dataCy("button") .click() .then(() => expect(actions.onClick).to.be.calledOnceWith(0)); cy.get("@actions").its("onClick").should("be.calledOnceWith", 0); cy.get("@argTypesRegex.onClick").should("be.calledOnceWith", 0); cy.dataCy("count").should("contain", 1); }); }); describe("in before each", () => { beforeEach(() => { stubStoryActions(ImplicitArgtypeActionStubViaRegex, stories); }); it("should stub tests when argtype is explicitly provided", function () { cy.mount(<ImplicitArgtypeActionStubViaRegex {...this.actions} />); cy.dataCy("button").click(); cy.get("@actions").its("onClick").should("be.calledOnceWith", 0); cy.get("@argTypesRegex.onClick").should("be.calledOnceWith", 0); }); }); }); }); |