Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Make waitFor interceptable and don't override interval/timeout #23

Merged
merged 2 commits into from
Dec 12, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,11 @@ import * as domTestingLibrary from '@testing-library/dom';
import _userEvent from '@testing-library/user-event';
import dedent from 'ts-dedent';

const debugOptions = {
timeout: 2147483647, // max valid timeout duration
interval: 2147483647,
};

const testingLibrary = instrument(
{ ...domTestingLibrary },
{
intercept: (method, path) => path[0] === 'fireEvent' || method.startsWith('findBy'),
getArgs: (call, state) => {
if (!state.isDebugging) return call.args;
if (call.method.startsWith('findBy')) {
const [value, queryOptions, waitForOptions] = call.args;
return [value, queryOptions, { ...waitForOptions, ...debugOptions }];
}
if (call.method.startsWith('waitFor')) {
const [callback, options] = call.args;
return [callback, { ...options, ...debugOptions }];
}
return call.args;
},
intercept: (method, path) =>
path[0] === 'fireEvent' || method.startsWith('findBy') || method.startsWith('waitFor'),
}
);

Expand Down