-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: reset DTL
asyncWrapper
before asserting setTimeout
calls
- Loading branch information
1 parent
a76db96
commit 139d18f
Showing
4 changed files
with
43 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,32 @@ | ||
// this is pretty helpful: | ||
// https://codesandbox.io/s/quizzical-worker-eo909 | ||
|
||
import { configure, getConfig } from '@testing-library/dom' | ||
|
||
export {render, setup} from './setup' | ||
export {addEventListener, addListeners} from './listeners' | ||
|
||
export function isJsdomEnv() { | ||
return window.navigator.userAgent.includes(' jsdom/') | ||
} | ||
|
||
/** | ||
* Reset the DTL wrappers | ||
* | ||
* Framework libraries configure the wrappers in DTL as side effect when being imported. | ||
* In the Toolbox testenvs that side effect is triggered by including the library as a setup file. | ||
*/ | ||
export function resetWrappers() { | ||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
const { asyncWrapper, eventWrapper } = {...getConfig()} | ||
|
||
configure({ | ||
asyncWrapper: (cb) => cb(), | ||
eventWrapper: (cb) => cb(), | ||
}) | ||
|
||
return () => configure({ | ||
asyncWrapper, | ||
eventWrapper, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters