Skip to content

Commit

Permalink
fix(vest): prevent performing eager check on prev test run
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Mar 1, 2022
1 parent 579b241 commit 24bc521
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/vest/src/core/test/lib/registerPrevRunTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import { useTestAtCursor, useSetTestAtCursor } from 'useTestAtCursor';

// eslint-disable-next-line max-statements
export default function registerPrevRunTest(testObject: VestTest): VestTest {
const prevRunTest = useTestAtCursor(testObject);

if (shouldSkipBasedOnMode(testObject)) {
testCursor.moveForward();
testObject.skip();
return testObject;
}

const prevRunTest = useTestAtCursor(testObject);

if (isOmitted()) {
prevRunTest.omit();
testCursor.moveForward();
Expand Down
25 changes: 25 additions & 0 deletions packages/vest/src/hooks/mode/__tests__/eager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,29 @@ describe('mode: eager', () => {
expect(suite.get().errorCount).toBe(6);
});
});

describe('When test used to fail and it now passes', () => {
let run = 0;
beforeEach(() => {
suite = create(() => {
dummyTest.passing('field_1');

if (run === 0) {
dummyTest.failing('field_1', 'second-of-field_1');
} else {
dummyTest.passing('field_1');
}
run++;
});
});

it('Should treat test as passing', () => {
suite();
expect(suite.get().hasErrors()).toBe(true);
expect(suite.get().getErrors('field_1')).toEqual(['second-of-field_1']);
suite();
expect(suite.get().hasErrors()).toBe(false);
expect(suite.get().getErrors('field_1')).toEqual([]);
});
});
});

1 comment on commit 24bc521

@vercel
Copy link

@vercel vercel bot commented on 24bc521 Mar 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest-next – ./website

vest-next.vercel.app
vest-website.vercel.app
vest-next-git-latest-ealush.vercel.app
vest-next-ealush.vercel.app

Please sign in to comment.