GithubHelp home page GithubHelp logo

isabella232 / web-push-testing-service Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googlechromelabs/web-push-testing-service

0.0 0.0 0.0 213 KB

License: Apache License 2.0

JavaScript 97.52% HTML 1.84% Shell 0.63%

web-push-testing-service's Introduction

Web Push Testing Service

Travis Build Status NPM Dependency State NPM Dev Dependency State

Why

Testing web push is hard and with difference between browsers being an issue as standards are created and implemented, the best approach to ensure a library is up to date is to have integration tests. Sadly this involves knowledge and implementation of selenium web driver and implementing the logic to manage those browsers for push testing.

This library handles the selenium and browser orchestrating and makes them available via a JSON API, simplifying the whole process.

Install

npm install web-push-testing-service -g

Usage

To start the push testing service run:

web-push-testing-service start <Service Name>

This will start the service and run it in the background on port 8090. If you need to run it on a different port, you can use the port flag:

web-push-testing-service start <Service Name> -p 9000

Once you've finished using the service you just need run the stop command.

web-push-testing-service start <Service Name>

With the service started you can make POST requests in the following flow to write integration tests for your push library.

Regardless of the API you call, you'll receive JSON and the top level parameter will be either 'data' or 'error'. Data will change depending on the API called and error with have an 'id' and 'message' parameter.

  1. Start Test Suite This assigns a test suite ID to the current run that all future tests are tied to.

    http://localhost:8090/api/start-test-suite/

    Input: Nothing

    Output

    {
      data: {
        testSuiteId: <New ID>
      }
    }
    
  2. Get a Subscription This method expected a testSuiteId, a browser name and the release version and it will return a subscription.

    The gcmSenderId and vapidPublicKey parameters are options BUT Chrome requires one of them to work, otherwise you must catch the error.

    http://localhost:8090/api/get-subscription/

    Input

    {
        testSuiteId: <Test Suite ID Number>,
        browserName: <'chrome' | 'firefox'>,
        browserVersion: <'stable' | 'beta' | 'unstable' >,
        gcmSenderId: <Your GCM Sender ID>,
        vapidPublicKey: <Base64 URL Encode Vapid Public Key>
    }
    

    Output

    {
        data: {
            testId: <ID for this test instance>,
            subscription: <A Subscription Object, will have endpoint and keys>
        }
    }
    
  3. Wait for notification to arrive Once your library has sent a message you can retrieve what details the browser received.

    http://localhost:8090/api/get-notification-status/

    Input

    {
        testSuiteId: <Test Suite ID Number>
        testId: <Test ID Number>
    }
    

    Output

    {
        data: {
            messages: [
                <Payload String>,
                ...
            ]
        }
    }
    
  4. End the Test Suite This will end and close any currently open tests.

    http://localhost:8090/api/end-test-suite/

    Input

    {
      testSuiteId: <Your Test Suite ID>
    }
    

    Output

    {
      data: {
        success: true
      }
    }
    

web-push-testing-service's People

Contributors

greenkeeper[bot] avatar minishlink avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.