JSPM

  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q39475F
  • License MIT

Configurable end-to-end test runner

Package Exports

  • kasmir

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (kasmir) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Kasmir

Build Status dependencies codecov

Kasmir is configurable end-to-end test runner. It wraps NightwatchJS to make your selenium tests fully configurable. It gives you full control over the outcome of browser based tests, producing a JSON report that includes extended information about each test step. You can use the output to handle very flexible failure conditions.

✦ Easy configuration ✦ Reusable test steps ✦ Flexible failure conditions

Installation

Install Kasmir using NPM:

npm install kasmir

Usage

This is a basic example: run a Kasmir test that opens and page and closes it. To do this you only need to provide a configuration for actions which consist of tasks and pass them to the runner.

var Kasmir = require('kasmir');

// Configure some custom actions
var actions = {
  'Open test page': {
    priority: 0,
    tasks: [
      {
        name:  'Open a page',
        priority: 1,
        handler: 'openPage',
        args: ['http://www.mytestsite.com'],
      }
    ]
  },
  'Close page': {
    priority: 0,
    tasks: [
      {
        name:  'Close client',
        priority: 0,
        handler: 'closeBrowser',
        args: [],
      }
    ]
  }
}

// Initialize runner with config
var runner = new Kasmir({actions: actions});

// Run 'Open test page' and 'Close page' in sequence and log report
runner.run(['Open test page', 'Close page']).then(function() {
  console.log(runner.getTaskSummary());
});

Here's a sample report produced by the test above:

{
  'Open test page':
  [{
    id: '50cl3wpj4too203gl23xr',
    name: 'Open a page',
    state: 'success',
    startTime: 1487530322700,
    endTime: 1487530325150,
    runTime: 2449,
    error: null
  }],
  'Close page':
  [{
    ...
  }]
}

As you can see the output reports state for each task, start and end times, run time and other information.

Use that information to report failure or success on your custom conditions or even use third-party assertion libraries in your existing test stack.

FAQ

Why would I want to use it?

Kasmir tests are very robust. One goal of this project is to combat test flakiness and allow you to skip steps and continue running the test on certain conditions. Kasmir also allows you to define very flexible action patterns that are reusable and repeatable.

But Nightwatch already makes writing tests very easy?

Yes indeed, but you still need to write your tests in code and implement your own structure for complex cases. Let's say you want to continue running the test even if some steps fail. Or you might want to fail a test in case some steps take too long. With Kasmir you only have to provide a configuration file, run the test and do whatever you want with the output.

What are some example special cases where Kasmir is useful?

Well, here's some ideas:

  • Want to fail a test if rendering a page or element render too long?

  • Want to repeat pre-defined action patterns multiple times without writing repeating blocks?

  • Want run a bot user on your app and flexibly report anomalies in your live environment?

Then Kasmir might be good for you. And the list goes on...

License

MIT License

Copyright (c) 2017 Andreas Urbanski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.