webrun
webrun's goal is to provide a lightweight CLI tool that runs your integration tests effectively in a local environment. While there's many alternatives out there, its main focus is on testing the integration of a library you've built in order to ensure that you ship a working module.
- Spins up a local webserver, hosting an integration sample of your module.
- Uses the
webdriver protocol and a strict API to provide interop between your local, remotely controlled browser and the test file.
Getting started
npm install @matvp91/webrun
Create the following structure in your project:
- /integration-tests // We'll use this folder name to write the test files.
- /public // Will be served by a local webserver.
- index.html
- basic.test.js // Your test file.
module.exports = {
name: 'A basic integration test',
run: async ( browser) => {
await browser.runFunction(() => {
bootstrapMyModule();
});
const result = await browser.runFunction(() => window.I_GOT_CALLED);
expect(result).toBe(true);
},
};
<html>
<body>
<script>
function bootstrapMyModule() {
window.I_GOT_CALLED = true;
}
</script>
</body>
</html>
{
"scripts": {
"test:integration": "webrun integration-tests"
}
}