2.14.3 • Published 2 years ago

@ukhomeoffice/asl-functional-testing v2.14.3

Weekly downloads
392
License
MIT
Repository
github
Last release
2 years ago

ASL Functional Testing

Provides some simple wrappers for writing functional tests in wdio

Usage

Create a config file in your project with the following content:

module.exports = {
  // path to your test files
  specs: './tests/functional/specs/**/*.js',
  // the usernames and passwords for any users used in your tests
  users: {
    'username': 'password'
  },
  // the urls for your different environments
  urls: {
    local: 'http://localhost:8080',
    dev: '<dev url>',
    preprod: '<preprod url>'
  }
};

Add the following as a script to the scripts section in your package.json:

asl-test ./path/to/you/config

Run that script.

Test helpers

There is currently a single helper function defined for logging in - withUser - this will start a clean browser session, and then log you in with the user defined.

const assert = require('assert');

describe('Example tests', () => {

  it('can log in', () => {
    browser.withUser('username');
    const title = browser.getTitle();
    assert.equal(title, 'My page title');
  });

});

Screenshots

You can optionally have the test runner create a set of screenshots of particular pages of your app after completing a successful test run. To do this, add a screenshots section to your config as follows:

module.exports = {
  ...
  screenshots: {
    user: '<user to log in as>',
    urls: [
      '/',
      '/details',
      '/places'
    ],
    path: '/path/to/save/screenshots/to'
  }
};

When running tests locally then screenshots will be saved into the path specified. Alternatively they can be saved into AWS S3 by providing additional config for S3. This will save the screenshots for each test run in a subdirectory in S3 corresponding to the test run.

module.exports = {
  ...
  screenshots: {
    user: '<user to log in as>',
    urls: [
      ...
    ],
    s3: {
      region: 'eu-west-2',
      bucket: 'asl-screenshots',
      prefix: 'my-service',
      accessKey: process.env.AWS_ACCESS_KEY,
      secret: process.env.AWS_SECRET
    }
  }
};
2.14.3

2 years ago

2.14.2

3 years ago

2.14.1

3 years ago

2.14.0

3 years ago

2.13.2

3 years ago

2.13.1

3 years ago

2.13.0

3 years ago

2.12.4

3 years ago

2.12.3

3 years ago

2.12.2

3 years ago

2.12.1

3 years ago

2.12.0

3 years ago

2.11.1

3 years ago

2.11.0

3 years ago

2.10.0

3 years ago

2.9.1

3 years ago

2.9.0

3 years ago

2.8.1

3 years ago

2.8.0

3 years ago

2.7.0

3 years ago

2.6.2

4 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.0

4 years ago

2.4.2

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.15

4 years ago

1.2.14

4 years ago

1.2.13

4 years ago

1.2.12

4 years ago

1.2.11

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

5 years ago

1.2.1

5 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago