Think of it like Jest for cross-browser testing - it even uses the same expect syntax.
Why do I want this?
Karma, Webpack and Jasmine are all great. They're all also quite powerful and each highly configurable. When creating and maintaining small modules, duplication of these configurations and dependencies is cumbersome.
Karmatic is a zero-configuration wrapper around these tools with intelligent defaults, configuration auto-detection, and optimizations most configurations don't include.
Most importantly, Karmatic provides a (headless) browser test harness in a single dependency.
npm i -D webpack karmatic
... then add a
test script to your
... now you can run your tests using
npm t. Here's a minimal example repo.
Test File Patterns
By default, Karmatic will find tests in any files ending in
You can change this to any minimatch pattern (note the quotes to avoid shell expansion):
Filename to be used to save Chrome preferences between test runs. Useful for debugging tests. It is recommended to also add this filename to
karmatic --chromeDataDir .chrome
Usage$ karmatic <command> [options]Available Commandsrun Run tests once and exitwatch Run tests on any changedebug Open a headful Puppeteer instance for debugging your testsFor more info, run any command with the `--help` flag$ karmatic run --help$ karmatic watch --helpOptions-v, --version Displays current version--files Minimatch pattern for test files--headless Run using Chrome Headless (default true)--coverage Report code coverage of tests (default true)-h, --help Displays this message
To disable any option that defaults to
false to the option:
--headless false or
debug option overrides the default value of the
--coverage option to be
false. This option will also open up the local Puppeteer installation of Chrome, not your globally installed one. If you'd like to debug your tests using your your own instance of Chrome (or any other browser), copy the URL from the puppeteer window into your favorite browser.
Q: Is there an FAQ?**
Projects Using Karmatic
Karmatic is pretty new! Here are some projects that have switched to it you may use as a reference: