mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 23:12:03 +08:00
Merge branch 'next' into norbert/auto-import-monorepo
This commit is contained in:
commit
19a16cb6b3
@ -13,7 +13,7 @@ type TelemetryOptions = {
|
||||
};
|
||||
|
||||
const promptCrashReports = async () => {
|
||||
if (process.env.CI && process.env.NODE_ENV !== 'test') {
|
||||
if (process.env.CI) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -374,8 +374,8 @@ export class StoryStore<TRenderer extends Renderer> {
|
||||
loaded: {},
|
||||
step: (label, play) => story.runStep(label, play, context),
|
||||
context: null!,
|
||||
canvas: {} as Canvas,
|
||||
mount: null!,
|
||||
canvas: {} as Canvas,
|
||||
viewMode: 'story',
|
||||
} as StoryContext<TRenderer>;
|
||||
|
||||
|
@ -32,14 +32,20 @@ export const sourceDecorator = (
|
||||
const channel = addons.getChannel();
|
||||
const { props, template, userDefinedTemplate } = story;
|
||||
|
||||
const { component, argTypes } = context;
|
||||
const { component, argTypes, parameters } = context;
|
||||
|
||||
let toEmit: string;
|
||||
|
||||
useEffect(() => {
|
||||
if (toEmit) {
|
||||
const { id, unmappedArgs } = context;
|
||||
channel.emit(SNIPPET_RENDERED, { id, args: unmappedArgs, source: toEmit, format: 'angular' });
|
||||
const format = parameters?.docs?.source?.format ?? true;
|
||||
channel.emit(SNIPPET_RENDERED, {
|
||||
id,
|
||||
args: unmappedArgs,
|
||||
source: toEmit,
|
||||
format: format === true ? 'angular' : format,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable local-rules/no-uncategorized-errors */
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
import { within, fireEvent, expect } from '@storybook/test';
|
||||
import React from 'react';
|
||||
@ -116,10 +117,18 @@ export const ErrorStory: Story = {
|
||||
render: () => {
|
||||
const err = new Error('Rendering problem');
|
||||
// force stack for consistency in capture
|
||||
err.stack = err.stack
|
||||
.replace(/\d+:\d+(:\d+)?/g, `000:0001`)
|
||||
.replace(/v=[^:]+/g, 'v=00000000')
|
||||
.replace(/[^/]+\.js/g, 'file.js');
|
||||
err.stack = `
|
||||
at undecoratedStoryFn (/sb-preview/file.js:000:0001)
|
||||
at hookified (/sb-preview/file.js:000:0001)
|
||||
at defaultDecorateStory (/sb-preview/file.js:000:0001)
|
||||
at jsxDecorator (/assets/file.js:000:0001)
|
||||
at hookified (/sb-preview/file.js:000:0001)
|
||||
at decorateStory (/sb-preview/file.js:000:0001)
|
||||
at renderWithHooks (/sb-preview/file.js:000:0001)
|
||||
at mountIndeterminateComponent (/assets/file.js:000:0001)
|
||||
at beginWork (/assets/file.js:000:0001)
|
||||
at longMockedPath (/node_modules/.cache/storybook/da6a511058d185c3c92ed7790fc88078d8a947a8d0ac75815e8fd5704bcd4baa/sb-vite/deps/file.js?v=00000000:000:0001)
|
||||
`;
|
||||
throw err;
|
||||
},
|
||||
args: { label: 'Button' },
|
||||
|
@ -235,7 +235,7 @@ describe('Story args can be inferred', () => {
|
||||
it('mount accepts a Component and props', () => {
|
||||
const Basic: StoryObj<Button> = {
|
||||
async play({ mount }) {
|
||||
const canvas = await mount(Button, { label: 'label', disabled: true });
|
||||
const canvas = await mount(Button, { props: { label: 'label', disabled: true } });
|
||||
expectTypeOf(canvas).toEqualTypeOf<Canvas>();
|
||||
},
|
||||
};
|
||||
|
@ -200,7 +200,7 @@ it('Infer type of slots', () => {
|
||||
it('mount accepts a Component', () => {
|
||||
const Basic: StoryObj<typeof Button> = {
|
||||
async play({ mount }) {
|
||||
const canvas = await mount(Button, { label: 'label', disabled: true });
|
||||
const canvas = await mount(Button, { props: { label: 'label', disabled: true } });
|
||||
expectTypeOf(canvas).toEqualTypeOf<Canvas>();
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user