Tilted sphere with longitudinal stripes Modern Web Guides Docs Blog Toggle darkmode

Writing Tests: Helper Libraries

Not all helper libraries ship es modules which are usable in the browser. On this page we collect libraries which are available as es modules. If need to use a library with another module format, you can follow the instructions at the bottom of the es modules page

General libraries

@open-wc/testing is a general-purpose library, including assertions via chai, HTML test fixtures, a11y tests, and test helpers. It is an opinionated implementation that brings together multiple libraries.

Assertions

chai is a popular assertion library. It doesn't ship an es module, but you can use @esm-bundle/chai for that.

import { expect } from '@esm-bundle/chai';

expect(undefined).to.not.be.a('function');

Chai plugins

Testing helpers

@open-wc/testing-helpers contains useful helper functions for setting up snippets of HTML test fixtures, and testing async behavior

Mocking

For stubbing and mocking, we recommend sinon. Check the mocking page for more.