This repository was archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
This repository was archived by the owner on Oct 3, 2024. It is now read-only.
Node.js script runner #33
Copy link
Copy link
Open
Labels
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.jsThe 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.