vitecompose 0.1.0 → 0.2.0
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/index.mjs +9 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -112,13 +112,18 @@ expect.extend({
|
|
|
112
112
|
toHaveContainerState,
|
|
113
113
|
toHaveExitedWith
|
|
114
114
|
});
|
|
115
|
-
/** Reports a forgotten setup clearly, instead of a TypeError from
|
|
115
|
+
/** Reports a forgotten (or never loaded) setup clearly, instead of a TypeError from deeper inside. */
|
|
116
|
+
const missingSetupError = () => /* @__PURE__ */ new Error("No Compose stack: add a file that exports defineComposeGlobalSetup() to `globalSetup` in your Vitest config. If it is already there, check that Vitest loaded that config: run it from the config's directory or pass `--config`.");
|
|
116
117
|
const stackTarget = () => {
|
|
117
118
|
const target = inject("vitecomposeTarget");
|
|
118
|
-
if (!target) throw
|
|
119
|
+
if (!target) throw missingSetupError();
|
|
119
120
|
return target;
|
|
120
121
|
};
|
|
121
|
-
const stateStore = () =>
|
|
122
|
+
const stateStore = () => {
|
|
123
|
+
const stateDir = inject("vitecomposeStateDir");
|
|
124
|
+
if (!stateDir) throw missingSetupError();
|
|
125
|
+
return createStackStateStore(stateDir);
|
|
126
|
+
};
|
|
122
127
|
const test = test$1.extend("environmentGuard", { auto: true }, async () => {
|
|
123
128
|
const state = await stateStore().read();
|
|
124
129
|
if (state?.unusable) throw new Error(`The Compose stack is marked unusable: ${state.unusable}`);
|
|
@@ -134,7 +139,7 @@ const test = test$1.extend("environmentGuard", { auto: true }, async () => {
|
|
|
134
139
|
onCleanup(() => scope.dispose());
|
|
135
140
|
return scope;
|
|
136
141
|
}).extend("evidence", ({ fileCompose }) => createEvidence(fileCompose)).extend("markStackUnusable", () => (reason) => stateStore().markUnusable(reason));
|
|
137
|
-
test.afterEach(async ({ task, evidence }) => {
|
|
142
|
+
if (inject("vitecomposeStateDir") && inject("vitecomposeTarget")) test.afterEach(async ({ task, evidence }) => {
|
|
138
143
|
if (task.result?.state === "fail") {
|
|
139
144
|
await stateStore().markFailed().catch(() => {});
|
|
140
145
|
const output = await evidence.capture();
|