stencil-test-helpers
v0.0.2
Published
Stencil test helpers
Downloads
5
Readme
Stencil Test Helpers
This code is a port from the great ember-test-helpers to be used in Stencil projects.
Getting Started
npm install stencil-test-helpers
So helpers know how to do their thing, the TestWindow
class provided by this package needs to be used. It behaves as the normal TestWindow
, but with a couple of extra magic bits that let the helpers use their magic.
You need to add a removeTestWindow
call in the aferEach
hook.
The basic scaffold is:
import { TestWindow, removeTestWindow } from 'stencil-test-helpers';
describe('something', () => {
afterEach(() => {
removeTestWindow();
});
});
Helpers
All the helpers accept a target both as a string (CSS selector) or an Element. All helpers will wait until the next tick before and after doing its work.
The available helpers are:
blur(target)
click(target)
doubleClick(target)
fillIn(target, value: string)
focus(target)
getElement(target): Element | null
tap(target, options)
triggerEvent(target, event, options)
triggerKeyEvent(target, keyEventType, keyOrKeyCode, modifiers)