Getting Started - Ashthos/skutter GitHub Wiki

TL; DR There is an example project included with the Skutter source. That'll get your first test up and running

1. NPM & Typings

In your test/bdd directory, you'll want to create a new npm project.

npm init

Follow the on-screen prompts to setup your project.json file. The 'test' command should be node run.

Next install skutter

npm install --save-dev skutter

If you are using typescript you'll also want to install typings and typescript

npm install typings typescript --save-dev

2. Project Structure

Setup your project directory structure similar to the following:

<Your Project Directory>
|- src <your project source>
|- test
    |- unit <your unit tests>
    |- bdd
        |- features 
        |- pages 
        |- steps

Features

The features directory is where your 'test scripts' will live. In the Gherkin world, these are called Features.

Pages

The pages directory is where you define the structure of the pages being tested.

Steps (Optional)

The steps directory is where you put your custom steps. This is optional as you may be able to do all your testing with the steps provided by Skutter.

3. Files

Some of the code examples use Lazy.js, you don't have to use Lazy.js, but we like it and so we do.

If you do use Lazy.js, you'll have to install it with npm npm install Lazy.js --save-dev. Additionally if you are using typescript you'll want to get the type definition files for it also with typings install Lazy.js --source dt --save --global

>

You'll find a mixture of .ts and .js files listed below. We find typescript really good for large application development and would recommend it to others doing the same. If you haven't investigated typescript yet, we have provided a vanilla es6|ecmascript 2016 version in the examples as well.

The minimal set of files required to run a Skutter test is as follows:

test/bbd/
      |-- features
      |      |- some.feature
      |-- pages
      |      |- pages.ts
      |      |- somePage.ts
      |-- protractor.config.js
      |-- skutter.config.js
      |-- tsconfig.json (when using typescript)
      |-- run.ts

features/*.feature files

The .feature files contain the Gherkin Scenarios to run. Skutter will (recursively) find all the .feature files within the feature directory.

For more information on Feature files, See the Yadda Feature Specifications. Skutter utilises Yadda in its vanilla form, and so anything you can do in Yadda, you can do in Skutter.

If no .feature files exist in this directory, Skutter will terminate and not do anything.

The name of the features directory is configurable, see the skutter.config.js on how to alter this value.

pages/pages.ts

Although not strictly absolutely necessary for Skutter to work, using a pages.ts will encourage you to layout your files in a structured manner and helps maintainability.

import * as Lazy from "lazy.js";
import { Page } from "skutter";

class Pages {

    private pages: Page[] = [];

    constructor() {
        // This is where you will add references to all your Page Definitions.
        this.pages.push(require("./somePage").default);
    }

    find(pageName: string): Page {
        let page: Page = Lazy(this.pages).find((item: Page) => {
            return item.name === pageName;
        });

        if (!page) {
            throw new Error(`Unable to find a page with the name "${pageName}".`);
        }

        return page;
    }

}

export { Pages };

pages/somePage.ts

somePage is just an example name we have given this page. You will end up using more informative names such as 'homepage' or 'login' in your tests.

The page structure will be tailored for each page you are testing, therefore a boiler plate is not provided here. Check out the page structure specification to find out more.

protractor.config.js

See the example protractor.config.js file. A full reference is provided by the protractor team which details all the options available to you.

skutter.config.js

See the example skutter.config.js file and the skutter.config.js specification.

run.ts

import { run } from "skutter";
run();

tsconfig.json

See the example tsconfig.json file.

4. Running your Tests

Execute the tests from the directory containing skutter.config.js by using the following command

node run

or if you are using typescript

tsc -p . && node run

Where 'run' matches the name of your script file with the run(); code in it.