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

Node.js script runner #33

Open
ghost opened this issue May 11, 2018 · 0 comments
Open

Node.js script runner #33

ghost opened this issue May 11, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented May 11, 2018

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.

@ghost ghost added the enhancement label May 11, 2018
@ghost ghost modified the milestone: Beta Launch Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

0 participants