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: 12 days 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 (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T17:04:37.000Z (almost 2 years ago)
- Last Synced: 2024-10-27T09:28:11.150Z (17 days 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 [![Build Status](https://api.travis-ci.org/asakusuma/swae.svg?branch=master)](https://travis-ci.org/asakusuma/swae) [![npm version](https://badge.fury.io/js/swae.svg)](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;
});
});
});
```