diff --git a/.changeset/late-plums-swim.md b/.changeset/late-plums-swim.md new file mode 100644 index 0000000000..ff48db07c4 --- /dev/null +++ b/.changeset/late-plums-swim.md @@ -0,0 +1,5 @@ +--- +"@storybook/marko": patch +--- + +Fix avoid stubbing testing apis for known tags api components. diff --git a/packages/renderers/marko/src/testing-api.ts b/packages/renderers/marko/src/testing-api.ts index 4cee2fd407..f913910e1b 100644 --- a/packages/renderers/marko/src/testing-api.ts +++ b/packages/renderers/marko/src/testing-api.ts @@ -152,6 +152,26 @@ function toRenderable( composed: ComposedStoryFn>, componentAnnotations: Meta, ) { + const defaultComponent = componentAnnotations?.component; + const isV6 = defaultComponent && !defaultComponent.createOut; + if (isV6) { + return { + ...composed, + mount( + rawInput: Partial> | undefined, + referenceNode: Parameters[1], + position?: Parameters[2], + ) { + const { component, input } = runStory(rawInput); + return component.mount(input, referenceNode, position); + }, + render(rawInput: Partial> | undefined) { + const { component, input } = runStory(rawInput); + return component.render(input); + }, + } as any as typeof composed & Marko.Template; + } + return { ...composed, createOut() { @@ -190,7 +210,7 @@ function toRenderable( } as any as typeof composed & Marko.Template; function runStory(rawInput: Partial> | undefined) { - const { component = componentAnnotations?.component, input = {} } = + const { component = defaultComponent, input = {} } = composed(rawInput) || {}; if (!component || !(component.mount || component.renderSync)) { throw new Error( diff --git a/tests/fixtures/click-count/test.ts b/tests/fixtures/click-count/test.ts index 5a89a50a54..77ab0f9c72 100644 --- a/tests/fixtures/click-count/test.ts +++ b/tests/fixtures/click-count/test.ts @@ -6,7 +6,7 @@ import { testPage } from "../../test-page"; import * as stories from "./stories"; const { Default, InitialCount } = composeStories(stories); -const initialTimeout = { timeout: 30000 }; +const initialTimeout = { timeout: 60000 }; test("click-count", async () => { await test(Default.storyName, async () => { diff --git a/tests/fixtures/invalid/test.ts b/tests/fixtures/invalid/test.ts index 6d1ffff906..8cb33d3876 100644 --- a/tests/fixtures/invalid/test.ts +++ b/tests/fixtures/invalid/test.ts @@ -6,7 +6,7 @@ import { testPage } from "../../test-page"; import * as stories from "./stories"; const { Default } = composeStories(stories); -const initialTimeout = { timeout: 30000 }; +const initialTimeout = { timeout: 60000 }; test("invalid", async () => { await test(Default.storyName, async () => { diff --git a/tests/fixtures/split-component/test.ts b/tests/fixtures/split-component/test.ts index 7432a71550..9c7838ae42 100644 --- a/tests/fixtures/split-component/test.ts +++ b/tests/fixtures/split-component/test.ts @@ -6,7 +6,7 @@ import { testPage } from "../../test-page"; import * as stories from "./stories"; const { HelloWorld, HelloMarko } = composeStories(stories); -const initialTimeout = { timeout: 30000 }; +const initialTimeout = { timeout: 60000 }; test("split-component", async () => { await test(HelloWorld.storyName, async () => {