Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/asakusuma/swae
A service worker testing framework
https://github.com/asakusuma/swae
Last synced: about 1 month ago
JSON representation
A service worker testing framework
- Host: GitHub
- URL: https://github.com/asakusuma/swae
- Owner: asakusuma
- License: mit
- Created: 2018-05-22T04:25:11.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T17:04:37.000Z (about 2 years ago)
- Last Synced: 2025-01-03T04:46:44.273Z (about 2 months ago)
- Language: TypeScript
- Size: 392 KB
- Stars: 55
- Watchers: 5
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swae [](https://travis-ci.org/asakusuma/swae) [](https://www.npmjs.com/package/swae)
**S**ervice**W**orker**A**ssessment**E**ngineA service worker testing framework in the early stages of development. There are lots of bugs, and every release is potentially a breaking change. Effectively a big wrapper around [chrome-debugging-client](https://github.com/devtrace/chrome-debugging-client), which is node client for interacting with [Headless Chrome](https://developers.google.com/web/updates/2017/04/headless-chrome) via the [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/). Built with [TypeScript](https://www.typescriptlang.org/).
## Example
```TypeScript
import { expect } from 'chai';
import { TestSession } from 'swae';
import { createServer } from './my-test-server';const session = new TestSession(createServer());
before(session.ready.bind(session));
after(session.close.bind(session));describe('Service Worker', () => {
it('should respond to requests', async () => {
await session.run(async (testEnv) => {
const client = await testEnv.createTab();await client.navigate();
await client.evaluate(function() {
return navigator.serviceWorker.register('/sw.js');
});await client.swState.waitForActivated();
const { body, networkResult } = await client.navigate();
expect(networkResult.response.fromServiceWorker).to.be.true;
});
});
});
```