Skip to content

Commit a127f86

Browse files
committed
Use io-ts for parsing user configuration
This was honestly long over due.
1 parent 0c54097 commit a127f86

File tree

3 files changed

+113
-566
lines changed

3 files changed

+113
-566
lines changed

lib/preprocessor-configuration.test.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import assert from "node:assert/strict";
22

3+
import stripIndent from "strip-indent";
4+
35
import {
46
COMPILED_REPORTER_ENTRYPOINT,
5-
FilterSpecsMixedMode,
67
IBaseUserConfiguration,
78
ICypressRuntimeConfiguration,
9+
IFilterSpecsMixedMode,
810
IPreprocessorConfiguration,
911
IUserConfiguration,
1012
resolve,
@@ -620,11 +622,11 @@ describe("resolve()", () => {
620622
describe("filterSpecsMixedMode", () => {
621623
const getValueFn = (
622624
configuration: IPreprocessorConfiguration,
623-
): FilterSpecsMixedMode => configuration.filterSpecsMixedMode;
625+
): IFilterSpecsMixedMode => configuration.filterSpecsMixedMode;
624626

625627
const setValueFn = (
626628
configuration: IBaseUserConfiguration,
627-
value: FilterSpecsMixedMode,
629+
value: IFilterSpecsMixedMode,
628630
) => (configuration.filterSpecsMixedMode = value);
629631

630632
it("default", () =>
@@ -712,7 +714,7 @@ describe("resolve()", () => {
712714
expectedValue: "empty-set",
713715
}));
714716

715-
it("should fail when configured using non-recognized mode", () =>
717+
it("should fail when configured using non-recognized mode", async () =>
716718
assert.rejects(
717719
() =>
718720
resolve(
@@ -725,8 +727,17 @@ describe("resolve()", () => {
725727
() => ({ filterSpecsMixedMode: "foobar" }),
726728
),
727729
{
728-
message:
729-
'Unrecognize filterSpecsMixedMode: \'foobar\' (valid options are "hide", "show" and "empty-set")',
730+
message: stripIndent(
731+
`
732+
optional property "filterSpecsMixedMode"
733+
├─ member 0
734+
│ └─ cannot decode "foobar", should be "hide"
735+
├─ member 1
736+
│ └─ cannot decode "foobar", should be "show"
737+
└─ member 2
738+
└─ cannot decode "foobar", should be "empty-set"
739+
`.replaceAll(/^\s*\n|\n\s*$/gm, ""),
740+
),
730741
},
731742
));
732743
});

0 commit comments

Comments
 (0)