From fa327f2db9c822b77a1fc823719617ae99b86138 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 11 Jul 2024 14:34:22 +0200 Subject: [PATCH] docs: add importance of subpath import order --- .../mocking-data-and-modules/mocking-modules.mdx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/writing-stories/mocking-data-and-modules/mocking-modules.mdx b/docs/writing-stories/mocking-data-and-modules/mocking-modules.mdx index dd4e5c49daaa..85cca9ffa13b 100644 --- a/docs/writing-stories/mocking-data-and-modules/mocking-modules.mdx +++ b/docs/writing-stories/mocking-data-and-modules/mocking-modules.mdx @@ -70,11 +70,13 @@ To configure subpath imports, you define the `imports` property in your project' {/* prettier-ignore-end */} -There are two aspects to this configuration worth noting: +There are three aspects to this configuration worth noting: First, **each subpath must begin with `#`**, to differentiate it from a regular module path. The `#*` entry is a catch-all that maps all subpaths to the root directory. -Second, note the **`storybook`, `test`, and `default` keys** in each module's entry. The `storybook` value is used to import the mock file when loaded in Storybook, while the `default` value is used to import the original module when loaded in your project. The `test` condition is also used within Storybook, which allows you to use the same configuration in Storybook and your other tests. +Second, the order of the keys is important. The `default` key should come last. + +Third, note the **`storybook`, `test`, and `default` keys** in each module's entry. The `storybook` value is used to import the mock file when loaded in Storybook, while the `default` value is used to import the original module when loaded in your project. The `test` condition is also used within Storybook, which allows you to use the same configuration in Storybook and your other tests. With the package configuration in place, you can then update your component file to use the subpath import: