Skip to content

Commit

Permalink
react-experiment: fix render error msgs in tests (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinRoy committed Jan 31, 2024
1 parent 345928b commit 0a6a337
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/react-experiment/__tests__/run.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,24 +236,21 @@ describe('run', () => {
);
expect(screen.getByRole('heading')).toHaveTextContent('Type A');

// I cannot find a way to test rendering errors without React displaying
// them in the console.
console.log(
"Don't worry about the error below, it's unfortunate but expected",
);
const spy = vi.spyOn(console, 'error');
spy.mockImplementation(() => {});

expect(() => {
rerender(
<Run elements={elements} timeline={[{ type: 'A', a: 'world' }]} />,
);
}).toThrow('Timeline cannot be changed once set');

spy.mockRestore();
});

it('throws an error if the run should resume after an non existing task', async () => {
// I cannot find a way to test rendering errors without React displaying
// them in the console.
console.log(
"Don't worry about the error below, it's unfortunate but expected",
);
const spy = vi.spyOn(console, 'error');
spy.mockImplementation(() => {});
expect(() => {
render(
<Run
Expand All @@ -275,6 +272,7 @@ describe('run', () => {
/>,
);
}).toThrow('Could not find task to resume after');
spy.mockRestore();
});

it('throws an error if the same task is completed multiple times', async () => {
Expand Down

0 comments on commit 0a6a337

Please sign in to comment.