Testing Hooks
Testing hooks perform the teardown step before the following setup step. When singling out a specific test, this allows you to play with your test environment and debug after the test runs.
Quick Start
Install testing-hooks
$ yarn add -D testing-hooks
React
Unmounts the previous mounted component before mounting the next component.
;;// react-dom must be a dependency;;;
Vue
Destroys the previous mounted component before mounting the next component.
;// vue must be a dependency;;;
Custom
Create your own testing hook using the core hook creator.
;// the function passed to the creator performs setup and may be asyncconst myTestHook =;// ...// the returned hook is always asyncawait ;//=> logs: "called with args:", ["foo", "bar"]// teardown isn't called until the next hook callawait ;//=> logs: "teardown", ["foo", "bar"]//=> logs: "called with args:", ["baz"]