diff --git a/docs/config/browsers.mdx b/docs/config/browsers.mdx index 078acf0..ec1119d 100644 --- a/docs/config/browsers.mdx +++ b/docs/config/browsers.mdx @@ -1066,9 +1066,60 @@ The section has the following parameters: will be disabled. + + `mapDependencyRelativePath` + `null | (dependency: { scope: "browser" | "testplane", relativePath: string }) => string | void` + `null` + + Callback, which accepts test dependency path in POSIX style and maps it to another path + or filters it completely if `falsy` value is returned + + +### `mapDependencyRelativePath` examples {#mapDependencyRelativePath_examples} + +#### Ignore Next.js internal dependencies {#mapDependencyRelativePath_example_nextjs} + +```ts +{ + selectivity: { + enabled: true, + mapDependencyRelativePath({relativePath}) { + if (relativePath.startsWith("turbopack://")) { + return; + } + + return relativePath; + }, + } +} +``` + +#### Usage with @testplane/storybook plugin {#mapDependencyRelativePath_example_testplane_storybook} + +```ts +{ + selectivity: { + enabled: true, + mapDependencyRelativePath({relativePath}) { + // Testplane storybook autogenerated tests + if (relativePath.includes("/testplane-storybook-autogenerated/")) { + return; + } + + // Storybook fake dependencies + if (relativePath === "storybook-stories.js" || relativePath === "storybook-config-entry.js") { + return; + } + + return relativePath; + }, + } +} +``` + You should not specify `node_modules` in `disableSelectivityPatterns`, as this will cause a significant slowdown. Instead, it is recommended to specify Testplane configuration files and diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/config/browsers.mdx b/i18n/ru/docusaurus-plugin-content-docs/current/config/browsers.mdx index bcfacee..1f58763 100644 --- a/i18n/ru/docusaurus-plugin-content-docs/current/config/browsers.mdx +++ b/i18n/ru/docusaurus-plugin-content-docs/current/config/browsers.mdx @@ -1073,9 +1073,60 @@ export = { Список паттернов, при изменении файлов по которым селективность должна отключаться. + + `mapDependencyRelativePath` + `null | (dependency: { scope: "browser" | "testplane", relativePath: string }) => string | void` + `null` + + Коллбэк, который принимает путь зависимости теста в стиле POSIX и преобразует его в другой путь + или полностью игнорирует зависимость, если возвращено `falsy` значение + + +### Примеры `mapDependencyRelativePath` {#mapDependencyRelativePath_examples} + +#### Игнорирование внутренних зависимостей Next.js {#mapDependencyRelativePath_example_nextjs} + +```ts +{ + selectivity: { + enabled: true, + mapDependencyRelativePath({relativePath}) { + if (relativePath.startsWith("turbopack://")) { + return; + } + + return relativePath; + }, + } +} +``` + +#### Использование с плагином @testplane/storybook {#mapDependencyRelativePath_example_testplane_storybook} + +```ts +{ + selectivity: { + enabled: true, + mapDependencyRelativePath({relativePath}) { + // Автогенерированные тесты testplane storybook + if (relativePath.includes("/testplane-storybook-autogenerated/")) { + return; + } + + // Фиктивные зависимости Storybook + if (relativePath === "storybook-stories.js" || relativePath === "storybook-config-entry.js") { + return; + } + + return relativePath; + }, + } +} +``` + В `disableSelectivityPatterns` не стоит указывать `node_modules` - это приведет к ощутимому замедлению. Вместо этого, рекомендуется указать конфигурационные файлы Testplane и исходный код