@scenarist/core 0.4.15 → 0.5.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/domain/config-builder.d.ts.map +1 -1
- package/dist/domain/config-builder.js +4 -7
- package/dist/schemas/scenario-definition.d.ts +2 -2
- package/dist/schemas/scenario-definition.js +2 -2
- package/dist/types/config.d.ts +21 -11
- package/dist/types/config.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-builder.d.ts","sourceRoot":"","sources":["../../src/domain/config-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAEnB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"config-builder.d.ts","sourceRoot":"","sources":["../../src/domain/config-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAEnB,MAAM,mBAAmB,CAAC;AAU3B;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,kBAAkB,EACtD,OAAO,oBAAoB,CAAC,CAAC,CAAC,KAC7B,eAkBF,CAAC"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { ScenariosObjectSchema } from "../schemas/index.js";
|
|
2
|
-
|
|
3
|
-
* Default error behaviors - strict by default.
|
|
4
|
-
* All errors throw to ensure tests fail clearly when something goes wrong.
|
|
5
|
-
*/
|
|
2
|
+
// 'throw' by default would 500 every unmatched request, including in-process calls to the app itself
|
|
6
3
|
const DEFAULT_ERROR_BEHAVIORS = {
|
|
7
|
-
onNoMockFound: "
|
|
8
|
-
onSequenceExhausted: "
|
|
9
|
-
onMissingTestId: "
|
|
4
|
+
onNoMockFound: "ignore",
|
|
5
|
+
onSequenceExhausted: "ignore",
|
|
6
|
+
onMissingTestId: "ignore",
|
|
10
7
|
};
|
|
11
8
|
/**
|
|
12
9
|
* Build a complete config from partial user input.
|
|
@@ -107,8 +107,8 @@ export type ScenaristSequence = z.infer<typeof ScenaristSequenceSchema>;
|
|
|
107
107
|
export declare const ScenaristCaptureConfigSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
108
108
|
export type ScenaristCaptureConfig = z.infer<typeof ScenaristCaptureConfigSchema>;
|
|
109
109
|
/**
|
|
110
|
-
* URL pattern supports
|
|
111
|
-
* - String: exact match
|
|
110
|
+
* URL pattern supports two forms:
|
|
111
|
+
* - String: exact match or path-to-regexp v6 params (/users/:id, /files/:path+)
|
|
112
112
|
* - Native RegExp: pattern match (e.g., /\/users\/\d+/)
|
|
113
113
|
*/
|
|
114
114
|
export declare const ScenaristUrlPatternSchema: z.ZodUnion<readonly [z.ZodString, z.ZodInstanceOf<RegExp>]>;
|
|
@@ -71,8 +71,8 @@ export const ScenaristSequenceSchema = z.object({
|
|
|
71
71
|
});
|
|
72
72
|
export const ScenaristCaptureConfigSchema = z.record(z.string(), z.string());
|
|
73
73
|
/**
|
|
74
|
-
* URL pattern supports
|
|
75
|
-
* - String: exact match
|
|
74
|
+
* URL pattern supports two forms:
|
|
75
|
+
* - String: exact match or path-to-regexp v6 params (/users/:id, /files/:path+)
|
|
76
76
|
* - Native RegExp: pattern match (e.g., /\/users\/\d+/)
|
|
77
77
|
*/
|
|
78
78
|
export const ScenaristUrlPatternSchema = z.union([
|
package/dist/types/config.d.ts
CHANGED
|
@@ -2,21 +2,26 @@ import type { ScenaristScenarios } from "./scenario.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* How errors should be handled when they occur.
|
|
4
4
|
*
|
|
5
|
-
* - `throw`:
|
|
6
|
-
* - `warn`: Log at warn level,
|
|
7
|
-
* - `ignore`:
|
|
5
|
+
* - `throw`: Respond 500 with the ScenaristError code and message
|
|
6
|
+
* - `warn`: Log at warn level via the configured logger, then let strictMode decide
|
|
7
|
+
* - `ignore`: Let strictMode decide silently (default)
|
|
8
8
|
*/
|
|
9
9
|
export type ErrorBehavior = "throw" | "warn" | "ignore";
|
|
10
10
|
/**
|
|
11
11
|
* Configuration for how different error types should be handled.
|
|
12
|
-
* Default is '
|
|
12
|
+
* Default is 'ignore' for all, so strictMode alone decides unmatched requests.
|
|
13
13
|
*/
|
|
14
14
|
export type ErrorBehaviors = {
|
|
15
|
-
/** How to handle when no mock matches a request. Default: '
|
|
15
|
+
/** How to handle when no mock matches a request. Default: 'ignore' */
|
|
16
16
|
readonly onNoMockFound: ErrorBehavior;
|
|
17
|
-
/** How to handle when a sequence is exhausted. Default: '
|
|
17
|
+
/** How to handle when a sequence is exhausted. Default: 'ignore' */
|
|
18
18
|
readonly onSequenceExhausted: ErrorBehavior;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* How to handle when no test ID can be resolved for a request. Default: 'ignore'
|
|
21
|
+
*
|
|
22
|
+
* Adapters fall back to `defaultTestId` when the header is absent, so this
|
|
23
|
+
* only applies when `defaultTestId` is set to `''`.
|
|
24
|
+
*/
|
|
20
25
|
readonly onMissingTestId: ErrorBehavior;
|
|
21
26
|
};
|
|
22
27
|
/**
|
|
@@ -26,8 +31,13 @@ export type ErrorBehaviors = {
|
|
|
26
31
|
export type ScenaristConfig = {
|
|
27
32
|
/**
|
|
28
33
|
* Whether mocking is enabled.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
34
|
+
* When false, adapters' `createScenarist()` returns `undefined`: no scenario
|
|
35
|
+
* endpoints are mounted and no requests are intercepted.
|
|
36
|
+
* For dynamic enabling, evaluate before creating config. In Express,
|
|
37
|
+
* `process.env.NODE_ENV === 'test'` works when the test runner sets it. In
|
|
38
|
+
* Next.js use `true`: Next.js inlines `NODE_ENV` as 'development' or
|
|
39
|
+
* 'production', so a 'test' check is never true, and production builds are
|
|
40
|
+
* excluded by the `production` export condition.
|
|
31
41
|
*/
|
|
32
42
|
readonly enabled: boolean;
|
|
33
43
|
/**
|
|
@@ -59,7 +69,7 @@ export type ScenaristConfig = {
|
|
|
59
69
|
readonly defaultTestId: string;
|
|
60
70
|
/**
|
|
61
71
|
* How different error types should be handled.
|
|
62
|
-
* Default is '
|
|
72
|
+
* Default is 'ignore' for all (strictMode decides unmatched requests).
|
|
63
73
|
*/
|
|
64
74
|
readonly errorBehaviors: ErrorBehaviors;
|
|
65
75
|
};
|
|
@@ -94,7 +104,7 @@ export type ScenaristConfigInput<T extends ScenaristScenarios = ScenaristScenari
|
|
|
94
104
|
readonly scenarios: T;
|
|
95
105
|
readonly defaultTestId?: string;
|
|
96
106
|
/**
|
|
97
|
-
* Optional error behavior overrides. Missing values use '
|
|
107
|
+
* Optional error behavior overrides. Missing values use 'ignore' as default.
|
|
98
108
|
*/
|
|
99
109
|
readonly errorBehaviors?: Partial<ErrorBehaviors>;
|
|
100
110
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,oEAAoE;IACpE,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC;IAC5C;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC;CACzC,CA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