Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/late-plums-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@storybook/marko": patch
---

Fix avoid stubbing testing apis for known tags api components.
22 changes: 21 additions & 1 deletion packages/renderers/marko/src/testing-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,26 @@ function toRenderable<Input extends Args = Args>(
composed: ComposedStoryFn<MarkoRenderer, Partial<Input>>,
componentAnnotations: Meta<Input>,
) {
const defaultComponent = componentAnnotations?.component;
const isV6 = defaultComponent && !defaultComponent.createOut;
if (isV6) {
return {
...composed,
mount(
rawInput: Partial<Marko.TemplateInput<Input>> | undefined,
referenceNode: Parameters<Marko.Template["mount"]>[1],
position?: Parameters<Marko.Template["mount"]>[2],
) {
const { component, input } = runStory(rawInput);
return component.mount(input, referenceNode, position);
},
render(rawInput: Partial<Marko.TemplateInput<Input>> | undefined) {
const { component, input } = runStory(rawInput);
return component.render(input);
},
} as any as typeof composed & Marko.Template<Input>;
}

return {
...composed,
createOut() {
Expand Down Expand Up @@ -190,7 +210,7 @@ function toRenderable<Input extends Args = Args>(
} as any as typeof composed & Marko.Template<Input>;

function runStory(rawInput: Partial<Marko.TemplateInput<Input>> | undefined) {
const { component = componentAnnotations?.component, input = {} } =
const { component = defaultComponent, input = {} } =
composed(rawInput) || {};
if (!component || !(component.mount || component.renderSync)) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/click-count/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/invalid/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/split-component/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down