nodepup
v1.2.1
Published
run tests with puppeteer and the nodejs test runner
Downloads
732
Readme
nodepup
Run component tests with puppeteer as if they were in node
requirements
- nodejs > 22
- a browser that supports es2022
Why does this exist?
- JSDOM doesn't fully implement the native Web APIs
- Cypress is too slow
- Playwright is too hard to integrate into existing projects (and also not as fast)
So this is kind of a "run your unit tests in a browser" enabling library.
Features
- FAST EXECUTION 🚀 - should theoretically be only slightly slower than jest etc
- FAST SETUP 🏎️ - no aggregation or unnecessary setup/teardown
Configuration
// nodepup.config.js
/**
* @type import("nodepup/server").NodepupConfig
*/
export default {
esbuild: {}, // changeable esbuild options
coverage: {}, // changeable monocart-coverage-reporter options
glob: "**/*.test.{ts,tsx}", // an extended glob to find your test files
bodyContent: "", // html that replaces the document body before every test run
};
Usage
Nodepup installs a simple binary so npx nodepup
would be enough.
It is possible to configure the run with some environment variables as follows:
process.env.BROWSER
(required)
Specify the browser to run the tests in. Must be supported by puppeteer and
must be provided in the form <browser>@<tag>
. So for example chrome@canary
process.env.BROWSER_ARGS (optional)
You can pass args to the launched browser instance via this environment variable.
Useful e.g. for running in CI environments with --no-sandbox
for chrome.
process.env.DEBUG
(optional)
By passing any value as DEBUG
the given browser will start with the devtools open.
You can then set breakpoints and simply reload the spec. The suite will finish when
you close the browser.
process.env.IGNORE_WARNINGS (optional)
Passing any truthy value here means that nodepup will exit with status 0 even if tests exist that log errors while still passing.
Filtering tests (optional)
You can provide a filter string that will be used as a regex to only run tests
matching that string. E.g. nodepup foobar
will run only specs with "foobar"
in their description.