Skip to content

Commit

Permalink
add(vest): omitWhen (#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Dec 17, 2021
1 parent a01e5ce commit 8ba9895
Show file tree
Hide file tree
Showing 10 changed files with 521 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/vest/src/core/ctx/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type CTXType = {
currentTest?: VestTest;
groupName?: string;
skipped?: boolean;
omitted?: boolean;
bus?: {
on: (
event: string,
Expand Down
1 change: 1 addition & 0 deletions packages/vest/src/core/isolate/IsolateTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum IsolateTypes {
SUITE,
EACH,
SKIP_WHEN,
OMIT_WHEN,
GROUP,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`omitWhen When conditional is falsy boolean conditional Should have all tests within the omit block referenced in the result 1`] = `
Object {
"field_1": Object {
"errorCount": 1,
"testCount": 2,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
}
`;

exports[`omitWhen When conditional is falsy boolean conditional Should run tests normally 1`] = `
Object {
"field_1": Object {
"errorCount": 1,
"testCount": 2,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
}
`;

exports[`omitWhen When conditional is falsy boolean conditional Should run tests normally 2`] = `
Object {
"field_1": Object {
"errorCount": 1,
"testCount": 2,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 1,
"warnCount": 0,
},
}
`;

exports[`omitWhen When conditional is falsy function conditional Should have all tests within the omit block referenced in the result 1`] = `
Object {
"field_1": Object {
"errorCount": 1,
"testCount": 2,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
}
`;

exports[`omitWhen When conditional is falsy function conditional Should run tests normally 1`] = `
Object {
"field_1": Object {
"errorCount": 1,
"testCount": 2,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
}
`;

exports[`omitWhen When conditional is falsy function conditional Should run tests normally 2`] = `
Object {
"field_1": Object {
"errorCount": 1,
"testCount": 2,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 1,
"warnCount": 0,
},
}
`;

exports[`omitWhen When conditional is truthy boolean conditional Should avoid running the omitted tests 1`] = `
Object {
"errorCount": 1,
"getErrors": [Function],
"getErrorsByGroup": [Function],
"getWarnings": [Function],
"getWarningsByGroup": [Function],
"groups": Object {},
"hasErrors": [Function],
"hasErrorsByGroup": [Function],
"hasWarnings": [Function],
"hasWarningsByGroup": [Function],
"isValid": [Function],
"suiteName": undefined,
"testCount": 2,
"tests": Object {
"field_1": Object {
"errorCount": 0,
"testCount": 1,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 1,
"testCount": 1,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
},
"warnCount": 0,
}
`;

exports[`omitWhen When conditional is truthy boolean conditional Should skip and not run omitted fields when no filter provided 1`] = `
Object {
"errorCount": 1,
"getErrors": [Function],
"getErrorsByGroup": [Function],
"getWarnings": [Function],
"getWarningsByGroup": [Function],
"groups": Object {},
"hasErrors": [Function],
"hasErrorsByGroup": [Function],
"hasWarnings": [Function],
"hasWarningsByGroup": [Function],
"isValid": [Function],
"suiteName": undefined,
"testCount": 2,
"tests": Object {
"field_1": Object {
"errorCount": 0,
"testCount": 1,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 1,
"testCount": 1,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
},
"warnCount": 0,
}
`;

exports[`omitWhen When conditional is truthy function conditional Should avoid running the omitted tests 1`] = `
Object {
"errorCount": 1,
"getErrors": [Function],
"getErrorsByGroup": [Function],
"getWarnings": [Function],
"getWarningsByGroup": [Function],
"groups": Object {},
"hasErrors": [Function],
"hasErrorsByGroup": [Function],
"hasWarnings": [Function],
"hasWarningsByGroup": [Function],
"isValid": [Function],
"suiteName": undefined,
"testCount": 2,
"tests": Object {
"field_1": Object {
"errorCount": 0,
"testCount": 1,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 1,
"testCount": 1,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
},
"warnCount": 0,
}
`;

exports[`omitWhen When conditional is truthy function conditional Should skip and not run omitted fields when no filter provided 1`] = `
Object {
"errorCount": 1,
"getErrors": [Function],
"getErrorsByGroup": [Function],
"getWarnings": [Function],
"getWarningsByGroup": [Function],
"groups": Object {},
"hasErrors": [Function],
"hasErrorsByGroup": [Function],
"hasWarnings": [Function],
"hasWarningsByGroup": [Function],
"isValid": [Function],
"suiteName": undefined,
"testCount": 2,
"tests": Object {
"field_1": Object {
"errorCount": 0,
"testCount": 1,
"warnCount": 0,
},
"field_2": Object {
"errorCount": 1,
"testCount": 1,
"warnCount": 0,
},
"field_3": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
"field_4": Object {
"errorCount": 0,
"testCount": 0,
"warnCount": 0,
},
},
"warnCount": 0,
}
`;
Loading

0 comments on commit 8ba9895

Please sign in to comment.