[proposal] add hooks support to all dom helpers + settled and wait-until
runspired opened this issue · 1 comments
runspired commented
Some such as waitFor
do not implement the hooks.
Some which do implement hooks (such as click
) could still benefit from additional hooks wrapping of sub-helpers like focus
and mouse-down
etc.
My use-case is pretty simple, I'm doing this:
import { _registerHook } from '@ember/test-helpers';
const SHOW_SPANS = true;
if (SHOW_SPANS) {
let SPAN = 0;
['select', 'click', 'focus', 'fillIn', 'blur', 'waitFor', 'waitUntil', 'scrollTo', 'settled', 'visit'].forEach(
(helper) => {
let spanId;
_registerHook(helper, 'start', function () {
spanId = SPAN++;
performance.mark(`${helper}-${spanId}-start`);
});
_registerHook(helper, 'end', function () {
performance.mark(`${helper}-${spanId}-end`);
performance.measure(`${helper}-${spanId}`, `${helper}-${spanId}-start`, `${helper}-${spanId}-end`);
});
},
);
}
NullVoxPopuli commented
(un)registerHook is now public API!
https://github.com/emberjs/ember-test-helpers/blob/master/API.md#registerhook