Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Node.js script runner #33

@ghost

Description

Introduce an API to the NPM module to make it easy to run scripts as part of suite of tests. This would let us integrate with unit test frameworks such as mocha. For example:

const {describe, before, it} = require('mocha-sugar-free');
const {runner} = require('openrunner');

describe('My Website\'s fancy click path', () => {
    let result;
    before({timeout: 60000}, async () => {
        result = await runner(async () => {
            'Openrunner-Script: v1';
            const tabs = await include('tabs');
            await include('wait');

            const tab = await tabs.create();
            await tab.navigate('http://computest.nl/', {timeout: '10s'});

            await transaction('HomePage', async t => {
                await tab.wait(async () => {
                    await wait.timeout('10s')
                        .documentComplete()
                        .selector('#layerslider_1 p.slider-text')
                        .containsText('Hoe snel zijn je systemen')
                        .isDisplayed();
                });
            });
        });
    });
    it('Should run without error', () => {
        result.assertNoError();
    });
    it('Should open the homepage within 4 seconds', () => {
        result.transaction('HomePage').assertDuration('4s');
    });
});

And then:

export OPENRUNNER_FIREFOX_BIN=/Applications/Firefox\ Nightly.app/Contents/MacOS/firefox
mocha myTest.js

The runner() function in this example should take care of creating the profile and starting the brower the first time, and then keep it active for further tests. Before node.js exits we should close firefox and cleanup the profile. We should also provide explicit functions to do this initialisation & cleanup.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions