diff --git a/code/core/template/stories/before-each.stories.ts b/code/core/template/stories/before-each.stories.ts deleted file mode 100644 index a6f613e7698c..000000000000 --- a/code/core/template/stories/before-each.stories.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { expect, mocked, getByRole, spyOn, userEvent } from '@storybook/test'; - -const meta = { - component: globalThis.Components.Button, - loaders() { - spyOn(console, 'log').mockName('console.log'); - console.log('1 - [from loaders]'); - }, - beforeEach() { - console.log('2 - [from meta beforeEach]'); - }, -}; - -export default meta; - -export const BeforeEachOrder = { - parameters: { - chromatic: { disable: true }, - }, - beforeEach() { - console.log('3 - [from story beforeEach]'); - }, - decorators: (StoryFn: any) => { - console.log('4 - [from decorator]'); - return StoryFn(); - }, - args: { - label: 'Button', - onClick: () => { - console.log('5 - [from onClick]'); - }, - }, - async play({ canvasElement }: any) { - await userEvent.click(getByRole(canvasElement, 'button')); - - await expect(mocked(console.log).mock.calls).toEqual([ - ['1 - [from loaders]'], - ['2 - [from meta beforeEach]'], - ['3 - [from story beforeEach]'], - ['4 - [from decorator]'], - ['5 - [from onClick]'], - ]); - }, -}; diff --git a/code/core/template/stories/module-mocking.stories.ts b/code/core/template/stories/module-mocking.stories.ts deleted file mode 100644 index dc9b8e2430b7..000000000000 --- a/code/core/template/stories/module-mocking.stories.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { global as globalThis } from '@storybook/global'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore This alias is set in the sandbox. Using ts-ignore instead of ts-expect-error to avoid build errors in the sandbox. - -import { foo } from '#utils'; -import { expect, fn, isMockFunction, mocked } from '@storybook/test'; - -export default { - component: globalThis.Components.Button, - args: { - onClick: fn(), - label: 'Mock story', - }, - parameters: { - chromatic: { - disable: true, - }, - }, - beforeEach: () => { - mocked(foo).mockReturnValue('mocked'); - }, - async play() { - await expect(isMockFunction(foo)).toBe(true); - await expect(foo()).toBe('mocked'); - }, -}; - -export const Basic = {}; diff --git a/code/e2e-tests/module-mocking.spec.ts b/code/e2e-tests/module-mocking.spec.ts index f82bac6e27b2..8b6b43713b61 100644 --- a/code/e2e-tests/module-mocking.spec.ts +++ b/code/e2e-tests/module-mocking.spec.ts @@ -14,7 +14,7 @@ test.describe('module-mocking', () => { test('should assert story lifecycle order', async ({ page }) => { const sbPage = new SbPage(page); - await sbPage.navigateToStory('core/before-each', 'before-each-order'); + await sbPage.navigateToStory('lib/test/before-each', 'before-each-order'); await sbPage.viewAddonPanel('Actions'); const logItem = await page.locator('#storybook-panel-root #panel-tab-content'); @@ -38,7 +38,7 @@ test.describe('module-mocking', () => { test('should assert that utils import is mocked', async ({ page }) => { const sbPage = new SbPage(page); - await sbPage.navigateToStory('core/module-mocking', 'basic'); + await sbPage.navigateToStory('lib/test/module-mocking', 'basic'); await sbPage.viewAddonPanel('Actions'); const logItem = await page.locator('#storybook-panel-root #panel-tab-content', { diff --git a/code/frameworks/nextjs/src/babel/preset.ts b/code/frameworks/nextjs/src/babel/preset.ts index c21e7e281caf..1b48e4a663c0 100644 --- a/code/frameworks/nextjs/src/babel/preset.ts +++ b/code/frameworks/nextjs/src/babel/preset.ts @@ -82,6 +82,12 @@ export default (api: any, options: NextBabelPresetOptions = {}): BabelPreset => // In production/development this option is set to `false` so that webpack can handle import/export with tree-shaking modules: 'auto', exclude: ['transform-typeof-symbol'], + bugfixes: true, + targets: { + chrome: 100, + safari: 15, + firefox: 91, + }, ...options['preset-env'], }; diff --git a/scripts/tasks/sandbox-parts.ts b/scripts/tasks/sandbox-parts.ts index 13e9d5dcbd99..90cdd9c43e45 100644 --- a/scripts/tasks/sandbox-parts.ts +++ b/scripts/tasks/sandbox-parts.ts @@ -488,6 +488,12 @@ export const addStories: Task['run'] = async ( cwd, disableDocs, }); + + await linkPackageStories(await workspacePath('test package', '@storybook/test'), { + mainConfig, + cwd, + disableDocs, + }); } const mainAddons = (mainConfig.getSafeFieldValue(['addons']) || []).reduce(