Skip to content

Commit

Permalink
fix: allow all combinations of describe, it and test to skip
Browse files Browse the repository at this point in the history
…modifier (#746)
  • Loading branch information
wellwelwel committed Sep 7, 2024
1 parent 228177f commit c53f3e3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/modules/helpers/modifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ export const todo = (message: string, _cb?: () => unknown) =>
`${indentation.hasDescribe ? ' ' : ''}${format(`● ${message}`).cyan().bold()}`
);

export const skip = (message: string, _cb?: () => unknown) =>
export function skip(message: string, _cb: () => unknown): void;
export function skip(_cb: () => unknown): void;
export function skip(
messageOrCb: string | (() => unknown),
_cb?: () => unknown
) {
const message =
(typeof messageOrCb === 'string' && messageOrCb) || 'Skipping';

Write.log(
`${indentation.hasDescribe ? ' ' : ''}${format(`◯ ${message}`).info().bold()}`
);
}
4 changes: 4 additions & 0 deletions test/__fixtures__/e2e/final-results/skip-it/skip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ it.skip('Some skip', () => {
it.skip('Multiple skips in the same file should not be counted', () => {
exit(1);
});

it.skip(() => {
exit(1);
});
4 changes: 3 additions & 1 deletion test/e2e/final-results.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ describe('Final Results', async () => {

assert.match(results.stdout, /PASS › 1/, 'Needs to pass 1');
assert.match(results.stdout, /FAIL › 0/, 'Needs to fail 0');
assert.match(results.stdout, /SKIP › 2/, 'Needs to skip 2');
assert.match(results.stdout, /SKIP › 3/, 'Needs to skip 3');
assert.match(results.stdout, /◯ Some skip/, 'User Messsage');
assert.match(results.stdout, /◯ Skipping/, 'No Messsage');
});

await it('Skip (describe)', async () => {
Expand Down

0 comments on commit c53f3e3

Please sign in to comment.