test: Silence the DOM dump in test output
This silences the DOM dump logged into test output by testing-library while keeping all the relevant information about the test failure in the output.
This commit is contained in:
parent
e2397b90d4
commit
4e24dc35b6
1 changed files with 11 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { configure } from '@testing-library/react';
|
||||
import nodeFetch, { Request, Response } from 'node-fetch';
|
||||
|
||||
import { server } from './mocks/server';
|
||||
|
|
@ -16,6 +17,16 @@ const MockResizeObserver = vi.fn(() => ({
|
|||
}));
|
||||
vi.stubGlobal('ResizeObserver', MockResizeObserver);
|
||||
|
||||
// Remove DOM dump from the testing-library output
|
||||
configure({
|
||||
getElementError: (message: string) => {
|
||||
const error = new Error(message);
|
||||
error.name = 'TestingLibraryElementError';
|
||||
error.stack = '';
|
||||
return error;
|
||||
},
|
||||
});
|
||||
|
||||
beforeAll(() => server.listen({ onUnhandledRequest: 'error' }));
|
||||
afterAll(() => server.close());
|
||||
afterEach(() => server.resetHandlers());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue