@cloudflare/test-focus
v1.0.30
Published
Cloudflare Focus Test Util
Downloads
3,588
Maintainers
Keywords
Readme
cf-test-focus
Cloudflare Focus Test Util
Installation
$ npm install cf-test-focus
Usage
import assert from 'assert';
import {trackFocus, getCurrentFocus} from 'cf-test-focus';
describe('exampleModule', () => {
it('should do something with focus', () => {
const stub = trackFocus();
exampleModule.doSomething();
assert.ok(stub.called);
assert.equal(getCurrentFocus(), document.getElementById('#expected-focused-element'));
// This will happen automatically in between tests.
stub.restore();
});
});