Giter Club home page Giter Club logo

ukhomeoffice.so-acceptance's Introduction

SO Acceptance

SO Acceptance is a NodeJS acceptance testing framework build on top of CodeceptJS and is designed to be used in SO applications

Installation

$ npm install so-acceptance --save-dev

Application configuration

Simple usage

Setup

For quickstart usage you can simply npm install the library and add the following script to your package.json.

package.json

"scripts": {
  "test:acceptance": "so-acceptance --steps"
}

Running this for the first time will create a local configuration file in your project directory.

The root of your acceptance tests will need to be located in a folder called acceptance_tests in the root of your app, features are located in a subdirectory named features.

<service name>
  |__acceptance_tests/
       |__features/
          |__your tests go here.

Running

$ npm run test:acceptance

Session Mocking

Setup

SO Acceptance comes with session mocking so you are able to test steps independently of one another. This assumes you are using hof-bootstrap and redis for session storage.

API

The I actor in CodeceptJS has been extended with the following session manipulation methods:

  • getSession(route_name): returns the session data for the given route_name (defined in bootstrap config).
  • setSessionData(route_name, {data}): sets the key: value pairs in data to session for given route_name.
  • setSessionSteps(route_name, [steps]): sets the visited steps to session for given route name.

As these API methods all return promises, they should be used within generator functions to ensure code execution is paused while the session is manipulated:

Scenario('I set session steps', function *(I) {
  yield I.setSessionSteps('journey-name', ['/', '/step-1']);
  I.amOnPage('/step-2');
});

Extensions to the actor (I)

The following methods have been added to I:

  • completeToStep(step[, values]): Completes a form as far as a given step, using values specified or default values inferred from the field names.
  • submitForm(): clicks the submit button input[type="submit"]
  • visitPage(page, [journey], [prereqs]): visits '/', then page, prepending journey if present, and setting prereq steps. Page and Prereqs are expected to be PageObjects with a url property.
  • seeErrors(errors): accepts either an array of keys or a single key, and checks for validation errors related to the element.
  • seeElements(elements): accepts either an array of selectors or a single selector and checks all elements are present on the page.
  • refreshPage(): refreshes the page - async, should be called within a generator.
  • seeEach(texts): accepts an array of text and checks all texts are present on the page`.
  • dontSeeEach(texts): accepts an array of text and checks all texts are not present on the page`.

Customisation

You can add any customisation options in your local configuration file. The default options are extended with overrides defined here.

codecept.conf.js

var path = require('path');

module.exports = require('so-acceptance').extend({
  name: 'name of your app',
  tests: './apps/**/acceptance/features/**/*.js',
  include: {
    customPage: path.resolve(__dirname, './pages/custom.js')
  }
})

ukhomeoffice.so-acceptance's People

Contributors

joefitter avatar lennym avatar easternbloc avatar joechapman avatar sulthan-ahmed avatar gxxm 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.