Skip to content

Commit

Permalink
Add missing specs for skipping with only
Browse files Browse the repository at this point in the history
  • Loading branch information
michalwarda committed Apr 26, 2022
1 parent 839964c commit 774358d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
1 change: 0 additions & 1 deletion docs/GlobalAPI.md
Expand Up @@ -898,4 +898,3 @@ test.failing('it is equal', () => {
expect(10).toBe(10); // this test will fail
});
```

33 changes: 28 additions & 5 deletions e2e/__tests__/__snapshots__/testFailing.test.ts.snap
Expand Up @@ -37,16 +37,39 @@ exports[`works with only mode 1`] = `
"FAIL __tests__/worksWithOnlyMode.test.js
block with only, should pass
✓ failing failes = passes, should pass
○ skipped failing test
○ skipped passing test
○ skipped failing test but skipped
○ skipped passing test but skipped
block with only, should fail
✕ failing passes = fails, should fail
○ skipped failing test
○ skipped passing test
○ skipped failing test but skipped
○ skipped passing test but skipped
block with only in other it, should skip
✕ failing test
○ skipped failing passes = fails, should fail but skipped
○ skipped passing test but skipped
● block with only, should fail › failing passes = fails, should fail
Failing test passed even though it was supposed to fail. Remove \`.failing\` to remove error."
Failing test passed even though it was supposed to fail. Remove \`.failing\` to remove error.
● block with only in other it, should skip › failing test
expect(received).toBe(expected) // Object.is equality
Expected: 101
Received: 10
41 | // eslint-disable-next-line jest/no-focused-tests
42 | it.only('failing test', () => {
> 43 | expect(10).toBe(101);
| ^
44 | });
45 |
46 | it('passing test but skipped', () => {
at Object.toBe (__tests__/worksWithOnlyMode.test.js:43:16)"
`;
exports[`works with skip mode 1`] = `
Expand Down
23 changes: 19 additions & 4 deletions e2e/test-failing/__tests__/worksWithOnlyMode.test.js
Expand Up @@ -10,11 +10,11 @@ describe('block with only, should pass', () => {
expect(10).toBe(101);
});

it('failing test', () => {
it('failing test but skipped', () => {
expect(10).toBe(101);
});

it('passing test', () => {
it('passing test but skipped', () => {
expect(10).toBe(10);
});
});
Expand All @@ -24,11 +24,26 @@ describe('block with only, should fail', () => {
expect(10).toBe(10);
});

it('failing test', () => {
it('failing test but skipped', () => {
expect(10).toBe(101);
});

it('passing test', () => {
it('passing test but skipped', () => {
expect(10).toBe(10);
});
});

describe('block with only in other it, should skip', () => {
it.failing('failing passes = fails, should fail but skipped', () => {
expect(10).toBe(10);
});

// eslint-disable-next-line jest/no-focused-tests
it.only('failing test', () => {
expect(10).toBe(101);
});

it('passing test but skipped', () => {
expect(10).toBe(10);
});
});
10 changes: 9 additions & 1 deletion packages/jest-circus/src/eventHandler.ts
Expand Up @@ -122,7 +122,15 @@ const eventHandler: Circus.EventHandler = (event, state) => {
}
case 'add_test': {
const {currentDescribeBlock, currentlyRunningTest, hasStarted} = state;
const {asyncError, fn, mode, testName: name, timeout, concurrent, failing} = event;
const {
asyncError,
fn,
mode,
testName: name,
timeout,
concurrent,
failing,
} = event;

if (currentlyRunningTest) {
currentlyRunningTest.errors.push(
Expand Down

0 comments on commit 774358d

Please sign in to comment.