diff --git a/code/addons/test/package.json b/code/addons/test/package.json index 4adcf51977b9..29d77a92968c 100644 --- a/code/addons/test/package.json +++ b/code/addons/test/package.json @@ -103,7 +103,6 @@ "execa": "^8.0.1", "find-up": "^7.0.0", "formik": "^2.2.9", - "glob": "^10.0.0", "istanbul-lib-report": "^3.0.1", "pathe": "^1.1.2", "picocolors": "^1.1.0", @@ -112,6 +111,7 @@ "semver": "^7.6.3", "slash": "^5.0.0", "strip-ansi": "^7.1.0", + "tinyglobby": "^0.2.10", "ts-dedent": "^2.2.0", "typescript": "^5.3.2", "vitest": "^2.1.3" diff --git a/code/addons/test/src/vitest-plugin/index.ts b/code/addons/test/src/vitest-plugin/index.ts index 238cc798128a..111e53fd2a8f 100644 --- a/code/addons/test/src/vitest-plugin/index.ts +++ b/code/addons/test/src/vitest-plugin/index.ts @@ -12,9 +12,8 @@ import { readConfig, vitestTransform } from 'storybook/internal/csf-tools'; import { MainFileMissingError } from 'storybook/internal/server-errors'; import type { DocsOptions, StoriesEntry } from 'storybook/internal/types'; -// eslint-disable-next-line depend/ban-dependencies -import { escape } from 'glob'; import { join, resolve } from 'pathe'; +import { convertPathToPattern } from 'tinyglobby'; import type { InternalOptions, UserOptions } from './types'; @@ -121,11 +120,7 @@ export const storybookTest = (options?: UserOptions): Plugin => { config.test ??= {}; config.test.include ??= []; - config.test.include.push( - // Escape magic characters in paths because they shouldn't be treated as glob patterns - // Paths are resolved using `pathe` to convert Windows paths to POSIX paths first - ...storiesFiles.map((path) => escape(resolve(path))) - ); + config.test.include.push(...storiesFiles.map((path) => convertPathToPattern(path))); config.test.exclude ??= []; config.test.exclude.push('**/*.mdx'); diff --git a/code/yarn.lock b/code/yarn.lock index 97473ea1d726..389084993441 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6623,7 +6623,6 @@ __metadata: execa: "npm:^8.0.1" find-up: "npm:^7.0.0" formik: "npm:^2.2.9" - glob: "npm:^10.0.0" istanbul-lib-report: "npm:^3.0.1" pathe: "npm:^1.1.2" picocolors: "npm:^1.1.0" @@ -6634,6 +6633,7 @@ __metadata: semver: "npm:^7.6.3" slash: "npm:^5.0.0" strip-ansi: "npm:^7.1.0" + tinyglobby: "npm:^0.2.10" ts-dedent: "npm:^2.2.0" typescript: "npm:^5.3.2" vitest: "npm:^2.1.3" @@ -15759,7 +15759,7 @@ __metadata: languageName: node linkType: hard -"fdir@npm:^6.2.0": +"fdir@npm:^6.2.0, fdir@npm:^6.4.2": version: 6.4.2 resolution: "fdir@npm:6.4.2" peerDependencies: @@ -23193,6 +23193,13 @@ __metadata: languageName: node linkType: hard +"picomatch@npm:^4.0.2": + version: 4.0.2 + resolution: "picomatch@npm:4.0.2" + checksum: 10c0/7c51f3ad2bb42c776f49ebf964c644958158be30d0a510efd5a395e8d49cb5acfed5b82c0c5b365523ce18e6ab85013c9ebe574f60305892ec3fa8eee8304ccc + languageName: node + linkType: hard + "picoquery@npm:^1.4.0": version: 1.4.0 resolution: "picoquery@npm:1.4.0" @@ -27704,6 +27711,16 @@ __metadata: languageName: node linkType: hard +"tinyglobby@npm:^0.2.10": + version: 0.2.10 + resolution: "tinyglobby@npm:0.2.10" + dependencies: + fdir: "npm:^6.4.2" + picomatch: "npm:^4.0.2" + checksum: 10c0/ce946135d39b8c0e394e488ad59f4092e8c4ecd675ef1bcd4585c47de1b325e61ec6adfbfbe20c3c2bfa6fd674c5b06de2a2e65c433f752ae170aff11793e5ef + languageName: node + linkType: hard + "tinypool@npm:^1.0.0": version: 1.0.0 resolution: "tinypool@npm:1.0.0"