@storybook/addon-vitest 11.0.0-beta.5 → 11.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_browser-chunks/{chunk-SOJUMPVB.js → chunk-JNYCH5SZ.js} +1 -0
- package/dist/_node-chunks/{chunk-FKKCPNLJ.js → chunk-4HVYW5B2.js} +1 -1
- package/dist/_node-chunks/chunk-PQZIOGBY.js +1 -1
- package/dist/_node-chunks/{chunk-G4HWSAOC.js → chunk-U3I4JYDP.js} +1 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +1 -1
- package/dist/manager.js +1 -1
- package/dist/node/vitest.js +21 -8
- package/dist/postinstall.js +3 -3
- package/dist/preset.js +90 -38
- package/dist/vitest-plugin/index.js +2 -2
- package/dist/vitest-plugin/setup-file.js +1 -1
- package/dist/vitest-plugin/test-utils.js +1 -1
- package/package.json +4 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRequire as
|
|
1
|
+
import { createRequire as CJS_COMPAT_CREATE_REQUIRE_au1pgcspllh } from "node:module";var require = CJS_COMPAT_CREATE_REQUIRE_au1pgcspllh(import.meta.url);
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
package/dist/constants.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ type CurrentRun = {
|
|
|
38
38
|
a11yReports: Record<StoryId, A11yRunReport[]>;
|
|
39
39
|
reports: Record<StoryId, Report[]>;
|
|
40
40
|
totalTestCount: number | undefined;
|
|
41
|
+
matchedFileCount: number | undefined;
|
|
41
42
|
storyIds: StoryId[] | undefined;
|
|
42
43
|
startedAt: number | undefined;
|
|
43
44
|
finishedAt: number | undefined;
|
|
@@ -94,6 +95,7 @@ declare const storeOptions: {
|
|
|
94
95
|
};
|
|
95
96
|
storyIds: undefined;
|
|
96
97
|
totalTestCount: undefined;
|
|
98
|
+
matchedFileCount: undefined;
|
|
97
99
|
startedAt: undefined;
|
|
98
100
|
finishedAt: undefined;
|
|
99
101
|
unhandledErrors: never[];
|
|
@@ -119,6 +121,8 @@ type TriggerTestRunRequestPayload = {
|
|
|
119
121
|
requestId: string;
|
|
120
122
|
actor: string;
|
|
121
123
|
storyIds?: string[];
|
|
124
|
+
fileFilters?: string[];
|
|
125
|
+
storyFiles?: string[];
|
|
122
126
|
config?: Record<string, unknown>;
|
|
123
127
|
};
|
|
124
128
|
type TestRunResult = CurrentRun;
|
package/dist/constants.js
CHANGED
package/dist/manager.js
CHANGED
package/dist/node/vitest.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
errorToErrorLike,
|
|
3
3
|
log
|
|
4
|
-
} from "../_node-chunks/chunk-
|
|
4
|
+
} from "../_node-chunks/chunk-4HVYW5B2.js";
|
|
5
5
|
import {
|
|
6
6
|
any,
|
|
7
7
|
up
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
STORYBOOK_TEST_PROVIDE_KEY,
|
|
23
23
|
STORY_INDEX_CHANNEL_EVENT_NAME,
|
|
24
24
|
storeOptions
|
|
25
|
-
} from "../_node-chunks/chunk-
|
|
25
|
+
} from "../_node-chunks/chunk-U3I4JYDP.js";
|
|
26
26
|
import "../_node-chunks/chunk-PQZIOGBY.js";
|
|
27
27
|
|
|
28
28
|
// src/node/vitest.ts
|
|
@@ -319,9 +319,11 @@ Please install the @vitest/${isIstanbul ? "coverage-istanbul" : "coverage-v8"} p
|
|
|
319
319
|
this.vitest?.provide(STORYBOOK_TEST_PROVIDE_KEY, this.getCurrentRunConfig());
|
|
320
320
|
}
|
|
321
321
|
async runTests(runPayload) {
|
|
322
|
-
let { watching } = this.testManager.store.getState(), coverageShouldBeEnabled = !!this.getCurrentRunConfig().coverage && !watching && (runPayload?.storyIds?.length ?? 0) === 0;
|
|
322
|
+
let { watching } = this.testManager.store.getState(), coverageShouldBeEnabled = !!this.getCurrentRunConfig().coverage && !watching && !runPayload.fileFilters && !runPayload.storyFiles && (runPayload?.storyIds?.length ?? 0) === 0;
|
|
323
323
|
this.vitest ? await this.setCoverage(coverageShouldBeEnabled) : await this.startVitest({ coverage: coverageShouldBeEnabled }), this.provideRunConfig(), this.resetGlobalTestNamePattern(), await this.cancelCurrentRun();
|
|
324
|
-
let allStories = this.getStories(),
|
|
324
|
+
let allStories = this.getStories(), matchedSpecifications = await this.getStorybookTestSpecifications(runPayload.fileFilters), storyFiles = runPayload.storyFiles && new Set(runPayload.storyFiles.map(toModuleId)), testSpecifications = storyFiles ? matchedSpecifications.filter(({ moduleId }) => storyFiles.has(moduleId)) : matchedSpecifications, matchedFiles = (runPayload.fileFilters || storyFiles) && new Set(testSpecifications.map(({ moduleId }) => moduleId)), filteredStories = allStories.filter(
|
|
325
|
+
(story) => (!runPayload.storyIds || runPayload.storyIds.includes(story.id)) && (!matchedFiles || matchedFiles.has(toModuleId(story.importPath)))
|
|
326
|
+
);
|
|
325
327
|
if (runPayload.storyIds?.length) {
|
|
326
328
|
let regex = this.buildTestNamePatternForStories(filteredStories, allStories);
|
|
327
329
|
regex && this.vitest.setGlobalTestNamePattern(regex);
|
|
@@ -330,7 +332,10 @@ Please install the @vitest/${isIstanbul ? "coverage-istanbul" : "coverage-v8"} p
|
|
|
330
332
|
testSpecifications,
|
|
331
333
|
filteredStories
|
|
332
334
|
);
|
|
333
|
-
this.testManager.
|
|
335
|
+
matchedFiles && this.testManager.setRunStories(
|
|
336
|
+
filteredStories.map((story) => story.id),
|
|
337
|
+
runPayload.fileFilters && new Set(matchedSpecifications.map(({ moduleId }) => moduleId)).size
|
|
338
|
+
), this.testManager.store.setState((s) => ({
|
|
334
339
|
...s,
|
|
335
340
|
currentRun: {
|
|
336
341
|
...s.currentRun,
|
|
@@ -363,8 +368,9 @@ Please install the @vitest/${isIstanbul ? "coverage-istanbul" : "coverage-v8"} p
|
|
|
363
368
|
logger.debug(`Could not check ${moduleId} against the Vitest test globs: ${e}`);
|
|
364
369
|
}
|
|
365
370
|
}
|
|
366
|
-
|
|
367
|
-
|
|
371
|
+
// With file filters: the story files they match, as `vitest Button` finds its test files
|
|
372
|
+
async getStorybookTestSpecifications(fileFilters) {
|
|
373
|
+
return (await this.vitest?.globTestSpecifications(fileFilters) ?? []).filter(
|
|
368
374
|
(workspaceSpec) => this.isStorybookProject(workspaceSpec.project)
|
|
369
375
|
) ?? [];
|
|
370
376
|
}
|
|
@@ -564,7 +570,8 @@ var testStateToStatusValueMap = {
|
|
|
564
570
|
}
|
|
565
571
|
async handleTriggerRunEvent(event) {
|
|
566
572
|
await this.runTestsWithState({
|
|
567
|
-
|
|
573
|
+
// The stories of a run of files are known once Vitest has matched the files
|
|
574
|
+
storyIds: event.payload.fileFilters || event.payload.storyFiles ? [] : event.payload.storyIds,
|
|
568
575
|
triggeredBy: event.payload.triggeredBy,
|
|
569
576
|
configOverride: event.payload.configOverride,
|
|
570
577
|
callback: async () => {
|
|
@@ -622,6 +629,12 @@ var testStateToStatusValueMap = {
|
|
|
622
629
|
throw new Error("Tests completed but there are unhandled errors");
|
|
623
630
|
});
|
|
624
631
|
}
|
|
632
|
+
setRunStories(storyIds, matchedFileCount) {
|
|
633
|
+
this.componentTestStatusStore.unset(storyIds), this.a11yStatusStore.unset(storyIds), this.store.setState((s) => ({
|
|
634
|
+
...s,
|
|
635
|
+
currentRun: { ...s.currentRun, storyIds, matchedFileCount }
|
|
636
|
+
}));
|
|
637
|
+
}
|
|
625
638
|
onTestModuleCollected(collectedTestCount) {
|
|
626
639
|
this.store.setState((s) => ({
|
|
627
640
|
...s,
|
package/dist/postinstall.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./_node-chunks/chunk-VDP2ZJQR.js";
|
|
13
13
|
import {
|
|
14
14
|
DOCUMENTATION_LINK
|
|
15
|
-
} from "./_node-chunks/chunk-
|
|
15
|
+
} from "./_node-chunks/chunk-U3I4JYDP.js";
|
|
16
16
|
import {
|
|
17
17
|
__toESM
|
|
18
18
|
} from "./_node-chunks/chunk-PQZIOGBY.js";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
import * as fs from "node:fs/promises";
|
|
22
22
|
import { writeFile } from "node:fs/promises";
|
|
23
23
|
import os from "node:os";
|
|
24
|
-
import { AddonVitestService } from "storybook/internal/cli";
|
|
24
|
+
import { AddonVitestService, refreshAgentInstructions } from "storybook/internal/cli";
|
|
25
25
|
import {
|
|
26
26
|
JsPackageManagerFactory,
|
|
27
27
|
formatFileContent,
|
|
@@ -460,7 +460,7 @@ async function postInstall(options) {
|
|
|
460
460
|
}
|
|
461
461
|
let runCommand = rootConfig ? "npx vitest --project=storybook" : "npx vitest";
|
|
462
462
|
if (errors.length === 0)
|
|
463
|
-
logger.step(CLI_COLORS.success("@storybook/addon-vitest setup completed successfully")), logger.log(import_ts_dedent.dedent`
|
|
463
|
+
await refreshAgentInstructions({ testSupported: !0, sawEveryStorybook: !1 }), logger.step(CLI_COLORS.success("@storybook/addon-vitest setup completed successfully")), logger.log(import_ts_dedent.dedent`
|
|
464
464
|
@storybook/addon-vitest is now configured and you're ready to run your tests!
|
|
465
465
|
Here are a couple of tips to get you started:
|
|
466
466
|
|
package/dist/preset.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
errorToErrorLike,
|
|
3
3
|
log,
|
|
4
4
|
noop
|
|
5
|
-
} from "./_node-chunks/chunk-
|
|
5
|
+
} from "./_node-chunks/chunk-4HVYW5B2.js";
|
|
6
6
|
import {
|
|
7
7
|
require_picocolors
|
|
8
8
|
} from "./_node-chunks/chunk-MTTYIP6M.js";
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
TRIGGER_TEST_RUN_REQUEST,
|
|
26
26
|
TRIGGER_TEST_RUN_RESPONSE,
|
|
27
27
|
storeOptions
|
|
28
|
-
} from "./_node-chunks/chunk-
|
|
28
|
+
} from "./_node-chunks/chunk-U3I4JYDP.js";
|
|
29
29
|
import {
|
|
30
30
|
__toESM
|
|
31
31
|
} from "./_node-chunks/chunk-PQZIOGBY.js";
|
|
@@ -439,7 +439,7 @@ var resolvePreviewBuilderName = (core) => typeof core?.builder == "string" ? cor
|
|
|
439
439
|
"vite"
|
|
440
440
|
), requestInFlight = !1;
|
|
441
441
|
channel.on(TRIGGER_TEST_RUN_REQUEST, async (payload) => {
|
|
442
|
-
let { requestId, actor, storyIds, config: configOverride } = payload, sendResponse = (response) => {
|
|
442
|
+
let { requestId, actor, storyIds, fileFilters, storyFiles, config: configOverride } = payload, sendResponse = (response) => {
|
|
443
443
|
channel.emit(TRIGGER_TEST_RUN_RESPONSE, { requestId, ...response });
|
|
444
444
|
};
|
|
445
445
|
if (!viteBuilder) {
|
|
@@ -497,6 +497,8 @@ var resolvePreviewBuilderName = (core) => typeof core?.builder == "string" ? cor
|
|
|
497
497
|
type: "TRIGGER_RUN",
|
|
498
498
|
payload: {
|
|
499
499
|
storyIds,
|
|
500
|
+
fileFilters,
|
|
501
|
+
storyFiles,
|
|
500
502
|
triggeredBy: `external:${actor}`,
|
|
501
503
|
...configOverride && {
|
|
502
504
|
configOverride: { ...config, ...configOverride }
|
|
@@ -605,6 +607,21 @@ function minLength(requirement, message$1) {
|
|
|
605
607
|
}
|
|
606
608
|
};
|
|
607
609
|
}
|
|
610
|
+
// @__NO_SIDE_EFFECTS__
|
|
611
|
+
function regex(requirement, message$1) {
|
|
612
|
+
return {
|
|
613
|
+
kind: "validation",
|
|
614
|
+
type: "regex",
|
|
615
|
+
reference: regex,
|
|
616
|
+
async: !1,
|
|
617
|
+
expects: `${requirement}`,
|
|
618
|
+
requirement,
|
|
619
|
+
message: message$1,
|
|
620
|
+
"~run"(dataset, config$1) {
|
|
621
|
+
return dataset.typed && !this.requirement.test(dataset.value) && _addIssue(this, "format", dataset, config$1), dataset;
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
}
|
|
608
625
|
var ABORT_EARLY_CONFIG = { abortEarly: !0 };
|
|
609
626
|
// @__NO_SIDE_EFFECTS__
|
|
610
627
|
function getFallback(schema, dataset, config$1) {
|
|
@@ -1147,7 +1164,6 @@ import {
|
|
|
1147
1164
|
} from "storybook/internal/core-server";
|
|
1148
1165
|
import {
|
|
1149
1166
|
defineToolset,
|
|
1150
|
-
getSkillCommand,
|
|
1151
1167
|
getToolset
|
|
1152
1168
|
} from "storybook/open-service";
|
|
1153
1169
|
|
|
@@ -1321,7 +1337,7 @@ function formatChangedConfigFiles(changed) {
|
|
|
1321
1337
|
function formatSelection(selection) {
|
|
1322
1338
|
let parts = [];
|
|
1323
1339
|
if (selection.files) {
|
|
1324
|
-
let { filters, storyFileCount } = selection.files;
|
|
1340
|
+
let { filters, storyFileCount = 0 } = selection.files;
|
|
1325
1341
|
parts.push(
|
|
1326
1342
|
`${pluralize(storyFileCount, "story file")} ${storyFileCount === 1 ? "matches" : "match"} ${filters.map((filter) => code(displayPath(filter))).join(", ")}`
|
|
1327
1343
|
);
|
|
@@ -1428,7 +1444,11 @@ function formatTestRun(data, ctx, { a11yEnabled }) {
|
|
|
1428
1444
|
|
|
1429
1445
|
// src/node/toolset/run.ts
|
|
1430
1446
|
import {
|
|
1431
|
-
|
|
1447
|
+
detectBlockedNetwork,
|
|
1448
|
+
formatBlockedNetwork,
|
|
1449
|
+
RERUN_OUTSIDE_SANDBOX
|
|
1450
|
+
} from "storybook/internal/common";
|
|
1451
|
+
import {
|
|
1432
1452
|
findStoryIds
|
|
1433
1453
|
} from "storybook/internal/core-server";
|
|
1434
1454
|
import { OpenServiceTestRunTimeoutError } from "storybook/internal/server-errors";
|
|
@@ -1452,6 +1472,8 @@ function triggerTestRun({
|
|
|
1452
1472
|
requestEvent,
|
|
1453
1473
|
responseEvent,
|
|
1454
1474
|
storyIds,
|
|
1475
|
+
fileFilters,
|
|
1476
|
+
storyFiles,
|
|
1455
1477
|
config,
|
|
1456
1478
|
actor,
|
|
1457
1479
|
timeoutMs = DEFAULT_TEST_RUN_TIMEOUT_MS
|
|
@@ -1483,6 +1505,8 @@ function triggerTestRun({
|
|
|
1483
1505
|
requestId,
|
|
1484
1506
|
actor,
|
|
1485
1507
|
storyIds,
|
|
1508
|
+
fileFilters,
|
|
1509
|
+
storyFiles,
|
|
1486
1510
|
config
|
|
1487
1511
|
});
|
|
1488
1512
|
} catch (error) {
|
|
@@ -1490,6 +1514,17 @@ function triggerTestRun({
|
|
|
1490
1514
|
}
|
|
1491
1515
|
});
|
|
1492
1516
|
}
|
|
1517
|
+
function blockedRunResult(blocked) {
|
|
1518
|
+
return {
|
|
1519
|
+
status: "error",
|
|
1520
|
+
error: {
|
|
1521
|
+
message: `The tests did not run: ${formatBlockedNetwork(blocked)}. This is not a problem in the code. ${RERUN_OUTSIDE_SANDBOX}`
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
function blockedBeforeAnyTest(result) {
|
|
1526
|
+
return result.componentTestCount.success + result.componentTestCount.error === 0 ? result.unhandledErrors.map((error) => detectBlockedNetwork(error)).find(Boolean) : void 0;
|
|
1527
|
+
}
|
|
1493
1528
|
async function runStoryTests({
|
|
1494
1529
|
channel,
|
|
1495
1530
|
getIndex,
|
|
@@ -1503,25 +1538,19 @@ async function runStoryTests({
|
|
|
1503
1538
|
responseEvent = TRIGGER_TEST_RUN_RESPONSE,
|
|
1504
1539
|
timeoutMs = DEFAULT_TEST_RUN_TIMEOUT_MS
|
|
1505
1540
|
}) {
|
|
1506
|
-
let storyIds, selection, notFoundMessages = [], filters = files?.length ? files : void 0;
|
|
1541
|
+
let storyIds, storyFiles, selection, notFoundMessages = [], filters = files?.length ? files : void 0;
|
|
1507
1542
|
if (stories || filters || changed) {
|
|
1508
1543
|
let since = typeof changed == "string" ? changed : void 0, changedStories = changed ? await getChangedStories2(since) : void 0, index = await getIndex(), candidates, narrow = (ids) => {
|
|
1509
1544
|
candidates = new Set(candidates ? ids.filter((id) => candidates.has(id)) : ids);
|
|
1510
1545
|
};
|
|
1511
|
-
if (selection = {}, filters) {
|
|
1512
|
-
let matched = filterStoryFiles({ index, filters });
|
|
1513
|
-
selection.files = { filters, storyFileCount: matched.storyFiles.length }, matched.storyFiles.length === 0 && !changed && notFoundMessages.push(
|
|
1514
|
-
`No story files found for ${filters.map((file) => `\`${displayPath(file)}\``).join(", ")}.`
|
|
1515
|
-
), narrow(matched.storyIds);
|
|
1516
|
-
}
|
|
1517
|
-
if (changedStories) {
|
|
1546
|
+
if (selection = {}, filters && (selection.files = { filters }), changedStories) {
|
|
1518
1547
|
let { storyIds: changedIds, changedConfigFiles, pendingFiles } = changedStories;
|
|
1519
1548
|
selection.changed = {
|
|
1520
1549
|
storyCount: changedIds.length,
|
|
1521
1550
|
changedConfigFiles,
|
|
1522
1551
|
pendingFiles,
|
|
1523
1552
|
...since === void 0 ? {} : { since }
|
|
1524
|
-
}, narrow(changedIds);
|
|
1553
|
+
}, stories ? narrow(changedIds) : storyFiles = changedStories.storyFiles;
|
|
1525
1554
|
}
|
|
1526
1555
|
if (stories) {
|
|
1527
1556
|
selection.inputStoryCount = stories.length;
|
|
@@ -1532,7 +1561,7 @@ async function runStoryTests({
|
|
|
1532
1561
|
resolved.filter((story) => "entry" in story).map((story) => story.entry.id)
|
|
1533
1562
|
);
|
|
1534
1563
|
}
|
|
1535
|
-
if (candidates?.size === 0)
|
|
1564
|
+
if (candidates?.size === 0 || storyFiles?.length === 0)
|
|
1536
1565
|
return { status: "no-stories", notFoundMessages, selection };
|
|
1537
1566
|
storyIds = candidates ? [...candidates] : void 0, selection.storyCount = storyIds?.length;
|
|
1538
1567
|
}
|
|
@@ -1543,6 +1572,8 @@ async function runStoryTests({
|
|
|
1543
1572
|
requestEvent,
|
|
1544
1573
|
responseEvent,
|
|
1545
1574
|
storyIds,
|
|
1575
|
+
fileFilters: filters,
|
|
1576
|
+
storyFiles,
|
|
1546
1577
|
config: { a11y },
|
|
1547
1578
|
actor,
|
|
1548
1579
|
timeoutMs
|
|
@@ -1556,24 +1587,32 @@ async function runStoryTests({
|
|
|
1556
1587
|
};
|
|
1557
1588
|
}
|
|
1558
1589
|
switch (response.status) {
|
|
1559
|
-
case "completed":
|
|
1560
|
-
|
|
1590
|
+
case "completed": {
|
|
1591
|
+
if (!response.result)
|
|
1592
|
+
return {
|
|
1593
|
+
status: "error",
|
|
1594
|
+
error: { message: "Test run completed but no result was returned" }
|
|
1595
|
+
};
|
|
1596
|
+
let { result } = response, blocked = blockedBeforeAnyTest(result);
|
|
1597
|
+
return blocked ? blockedRunResult(blocked) : (selection?.files && (selection.files.storyFileCount = result.matchedFileCount ?? 0, selection.files.storyFileCount === 0 && !changed && notFoundMessages.push(
|
|
1598
|
+
`No story files found for ${selection.files.filters.map((file) => `\`${displayPath(file)}\``).join(", ")}.`
|
|
1599
|
+
)), selection && (filters || storyFiles) && (selection.storyCount = result.storyIds?.length, filters && result.storyIds?.length === 0) ? { status: "no-stories", notFoundMessages, selection } : {
|
|
1561
1600
|
status: "completed",
|
|
1562
|
-
result
|
|
1601
|
+
result,
|
|
1563
1602
|
...selection ? { selection } : {},
|
|
1564
1603
|
...notFoundMessages.length > 0 ? { notFoundMessages } : {}
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
return {
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
case "error": {
|
|
1607
|
+
let blocked = detectBlockedNetwork(response.error) ?? detectBlockedNetwork(response.error?.error);
|
|
1608
|
+
return blocked ? blockedRunResult(blocked) : {
|
|
1571
1609
|
status: "error",
|
|
1572
1610
|
error: {
|
|
1573
1611
|
message: response.error?.message ?? "Test run failed with unknown error",
|
|
1574
1612
|
...response.error?.error !== void 0 ? { error: response.error.error } : {}
|
|
1575
1613
|
}
|
|
1576
1614
|
};
|
|
1615
|
+
}
|
|
1577
1616
|
case "cancelled":
|
|
1578
1617
|
return { status: "cancelled" };
|
|
1579
1618
|
default:
|
|
@@ -1613,6 +1652,7 @@ var errorLikeSchema = object({
|
|
|
1613
1652
|
a11yReports: record(string(), array(any())),
|
|
1614
1653
|
reports: record(string(), array(any())),
|
|
1615
1654
|
totalTestCount: optional(number()),
|
|
1655
|
+
matchedFileCount: optional(number()),
|
|
1616
1656
|
storyIds: optional(array(string())),
|
|
1617
1657
|
startedAt: optional(number()),
|
|
1618
1658
|
finishedAt: optional(number()),
|
|
@@ -1629,7 +1669,13 @@ var errorLikeSchema = object({
|
|
|
1629
1669
|
})
|
|
1630
1670
|
)
|
|
1631
1671
|
}), selectionSchema = object({
|
|
1632
|
-
files: optional(
|
|
1672
|
+
files: optional(
|
|
1673
|
+
object({
|
|
1674
|
+
filters: array(string()),
|
|
1675
|
+
/** How many story files Vitest matched. Not there when the call stopped before that. */
|
|
1676
|
+
storyFileCount: optional(number())
|
|
1677
|
+
})
|
|
1678
|
+
),
|
|
1633
1679
|
changed: optional(
|
|
1634
1680
|
object({
|
|
1635
1681
|
/** How many stories `stories changed` listed. */
|
|
@@ -1681,8 +1727,18 @@ var errorLikeSchema = object({
|
|
|
1681
1727
|
),
|
|
1682
1728
|
files: optional(
|
|
1683
1729
|
pipe(
|
|
1684
|
-
|
|
1685
|
-
|
|
1730
|
+
array(
|
|
1731
|
+
pipe(
|
|
1732
|
+
string(),
|
|
1733
|
+
// An empty entry, as from an unset variable, would match every story file.
|
|
1734
|
+
minLength(1),
|
|
1735
|
+
// Vitest reads `Button.stories.tsx:12` as the test at that line, which the runner cannot run.
|
|
1736
|
+
regex(
|
|
1737
|
+
/^(?!.*:\d+(-\d+)?$)/,
|
|
1738
|
+
"A line number after a file is not supported. To test one story, pass it in stories."
|
|
1739
|
+
)
|
|
1740
|
+
)
|
|
1741
|
+
),
|
|
1686
1742
|
description(
|
|
1687
1743
|
"Story files to test: each entry selects the story files whose path contains it (case-insensitive), or that an absolute path or directory points to. Only story files match; to test the stories that depend on a changed component, use `changed`."
|
|
1688
1744
|
)
|
|
@@ -1693,7 +1749,7 @@ var errorLikeSchema = object({
|
|
|
1693
1749
|
// An empty ref, as from an unset variable in CI, must not read as "not changed".
|
|
1694
1750
|
union([boolean(), pipe(string(), minLength(1))]),
|
|
1695
1751
|
description(
|
|
1696
|
-
"Test the changed stories
|
|
1752
|
+
"Test the story files of the changed stories that the stories changed tool lists: new and modified stories, and the stories that depend on changed files. true for the uncommitted changes, or a git ref (a branch, tag or commit) for what this branch committed since it forked from that ref, plus the uncommitted changes. Combined with files or stories, only the stories that match both run."
|
|
1697
1753
|
)
|
|
1698
1754
|
)
|
|
1699
1755
|
),
|
|
@@ -1707,14 +1763,9 @@ var errorLikeSchema = object({
|
|
|
1707
1763
|
!0
|
|
1708
1764
|
)
|
|
1709
1765
|
});
|
|
1710
|
-
function describeRun(a11yEnabled
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
First run ${skill} once and follow it: it has the rules for running the tests and fixing what fails.` : ""}
|
|
1714
|
-
Run them after editing anything that changes how the UI looks \u2014 components, stories, styles, CSS, themes, colors, or design tokens \u2014 shell-level substitutes like typecheck, lint, or package.json test scripts do not replace this.
|
|
1715
|
-
Use changed for focused runs on what you changed (faster while iterating), or files for specific story files,
|
|
1716
|
-
and leave all of them out to run every story.
|
|
1717
|
-
Use this continuously to monitor test results as you work on your UI components and stories.
|
|
1766
|
+
function describeRun(a11yEnabled) {
|
|
1767
|
+
return `Run story tests.
|
|
1768
|
+
Use changed for the stories your changes affect, or files for specific story files, and leave both out to run every story.
|
|
1718
1769
|
Results will include passing/failing status` + (a11yEnabled ? `, and accessibility violation reports.
|
|
1719
1770
|
For visual/design accessibility violations (for example color contrast), ask the user before changing styles.` : ".");
|
|
1720
1771
|
}
|
|
@@ -1767,6 +1818,7 @@ async function getChangedStories(ctx, since) {
|
|
|
1767
1818
|
);
|
|
1768
1819
|
return {
|
|
1769
1820
|
storyIds: data.stories.map((story) => story.storyId),
|
|
1821
|
+
storyFiles: [...new Set(data.stories.map((story) => story.importPath))],
|
|
1770
1822
|
changedConfigFiles: data.changedConfigFiles,
|
|
1771
1823
|
pendingFiles: [...data.unindexedStoryFiles, ...data.pendingFiles]
|
|
1772
1824
|
};
|
|
@@ -1785,7 +1837,7 @@ function createTestToolset({
|
|
|
1785
1837
|
input: runInputSchema,
|
|
1786
1838
|
positional: "files",
|
|
1787
1839
|
title: "Run Storybook tests",
|
|
1788
|
-
description: (
|
|
1840
|
+
description: () => describeRun(a11yEnabled),
|
|
1789
1841
|
handler: async (input, ctx) => {
|
|
1790
1842
|
let done = await queue.wait();
|
|
1791
1843
|
try {
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
STORYBOOK_CORE_RENDER_ANALYSIS_PROVIDE_KEY,
|
|
18
18
|
STORYBOOK_TEST_FEATURES_PROVIDE_KEY,
|
|
19
19
|
STORYBOOK_TEST_INITIAL_GLOBALS_PROVIDE_KEY
|
|
20
|
-
} from "../_node-chunks/chunk-
|
|
20
|
+
} from "../_node-chunks/chunk-U3I4JYDP.js";
|
|
21
21
|
import {
|
|
22
22
|
__commonJS,
|
|
23
23
|
__esm,
|
|
@@ -2354,7 +2354,7 @@ import {
|
|
|
2354
2354
|
var import_picocolors = __toESM(require_picocolors(), 1), import_sirv = __toESM(require_build(), 1), import_ts_dedent2 = __toESM(require_dist(), 1);
|
|
2355
2355
|
|
|
2356
2356
|
// package.json
|
|
2357
|
-
var version = "11.0.0-
|
|
2357
|
+
var version = "11.0.0-rc.1";
|
|
2358
2358
|
|
|
2359
2359
|
// ../../builders/builder-vite/src/utils/without-vite-plugins.ts
|
|
2360
2360
|
var withoutVitePlugins = async (plugins = [], namesToRemove) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PANEL_ID,
|
|
3
3
|
STORYBOOK_TEST_FEATURES_PROVIDE_KEY
|
|
4
|
-
} from "../_browser-chunks/chunk-
|
|
4
|
+
} from "../_browser-chunks/chunk-JNYCH5SZ.js";
|
|
5
5
|
|
|
6
6
|
// src/vitest-plugin/setup-file.ts
|
|
7
7
|
import { afterEach, beforeAll, beforeEach, inject, vi } from "vitest";
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
STORYBOOK_CORE_RENDER_ANALYSIS_PROVIDE_KEY,
|
|
4
4
|
STORYBOOK_TEST_INITIAL_GLOBALS_PROVIDE_KEY,
|
|
5
5
|
STORYBOOK_TEST_PROVIDE_KEY
|
|
6
|
-
} from "../_browser-chunks/chunk-
|
|
6
|
+
} from "../_browser-chunks/chunk-JNYCH5SZ.js";
|
|
7
7
|
|
|
8
8
|
// src/vitest-plugin/test-utils.ts
|
|
9
9
|
import { inject } from "vitest";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-vitest",
|
|
3
|
-
"version": "11.0.0-
|
|
3
|
+
"version": "11.0.0-rc.1",
|
|
4
4
|
"description": "Storybook Vitest addon: Blazing fast component testing using stories",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -77,12 +77,11 @@
|
|
|
77
77
|
"!src/**/*"
|
|
78
78
|
],
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@storybook/global": "^5.0.0",
|
|
81
80
|
"@storybook/icons": "^2.0.2"
|
|
82
81
|
},
|
|
83
82
|
"devDependencies": {
|
|
84
|
-
"@storybook/addon-a11y": "11.0.0-
|
|
85
|
-
"@storybook/builder-vite": "11.0.0-
|
|
83
|
+
"@storybook/addon-a11y": "11.0.0-rc.1",
|
|
84
|
+
"@storybook/builder-vite": "11.0.0-rc.1",
|
|
86
85
|
"@types/istanbul-lib-report": "^3.0.3",
|
|
87
86
|
"@types/micromatch": "^4.0.0",
|
|
88
87
|
"@types/node": "^22.19.1",
|
|
@@ -110,7 +109,7 @@
|
|
|
110
109
|
"peerDependencies": {
|
|
111
110
|
"@vitest/browser": "^4.0.0 || ^5.0.0",
|
|
112
111
|
"@vitest/browser-playwright": "^4.0.0 || ^5.0.0",
|
|
113
|
-
"storybook": "^11.0.0-
|
|
112
|
+
"storybook": "^11.0.0-rc.1",
|
|
114
113
|
"vitest": "^4.0.0 || ^5.0.0"
|
|
115
114
|
},
|
|
116
115
|
"peerDependenciesMeta": {
|