satisfy

0.1.0 • Public • Published

satisfy.js

Satisfy is a minimalistic browser testing utility designed to work with any test framework, oriented only around CSS selectors, designed for speed both of test writing and test execution.

For development, run the tests in a headless WebKit browser. For deployments, run them in the cloud in all browsers with Selenium.

It's the expect.js of browser / acceptance testing.

How to use

satisfy('localhost')
  .click('li#home a')
  .expect('h1:contains(Home)')
  .click('li#test a')
  .expect('h1:contains(Test)')

Mocha

With the mocha test framework:

var satisfy = require('satisfy');
 
describe('learnboost homepage', function () {
  it('should work', function (done) {
    satisfy('http://learnboost.com')
      .expect('a:contains(For Schools)')
      .run(done)
  });
});

Then run it:

$ mocha -t 0 test.js

Features

  • Fast. The default adaptor is the fastest available.
  • Test-framework agnostic, but best with the wonderful mocha
  • No APIs to learn. Only based on CSS selectors.
  • Extended CSS selectors thanks to Sizzle like :contains for text matching.
  • Adaptor based
    • webkit-server (headless webkit)
    • soda (selenium)

Examples

Following a link

satisfy('localhost')
  .click('li#home a')
  .expect('h1:contains(Home)')

Filling a form

satisfy('localhost')
  .click('#add-classroom')
  .expect('#add-classroom-dialog', 7000) // override expect timeout
  .fill('input[name=classroom-name]', 'My classroom')
  .fill({ 'textarea': 'Something' })
  .click('#add-classroom input[type=submit]')
  .expect('body:not(#add-classroom)')

Options

You can pass options to specific satisfy instances:

satisfy('http://host.com:port/path', { options })
  • adaptor String
    • webkit-server or soda (selenium/sauce labs).
    • Defaults to webkit-server
  • timeout Number
    • Timeout after which we considered the test failed if a CSS selector expectation is not met.
    • Strings like '2m' or '10s' are supported.
    • Defaults to 10000
  • webkit-server Object
    • Hash of options for the webkit-server adaptor.
    • Options
    • poll Number|String
      • How often we poll the DOM for a certain selector match.
      • Only applies for the webkit-server mode.
      • Strings like '2m' or '10s' are supported.
      • Defaults to 50
  • soda Object
    • Hash of options for the soda adaptor.
    • Options
      • sauce Boolean
        • Whether to use sauce labs.
        • Defaults to false
      • host String
        • Selenium host.
        • Defaults to localhost
      • port Number
        • Selenium port
        • Defaults to 4444
      • browser String
        • Browser to test on.
        • Defaults to firefox.
  • autorun Boolean
    • If run is not called, it calls it automatically for you
    • Defaults to true

Global options

If you wanted to pass options to all instances, you can implement that in userland easily by defining your own helper method:

function mytest (url) {
  return satisfy(url, { default options });
}

Readme

Keywords

none

Package Sidebar

Install

npm i satisfy

Weekly Downloads

1

Version

0.1.0

License

none

Last publish

Collaborators

  • rauchg