atomico/test-hooks
Build test to custom hooks created with Atomico with an isolated instance and predictable
The "atomico/test-hooks" submodule is a direct part of Atomico's core and will allow you to run the customHook in a controlled way without the need for webcomponents.
createHooks
function that creates an isolated context that is shared globally with Atomico hooks when executing the load method
Instance
Where:
optionalRender: Callback that allows restarting the hook's life cycle, this callback will be executed every time a hook like useState or useReducer requests the scope update, Atomico uses it to render the webcomponent again.
opcionalHost: allows to share an object for the hook useHost, Atomico uses it to share the instance of the webcomponent.
Return of the instance
Where:
load: Function that allows to load the hooks to the temporary global context of Atomico.
clearEffect: Function that activates the collector of useLayoutEffect, when executing clear Effect a callback will be returned that allows ending the collector for useEffect, closing the cycle of secondary effects.
If clear Effect receives true as parameter, it communicates the unmounted.
Example:
./use-counter.js: customHook to test.
./use-counter.test.js: The example is based on the test environment from @web/test-runner.
Last updated