@storybook/addon-vitest 0.0.0-pr-32412-sha-4e0feb24 → 0.0.0-pr-32458-sha-a8934fc9
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/_node-chunks/{chunk-N34KX3CN.js → chunk-226MMIJW.js} +7 -7
- package/dist/_node-chunks/{chunk-OZHW4RTJ.js → chunk-3USXLZ32.js} +6 -6
- package/dist/_node-chunks/{chunk-5HXFH4CR.js → chunk-5IRNZM6E.js} +325 -15
- package/dist/_node-chunks/{chunk-X2ZIL2ID.js → chunk-E3O3SZWH.js} +6 -6
- package/dist/_node-chunks/chunk-NTCNCRSX.js +98 -0
- package/dist/_node-chunks/{chunk-Y3DMC4DM.js → chunk-T4BKNWFR.js} +9 -9
- package/dist/_node-chunks/{chunk-MHB2QQK5.js → chunk-T4U7VHZY.js} +7 -7
- package/dist/_node-chunks/{chunk-UJYZKRFO.js → chunk-XC3FDNT2.js} +7 -7
- package/dist/manager.js +116 -142
- package/dist/node/coverage-reporter.js +8 -8
- package/dist/node/vitest.js +42 -21
- package/dist/postinstall.js +31 -24
- package/dist/preset.js +12 -12
- package/dist/vitest-plugin/global-setup.js +7 -7
- package/dist/vitest-plugin/index.js +15 -12
- package/dist/vitest-plugin/test-utils.js +10 -7
- package/package.json +4 -4
- package/dist/_node-chunks/chunk-YZ45VJKW.js +0 -295
package/dist/manager.js
CHANGED
|
@@ -37,8 +37,8 @@ import { addons as addons2 } from "storybook/manager-api";
|
|
|
37
37
|
|
|
38
38
|
// src/components/GlobalErrorModal.tsx
|
|
39
39
|
import React, { useContext } from "react";
|
|
40
|
-
import { Button,
|
|
41
|
-
import {
|
|
40
|
+
import { Button, Modal } from "storybook/internal/components";
|
|
41
|
+
import { SyncIcon } from "@storybook/icons";
|
|
42
42
|
import { useStorybookApi } from "storybook/manager-api";
|
|
43
43
|
import { styled } from "storybook/theming";
|
|
44
44
|
var ModalBar = styled.div({
|
|
@@ -85,7 +85,6 @@ __name(ErrorCause, "ErrorCause");
|
|
|
85
85
|
function GlobalErrorModal({ onRerun, storeState }) {
|
|
86
86
|
const api = useStorybookApi();
|
|
87
87
|
const { isModalOpen, setModalOpen } = useContext(GlobalErrorContext);
|
|
88
|
-
const handleClose = /* @__PURE__ */ __name(() => setModalOpen?.(false), "handleClose");
|
|
89
88
|
const troubleshootURL = api.getDocsUrl({
|
|
90
89
|
subpath: DOCUMENTATION_FATAL_ERROR_LINK,
|
|
91
90
|
versioned: true,
|
|
@@ -96,7 +95,7 @@ function GlobalErrorModal({ onRerun, storeState }) {
|
|
|
96
95
|
currentRun: { unhandledErrors }
|
|
97
96
|
} = storeState;
|
|
98
97
|
const content = fatalError ? React.createElement(React.Fragment, null, React.createElement("p", null, fatalError.error.name || "Error"), fatalError.message && React.createElement("p", null, fatalError.message), fatalError.error.message && React.createElement("p", null, fatalError.error.message), fatalError.error.stack && React.createElement("p", null, fatalError.error.stack), fatalError.error.cause && React.createElement(ErrorCause, { error: fatalError.error.cause })) : unhandledErrors.length > 0 ? React.createElement("ol", null, unhandledErrors.map((error) => React.createElement("li", { key: error.name + error.message }, React.createElement("p", null, error.name, ": ", error.message), error.VITEST_TEST_PATH && React.createElement("p", null, 'This error originated in "', React.createElement("b", null, error.VITEST_TEST_PATH), `". It doesn't mean the error was thrown inside the file itself, but while it was running.`), error.VITEST_TEST_NAME && React.createElement(React.Fragment, null, React.createElement("p", null, `The latest test that might've caused the error is "`, React.createElement("b", null, error.VITEST_TEST_NAME), '". It might mean one of the following:'), React.createElement("ul", null, React.createElement("li", null, "The error was thrown, while Vitest was running this test."), React.createElement("li", null, "If the error occurred after the test had been completed, this was the last documented test before it was thrown."))), error.stacks && React.createElement(React.Fragment, null, React.createElement("p", null, React.createElement("b", null, "Stacks:")), React.createElement("ul", null, error.stacks.map((stack) => React.createElement("li", { key: stack.file + stack.line + stack.column }, stack.file, ":", stack.line, ":", stack.column, " - ", stack.method || "unknown method")))), error.stack && React.createElement("p", null, error.stack), error.cause ? React.createElement(ErrorCause, { error: error.cause }) : null))) : null;
|
|
99
|
-
return React.createElement(Modal, {
|
|
98
|
+
return React.createElement(Modal, { ariaLabel: "Storybook Tests error details", onOpenChange: setModalOpen, open: isModalOpen }, React.createElement(ModalBar, null, React.createElement(ModalTitle, null, "Storybook Tests error details"), React.createElement(ModalActionBar, null, React.createElement(Button, { onClick: onRerun, variant: "ghost", ariaLabel: false }, React.createElement(SyncIcon, null), "Rerun"), React.createElement(Button, { variant: "ghost", ariaLabel: false, asChild: true }, React.createElement("a", { target: "_blank", href: troubleshootURL, rel: "noreferrer" }, "Troubleshoot")), React.createElement(Modal.Close, null))), React.createElement(ModalStackTrace, null, content, React.createElement("br", null), React.createElement("br", null), "Troubleshoot:", " ", React.createElement(TroubleshootLink, { target: "_blank", href: troubleshootURL }, troubleshootURL)));
|
|
100
99
|
}
|
|
101
100
|
__name(GlobalErrorModal, "GlobalErrorModal");
|
|
102
101
|
|
|
@@ -434,12 +433,11 @@ var useTestProvider = /* @__PURE__ */ __name((api, entryId) => {
|
|
|
434
433
|
// src/components/TestProviderRender.tsx
|
|
435
434
|
import React3 from "react";
|
|
436
435
|
import {
|
|
436
|
+
Button as Button2,
|
|
437
437
|
Form,
|
|
438
|
-
IconButton as IconButton2,
|
|
439
438
|
ListItem,
|
|
440
439
|
ProgressSpinner,
|
|
441
|
-
|
|
442
|
-
WithTooltip
|
|
440
|
+
ToggleButton
|
|
443
441
|
} from "storybook/internal/components";
|
|
444
442
|
import { EyeIcon, InfoIcon, PlayHollowIcon, StopAltIcon } from "@storybook/icons";
|
|
445
443
|
import { addons } from "storybook/manager-api";
|
|
@@ -552,8 +550,8 @@ var TestStatusIcon = styled3.div(
|
|
|
552
550
|
"--status-background": `${theme.color.defaultText}66`
|
|
553
551
|
},
|
|
554
552
|
({ status, theme }) => status === "unknown" && {
|
|
555
|
-
"--status-color": theme.
|
|
556
|
-
"--status-background": `${theme.
|
|
553
|
+
"--status-color": theme.textMutedColor,
|
|
554
|
+
"--status-background": `${theme.textMutedColor}66`
|
|
557
555
|
}
|
|
558
556
|
);
|
|
559
557
|
|
|
@@ -642,76 +640,61 @@ var TestProviderRender = /* @__PURE__ */ __name(({
|
|
|
642
640
|
isSettingsUpdated
|
|
643
641
|
}
|
|
644
642
|
)), React3.createElement(Actions, null, !entry && React3.createElement(
|
|
645
|
-
|
|
643
|
+
ToggleButton,
|
|
646
644
|
{
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
645
|
+
ariaLabel: isRunning ? "Watch mode (cannot toggle while running)" : "Watch mode",
|
|
646
|
+
tooltip: isRunning ? "Watch mode unavailable while running" : `Watch mode is ${watching ? "enabled" : "disabled"}`,
|
|
647
|
+
padding: "small",
|
|
648
|
+
size: "medium",
|
|
649
|
+
variant: "ghost",
|
|
650
|
+
pressed: watching,
|
|
651
|
+
onClick: () => store.send({
|
|
652
|
+
type: "TOGGLE_WATCHING",
|
|
653
|
+
payload: {
|
|
654
|
+
to: !watching
|
|
655
|
+
}
|
|
656
|
+
}),
|
|
657
|
+
disabled: isRunning
|
|
650
658
|
},
|
|
651
|
-
React3.createElement(
|
|
652
|
-
IconButton2,
|
|
653
|
-
{
|
|
654
|
-
"aria-label": `${watching ? "Disable" : "Enable"} watch mode`,
|
|
655
|
-
size: "medium",
|
|
656
|
-
active: watching,
|
|
657
|
-
onClick: () => store.send({
|
|
658
|
-
type: "TOGGLE_WATCHING",
|
|
659
|
-
payload: {
|
|
660
|
-
to: !watching
|
|
661
|
-
}
|
|
662
|
-
}),
|
|
663
|
-
disabled: isRunning
|
|
664
|
-
},
|
|
665
|
-
React3.createElement(EyeIcon, null)
|
|
666
|
-
)
|
|
659
|
+
React3.createElement(EyeIcon, null)
|
|
667
660
|
), isRunning ? React3.createElement(
|
|
668
|
-
|
|
661
|
+
Button2,
|
|
669
662
|
{
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
663
|
+
ariaLabel: cancelling ? "Stop test run (already stopping...)" : "Stop test run",
|
|
664
|
+
padding: "none",
|
|
665
|
+
size: "medium",
|
|
666
|
+
variant: "ghost",
|
|
667
|
+
onClick: () => store.send({
|
|
668
|
+
type: "CANCEL_RUN"
|
|
669
|
+
}),
|
|
670
|
+
disabled: cancelling || isStarting
|
|
673
671
|
},
|
|
674
672
|
React3.createElement(
|
|
675
|
-
|
|
673
|
+
Progress,
|
|
676
674
|
{
|
|
677
|
-
|
|
678
|
-
padding: "none",
|
|
679
|
-
size: "medium",
|
|
680
|
-
onClick: () => store.send({
|
|
681
|
-
type: "CANCEL_RUN"
|
|
682
|
-
}),
|
|
683
|
-
disabled: cancelling || isStarting
|
|
675
|
+
percentage: finishedTestCount && storeState.currentRun.totalTestCount ? finishedTestCount / storeState.currentRun.totalTestCount * 100 : void 0
|
|
684
676
|
},
|
|
685
|
-
React3.createElement(
|
|
686
|
-
Progress,
|
|
687
|
-
{
|
|
688
|
-
percentage: finishedTestCount && storeState.currentRun.totalTestCount ? finishedTestCount / storeState.currentRun.totalTestCount * 100 : void 0
|
|
689
|
-
},
|
|
690
|
-
React3.createElement(StopIcon, null)
|
|
691
|
-
)
|
|
677
|
+
React3.createElement(StopIcon, null)
|
|
692
678
|
)
|
|
693
679
|
) : React3.createElement(
|
|
694
|
-
|
|
680
|
+
Button2,
|
|
695
681
|
{
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
682
|
+
ariaLabel: "Start test run",
|
|
683
|
+
padding: "small",
|
|
684
|
+
size: "medium",
|
|
685
|
+
variant: "ghost",
|
|
686
|
+
onClick: () => {
|
|
687
|
+
let storyIds;
|
|
688
|
+
if (entry) {
|
|
689
|
+
storyIds = entry.type === "story" ? [entry.id] : api.findAllLeafStoryIds(entry.id);
|
|
690
|
+
}
|
|
691
|
+
store.send({
|
|
706
692
|
type: "TRIGGER_RUN",
|
|
707
|
-
payload: {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
},
|
|
713
|
-
React3.createElement(PlayHollowIcon, null)
|
|
714
|
-
)
|
|
693
|
+
payload: { storyIds, triggeredBy: entry?.type ?? "global" }
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
},
|
|
697
|
+
React3.createElement(PlayHollowIcon, null)
|
|
715
698
|
))), React3.createElement(Extras, null, React3.createElement(Row, null, React3.createElement(
|
|
716
699
|
ListItem,
|
|
717
700
|
{
|
|
@@ -720,35 +703,24 @@ var TestProviderRender = /* @__PURE__ */ __name(({
|
|
|
720
703
|
icon: entry ? null : React3.createElement(Form.Checkbox, { checked: true, disabled: true })
|
|
721
704
|
}
|
|
722
705
|
), React3.createElement(
|
|
723
|
-
|
|
706
|
+
Button2,
|
|
724
707
|
{
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
708
|
+
ariaLabel: `${componentTestStatusLabel}${componentTestStatusValueToStoryIds["status-value:error"].length + componentTestStatusValueToStoryIds["status-value:warning"].length > 0 ? ` (${componentTestStatusValueToStoryIds["status-value:error"].length + componentTestStatusValueToStoryIds["status-value:warning"].length} errors or warnings so far)` : ""}`,
|
|
709
|
+
tooltip: componentTestStatusLabel,
|
|
710
|
+
padding: "small",
|
|
711
|
+
size: "medium",
|
|
712
|
+
variant: "ghost",
|
|
713
|
+
disabled: componentTestStatusValueToStoryIds["status-value:error"].length === 0 && componentTestStatusValueToStoryIds["status-value:warning"].length === 0 && componentTestStatusValueToStoryIds["status-value:success"].length === 0,
|
|
714
|
+
onClick: () => {
|
|
715
|
+
openPanel({
|
|
716
|
+
api,
|
|
717
|
+
panelId: PANEL_ID,
|
|
718
|
+
entryId: componentTestStatusValueToStoryIds["status-value:error"][0] ?? componentTestStatusValueToStoryIds["status-value:warning"][0] ?? componentTestStatusValueToStoryIds["status-value:success"][0] ?? entry?.id
|
|
719
|
+
});
|
|
720
|
+
}
|
|
728
721
|
},
|
|
729
|
-
React3.createElement(
|
|
730
|
-
|
|
731
|
-
{
|
|
732
|
-
size: "medium",
|
|
733
|
-
disabled: componentTestStatusValueToStoryIds["status-value:error"].length === 0 && componentTestStatusValueToStoryIds["status-value:warning"].length === 0 && componentTestStatusValueToStoryIds["status-value:success"].length === 0,
|
|
734
|
-
onClick: () => {
|
|
735
|
-
openPanel({
|
|
736
|
-
api,
|
|
737
|
-
panelId: PANEL_ID,
|
|
738
|
-
entryId: componentTestStatusValueToStoryIds["status-value:error"][0] ?? componentTestStatusValueToStoryIds["status-value:warning"][0] ?? componentTestStatusValueToStoryIds["status-value:success"][0] ?? entry?.id
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
},
|
|
742
|
-
React3.createElement(
|
|
743
|
-
TestStatusIcon,
|
|
744
|
-
{
|
|
745
|
-
status: componentTestStatusIcon,
|
|
746
|
-
"aria-label": componentTestStatusLabel,
|
|
747
|
-
isRunning
|
|
748
|
-
}
|
|
749
|
-
),
|
|
750
|
-
componentTestStatusValueToStoryIds["status-value:error"].length + componentTestStatusValueToStoryIds["status-value:warning"].length || null
|
|
751
|
-
)
|
|
722
|
+
React3.createElement(TestStatusIcon, { status: componentTestStatusIcon, isRunning }),
|
|
723
|
+
componentTestStatusValueToStoryIds["status-value:error"].length + componentTestStatusValueToStoryIds["status-value:warning"].length || null
|
|
752
724
|
)), !entry && React3.createElement(Row, null, React3.createElement(
|
|
753
725
|
ListItem,
|
|
754
726
|
{
|
|
@@ -766,39 +738,53 @@ var TestProviderRender = /* @__PURE__ */ __name(({
|
|
|
766
738
|
}
|
|
767
739
|
)
|
|
768
740
|
}
|
|
769
|
-
), React3.createElement(
|
|
770
|
-
|
|
741
|
+
), watching || currentRun.triggeredBy && !FULL_RUN_TRIGGERS.includes(currentRun.triggeredBy) ? React3.createElement(
|
|
742
|
+
Button2,
|
|
771
743
|
{
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
744
|
+
padding: "small",
|
|
745
|
+
size: "medium",
|
|
746
|
+
variant: "ghost",
|
|
747
|
+
disabled: true,
|
|
748
|
+
ariaLabel: watching ? `Coverage unavailable in watch mode` : `Coverage unavailable when running focused tests`
|
|
749
|
+
},
|
|
750
|
+
React3.createElement(InfoIcon, null)
|
|
751
|
+
) : currentRun.coverageSummary ? React3.createElement(
|
|
752
|
+
Button2,
|
|
753
|
+
{
|
|
754
|
+
asChild: true,
|
|
755
|
+
padding: "small",
|
|
756
|
+
size: "medium",
|
|
757
|
+
variant: "ghost",
|
|
758
|
+
ariaLabel: (
|
|
759
|
+
// FIXME: I can't deduce from the original tooltip logic whether this use case
|
|
760
|
+
// is logically possible or not. It is a reachable conditional branch in the original code.
|
|
761
|
+
isRunning ? "Open coverage report (testing still in progress)" : `Open coverage report (${currentRun.coverageSummary.percentage}% coverage)`
|
|
779
762
|
)
|
|
780
763
|
},
|
|
781
|
-
|
|
782
|
-
InfoIcon,
|
|
783
|
-
{
|
|
784
|
-
"aria-label": watching ? `Coverage is unavailable in watch mode` : `Coverage is unavailable when running focused tests`
|
|
785
|
-
}
|
|
786
|
-
)) : currentRun.coverageSummary ? React3.createElement(IconButton2, { asChild: true, size: "medium" }, React3.createElement("a", { href: "/coverage/index.html", target: "_blank", "aria-label": "Open coverage report" }, React3.createElement(
|
|
764
|
+
React3.createElement("a", { href: "/coverage/index.html", target: "_blank" }, React3.createElement(
|
|
787
765
|
TestStatusIcon,
|
|
788
766
|
{
|
|
789
767
|
isRunning,
|
|
790
768
|
percentage: currentRun.coverageSummary.percentage,
|
|
791
|
-
status: currentRun.coverageSummary.status
|
|
792
|
-
"aria-label": `Coverage status: ${currentRun.coverageSummary.status}`
|
|
769
|
+
status: currentRun.coverageSummary.status
|
|
793
770
|
}
|
|
794
|
-
),
|
|
771
|
+
), currentRun.coverageSummary.percentage, "%")
|
|
772
|
+
) : React3.createElement(
|
|
773
|
+
Button2,
|
|
774
|
+
{
|
|
775
|
+
padding: "small",
|
|
776
|
+
size: "medium",
|
|
777
|
+
variant: "ghost",
|
|
778
|
+
disabled: true,
|
|
779
|
+
ariaLabel: isRunning ? "Coverage unavailable, testing still in progress" : fatalError ? "Coverage unavailable, component tests crashed" : "Coverage unavailable, run tests first"
|
|
780
|
+
},
|
|
781
|
+
React3.createElement(
|
|
795
782
|
TestStatusIcon,
|
|
796
783
|
{
|
|
797
784
|
isRunning,
|
|
798
|
-
status: fatalError ? "critical" : "unknown"
|
|
799
|
-
"aria-label": "Coverage status: unknown"
|
|
785
|
+
status: fatalError ? "critical" : "unknown"
|
|
800
786
|
}
|
|
801
|
-
)
|
|
787
|
+
)
|
|
802
788
|
)), hasA11yAddon && React3.createElement(Row, null, React3.createElement(
|
|
803
789
|
ListItem,
|
|
804
790
|
{
|
|
@@ -817,35 +803,23 @@ var TestProviderRender = /* @__PURE__ */ __name(({
|
|
|
817
803
|
)
|
|
818
804
|
}
|
|
819
805
|
), React3.createElement(
|
|
820
|
-
|
|
806
|
+
Button2,
|
|
821
807
|
{
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
808
|
+
ariaLabel: a11yStatusLabel,
|
|
809
|
+
padding: "small",
|
|
810
|
+
size: "medium",
|
|
811
|
+
variant: "ghost",
|
|
812
|
+
disabled: a11yStatusValueToStoryIds["status-value:error"].length === 0 && a11yStatusValueToStoryIds["status-value:warning"].length === 0 && a11yStatusValueToStoryIds["status-value:success"].length === 0,
|
|
813
|
+
onClick: () => {
|
|
814
|
+
openPanel({
|
|
815
|
+
api,
|
|
816
|
+
entryId: a11yStatusValueToStoryIds["status-value:error"][0] ?? a11yStatusValueToStoryIds["status-value:warning"][0] ?? a11yStatusValueToStoryIds["status-value:success"][0] ?? entry?.id,
|
|
817
|
+
panelId: PANEL_ID2
|
|
818
|
+
});
|
|
819
|
+
}
|
|
825
820
|
},
|
|
826
|
-
React3.createElement(
|
|
827
|
-
|
|
828
|
-
{
|
|
829
|
-
size: "medium",
|
|
830
|
-
disabled: a11yStatusValueToStoryIds["status-value:error"].length === 0 && a11yStatusValueToStoryIds["status-value:warning"].length === 0 && a11yStatusValueToStoryIds["status-value:success"].length === 0,
|
|
831
|
-
onClick: () => {
|
|
832
|
-
openPanel({
|
|
833
|
-
api,
|
|
834
|
-
entryId: a11yStatusValueToStoryIds["status-value:error"][0] ?? a11yStatusValueToStoryIds["status-value:warning"][0] ?? a11yStatusValueToStoryIds["status-value:success"][0] ?? entry?.id,
|
|
835
|
-
panelId: PANEL_ID2
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
},
|
|
839
|
-
React3.createElement(
|
|
840
|
-
TestStatusIcon,
|
|
841
|
-
{
|
|
842
|
-
status: a11yStatusIcon,
|
|
843
|
-
"aria-label": a11yStatusLabel,
|
|
844
|
-
isRunning
|
|
845
|
-
}
|
|
846
|
-
),
|
|
847
|
-
a11yStatusValueToStoryIds["status-value:error"].length + a11yStatusValueToStoryIds["status-value:warning"].length || null
|
|
848
|
-
)
|
|
821
|
+
React3.createElement(TestStatusIcon, { status: a11yStatusIcon, isRunning }),
|
|
822
|
+
a11yStatusValueToStoryIds["status-value:error"].length + a11yStatusValueToStoryIds["status-value:warning"].length || null
|
|
849
823
|
))));
|
|
850
824
|
}, "TestProviderRender");
|
|
851
825
|
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_5w076g95rck from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_5w076g95rck from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_5w076g95rck from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_5w076g95rck.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_5w076g95rck.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_5w076g95rck.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
require_gte
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
14
|
+
} from "../_node-chunks/chunk-XC3FDNT2.js";
|
|
15
15
|
import {
|
|
16
16
|
__commonJS,
|
|
17
17
|
__name,
|
|
18
18
|
__require,
|
|
19
19
|
__toESM
|
|
20
|
-
} from "../_node-chunks/chunk-
|
|
20
|
+
} from "../_node-chunks/chunk-E3O3SZWH.js";
|
|
21
21
|
|
|
22
22
|
// ../../node_modules/istanbul-lib-report/node_modules/make-dir/index.js
|
|
23
23
|
var require_make_dir = __commonJS({
|
package/dist/node/vitest.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_5w076g95rck from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_5w076g95rck from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_5w076g95rck from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_5w076g95rck.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_5w076g95rck.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_5w076g95rck.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
log
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
14
|
+
} from "../_node-chunks/chunk-T4BKNWFR.js";
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from "../_node-chunks/chunk-
|
|
16
|
+
any,
|
|
17
|
+
errorToErrorLike
|
|
18
|
+
} from "../_node-chunks/chunk-NTCNCRSX.js";
|
|
19
19
|
import {
|
|
20
20
|
ADDON_ID,
|
|
21
21
|
COVERAGE_DIRECTORY,
|
|
22
22
|
STATUS_TYPE_ID_A11Y,
|
|
23
23
|
STATUS_TYPE_ID_COMPONENT_TEST,
|
|
24
24
|
storeOptions
|
|
25
|
-
} from "../_node-chunks/chunk-
|
|
26
|
-
import "../_node-chunks/chunk-
|
|
25
|
+
} from "../_node-chunks/chunk-3USXLZ32.js";
|
|
26
|
+
import "../_node-chunks/chunk-226MMIJW.js";
|
|
27
27
|
import {
|
|
28
28
|
dirname,
|
|
29
29
|
join,
|
|
30
30
|
normalize,
|
|
31
31
|
path
|
|
32
|
-
} from "../_node-chunks/chunk-
|
|
32
|
+
} from "../_node-chunks/chunk-T4U7VHZY.js";
|
|
33
33
|
import {
|
|
34
34
|
__name
|
|
35
|
-
} from "../_node-chunks/chunk-
|
|
35
|
+
} from "../_node-chunks/chunk-E3O3SZWH.js";
|
|
36
36
|
|
|
37
37
|
// src/node/vitest.ts
|
|
38
38
|
import process2 from "node:process";
|
|
@@ -84,7 +84,6 @@ function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
|
84
84
|
pendingArgs = null;
|
|
85
85
|
}, "cancel");
|
|
86
86
|
const flush = /* @__PURE__ */ __name(() => {
|
|
87
|
-
cancelTimer();
|
|
88
87
|
invoke();
|
|
89
88
|
}, "flush");
|
|
90
89
|
const debounced = /* @__PURE__ */ __name(function(...args) {
|
|
@@ -243,6 +242,8 @@ var StorybookReporter = class {
|
|
|
243
242
|
var VITEST_CONFIG_FILE_EXTENSIONS = ["mts", "mjs", "cts", "cjs", "ts", "tsx", "js", "jsx"];
|
|
244
243
|
var VITEST_WORKSPACE_FILE_EXTENSION = ["ts", "js", "json"];
|
|
245
244
|
process.env.VITEST_STORYBOOK = "true";
|
|
245
|
+
var DOUBLE_SPACES = " ";
|
|
246
|
+
var getTestName = /* @__PURE__ */ __name((name) => `${name}${DOUBLE_SPACES}`, "getTestName");
|
|
246
247
|
var VitestManager = class {
|
|
247
248
|
constructor(testManager) {
|
|
248
249
|
this.testManager = testManager;
|
|
@@ -271,12 +272,12 @@ var VitestManager = class {
|
|
|
271
272
|
reporter: [["html", {}], storybookCoverageReporter],
|
|
272
273
|
reportsDirectory: resolvePathInStorybookCache(COVERAGE_DIRECTORY)
|
|
273
274
|
} : { enabled: false };
|
|
274
|
-
const vitestWorkspaceConfig =
|
|
275
|
+
const vitestWorkspaceConfig = any(
|
|
275
276
|
[
|
|
276
277
|
...VITEST_WORKSPACE_FILE_EXTENSION.map((ext) => `vitest.workspace.${ext}`),
|
|
277
278
|
...VITEST_CONFIG_FILE_EXTENSIONS.map((ext) => `vitest.config.${ext}`)
|
|
278
279
|
],
|
|
279
|
-
{
|
|
280
|
+
{ last: getProjectRoot() }
|
|
280
281
|
);
|
|
281
282
|
const projectName = "storybook:" + process.env.STORYBOOK_CONFIG_DIR;
|
|
282
283
|
try {
|
|
@@ -433,16 +434,36 @@ Please install the @vitest/${coveragePackage} package to collect coverage
|
|
|
433
434
|
this.resetGlobalTestNamePattern();
|
|
434
435
|
await this.cancelCurrentRun();
|
|
435
436
|
const testSpecifications = await this.getStorybookTestSpecifications();
|
|
436
|
-
const
|
|
437
|
+
const allStories = await this.fetchStories();
|
|
438
|
+
const filteredStories = runPayload.storyIds ? allStories.filter((story) => runPayload.storyIds?.includes(story.id)) : allStories;
|
|
437
439
|
const isSingleStoryRun = runPayload.storyIds?.length === 1;
|
|
438
440
|
if (isSingleStoryRun) {
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
+
const selectedStory = filteredStories.find((story) => story.id === runPayload.storyIds?.[0]);
|
|
442
|
+
if (!selectedStory) {
|
|
443
|
+
throw new Error(`Story ${runPayload.storyIds?.[0]} not found`);
|
|
444
|
+
}
|
|
445
|
+
const storyName = selectedStory.name;
|
|
446
|
+
let regex;
|
|
447
|
+
const isParentStory = allStories.some((story) => selectedStory.id === story.parent);
|
|
448
|
+
const hasParentStory = allStories.some((story) => selectedStory.parent === story.id);
|
|
449
|
+
if (isParentStory) {
|
|
450
|
+
const parentName = getTestName(selectedStory.name);
|
|
451
|
+
regex = new RegExp(`^${parentName}`);
|
|
452
|
+
} else if (hasParentStory) {
|
|
453
|
+
const parentStory = allStories.find((story) => story.id === selectedStory.parent);
|
|
454
|
+
if (!parentStory) {
|
|
455
|
+
throw new Error(`Parent story not found for story ${selectedStory.id}`);
|
|
456
|
+
}
|
|
457
|
+
const parentName = getTestName(parentStory.name);
|
|
458
|
+
regex = new RegExp(`^${parentName} ${storyName}$`);
|
|
459
|
+
} else {
|
|
460
|
+
regex = new RegExp(`^${storyName}$`);
|
|
461
|
+
}
|
|
441
462
|
this.vitest.setGlobalTestNamePattern(regex);
|
|
442
463
|
}
|
|
443
464
|
const { filteredTestSpecifications, filteredStoryIds } = this.filterTestSpecifications(
|
|
444
465
|
testSpecifications,
|
|
445
|
-
|
|
466
|
+
filteredStories
|
|
446
467
|
);
|
|
447
468
|
this.testManager.store.setState((s) => ({
|
|
448
469
|
...s,
|
package/dist/postinstall.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_5w076g95rck from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_5w076g95rck from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_5w076g95rck from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_5w076g95rck.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_5w076g95rck.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_5w076g95rck.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -12,21 +12,22 @@ var require = CJS_COMPAT_NODE_MODULE_tr2v1yz0ftg.createRequire(import.meta.url);
|
|
|
12
12
|
import {
|
|
13
13
|
execa,
|
|
14
14
|
resolvePackageDir
|
|
15
|
-
} from "./_node-chunks/chunk-
|
|
15
|
+
} from "./_node-chunks/chunk-5IRNZM6E.js";
|
|
16
16
|
import {
|
|
17
|
-
|
|
18
|
-
getAddonNames
|
|
19
|
-
|
|
17
|
+
any,
|
|
18
|
+
getAddonNames,
|
|
19
|
+
up
|
|
20
|
+
} from "./_node-chunks/chunk-NTCNCRSX.js";
|
|
20
21
|
import {
|
|
21
22
|
DOCUMENTATION_LINK,
|
|
22
23
|
SUPPORTED_FRAMEWORKS
|
|
23
|
-
} from "./_node-chunks/chunk-
|
|
24
|
+
} from "./_node-chunks/chunk-3USXLZ32.js";
|
|
24
25
|
import {
|
|
25
26
|
dirname,
|
|
26
27
|
join,
|
|
27
28
|
relative,
|
|
28
29
|
resolve
|
|
29
|
-
} from "./_node-chunks/chunk-
|
|
30
|
+
} from "./_node-chunks/chunk-T4U7VHZY.js";
|
|
30
31
|
import {
|
|
31
32
|
require_compare,
|
|
32
33
|
require_constants,
|
|
@@ -36,12 +37,12 @@ import {
|
|
|
36
37
|
require_parse_options,
|
|
37
38
|
require_re,
|
|
38
39
|
require_semver
|
|
39
|
-
} from "./_node-chunks/chunk-
|
|
40
|
+
} from "./_node-chunks/chunk-XC3FDNT2.js";
|
|
40
41
|
import {
|
|
41
42
|
__commonJS,
|
|
42
43
|
__name,
|
|
43
44
|
__toESM
|
|
44
|
-
} from "./_node-chunks/chunk-
|
|
45
|
+
} from "./_node-chunks/chunk-E3O3SZWH.js";
|
|
45
46
|
|
|
46
47
|
// ../../node_modules/semver/functions/parse.js
|
|
47
48
|
var require_parse = __commonJS({
|
|
@@ -1528,6 +1529,14 @@ import {
|
|
|
1528
1529
|
import { experimental_loadStorybook } from "storybook/internal/core-server";
|
|
1529
1530
|
import { readConfig, writeConfig } from "storybook/internal/csf-tools";
|
|
1530
1531
|
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
1532
|
+
|
|
1533
|
+
// ../../node_modules/empathic/package.mjs
|
|
1534
|
+
function up2(options) {
|
|
1535
|
+
return up("package.json", options);
|
|
1536
|
+
}
|
|
1537
|
+
__name(up2, "up");
|
|
1538
|
+
|
|
1539
|
+
// src/postinstall.ts
|
|
1531
1540
|
var import_semver = __toESM(require_semver2(), 1);
|
|
1532
1541
|
import prompts from "prompts";
|
|
1533
1542
|
import { dedent } from "ts-dedent";
|
|
@@ -1677,9 +1686,9 @@ var logErrors = /* @__PURE__ */ __name((...args) => {
|
|
|
1677
1686
|
hasErrors = true;
|
|
1678
1687
|
printError(...args);
|
|
1679
1688
|
}, "logErrors");
|
|
1680
|
-
var findFile = /* @__PURE__ */ __name(
|
|
1689
|
+
var findFile = /* @__PURE__ */ __name((basename, extensions = EXTENSIONS) => any(
|
|
1681
1690
|
extensions.map((ext) => basename + ext),
|
|
1682
|
-
{
|
|
1691
|
+
{ last: getProjectRoot() }
|
|
1683
1692
|
), "findFile");
|
|
1684
1693
|
async function postInstall(options) {
|
|
1685
1694
|
printSuccess(
|
|
@@ -1883,7 +1892,7 @@ async function postInstall(options) {
|
|
|
1883
1892
|
console.error("Failed to install Playwright. Please install it manually");
|
|
1884
1893
|
}
|
|
1885
1894
|
}
|
|
1886
|
-
const fileExtension = allDeps.typescript ||
|
|
1895
|
+
const fileExtension = allDeps.typescript || findFile("tsconfig", [...EXTENSIONS, ".json"]) ? "ts" : "js";
|
|
1887
1896
|
const vitestSetupFile = resolve(options.configDir, `vitest.setup.${fileExtension}`);
|
|
1888
1897
|
if (existsSync(vitestSetupFile)) {
|
|
1889
1898
|
logErrors(
|
|
@@ -1921,10 +1930,10 @@ async function postInstall(options) {
|
|
|
1921
1930
|
setProjectAnnotations([${projectAnnotations.join(", ")}]);
|
|
1922
1931
|
`
|
|
1923
1932
|
);
|
|
1924
|
-
const vitestWorkspaceFile =
|
|
1925
|
-
const viteConfigFile =
|
|
1926
|
-
const vitestConfigFile =
|
|
1927
|
-
const vitestShimFile =
|
|
1933
|
+
const vitestWorkspaceFile = findFile("vitest.workspace", [".ts", ".js", ".json"]) || findFile("vitest.projects", [".ts", ".js", ".json"]);
|
|
1934
|
+
const viteConfigFile = findFile("vite.config");
|
|
1935
|
+
const vitestConfigFile = findFile("vitest.config");
|
|
1936
|
+
const vitestShimFile = findFile("vitest.shims.d");
|
|
1928
1937
|
const rootConfig = vitestConfigFile || viteConfigFile;
|
|
1929
1938
|
const browserConfig = `{
|
|
1930
1939
|
enabled: true,
|
|
@@ -2094,9 +2103,7 @@ async function getPackageNameFromPath(input) {
|
|
|
2094
2103
|
if (!isAbsolute(path)) {
|
|
2095
2104
|
return path;
|
|
2096
2105
|
}
|
|
2097
|
-
const packageJsonPath =
|
|
2098
|
-
cwd: path
|
|
2099
|
-
});
|
|
2106
|
+
const packageJsonPath = up2({ cwd: path });
|
|
2100
2107
|
if (!packageJsonPath) {
|
|
2101
2108
|
throw new Error(`Could not find package.json in path: ${path}`);
|
|
2102
2109
|
}
|