swae
TypeScript icon, indicating that this package has built-in type declarations

0.0.27 • Public • Published

swae Build Status npm version

ServiceWorkerAssessmentEngine

A 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, which is node client for interacting with Headless Chrome via the Chrome DevTools Protocol. Built with TypeScript.

Example

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;
    });
  });
});

Readme

Keywords

none

Package Sidebar

Install

npm i swae

Weekly Downloads

2

Version

0.0.27

License

MIT

Unpacked Size

46.9 kB

Total Files

19

Last publish

Collaborators

  • krisselden
  • asakusuma
  • stefanpenner