Nefarious Plastic Mannequins
Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

ya-done

1.2.1 • Public • Published

ya-done

Ready to use yadda BBD test framework with selenium-webdriver and chai for chromedriver and phantomjs

travis build passing

Version 0.9.* adds BrowserStack automating multiple browsers in parallel will be added in a further version

Version 1.1.* adds yadda dictionary support for tables

Version 1.2.* adds the ability to add arguments via index.js file to run both chrome and firefox headless

 
npm  i  ya-done --save
 

The aim of this package is to build a simple configuration for 'yadda' to enable QA test engineers to productively build test projects for web projects using JavaScript.

ya-done configures 'yadda' with chai with 'selenium-webdriver'. 'yadda' has been created with two context properties. 'selenium-webdriver' can be accessed via the property 'driver' additionally a property of 'ctx', type object, has been added to allow the passing of data between steps.

ya-done allows testing with chromedriver, geckodriver and phantomjs.

Technologies Used

Default steps

ya-done has preconfigured "set-up" and "tear down" steps.

  • a web browser (sets window size, solves lots of webdriver common problems)

  • end the test (calls quit on webdriver, only to be used on last scenario in the last feature file)

These steps are added to the yadda library by default and are used in the example project and seen below.

ya-done exposes "yaddaCore" which requires a step library to run

Configuration (standard)

The web-browser to be used for testing can be defined by either a string or configuration object.

When using a configuration object the window size can also be set, more configuration option may become available as issues are found or raised.

 
import { yaddaCore } from  'ya-done';
import  steps  from  './steps';
 
/* configure */
yaddaCore(steps, {
useBrowser:  true,
capabilities: {
browserName:  'chrome',
args: [
 
'--disable-background-networking',
 
'--disable-background-timer-throttling',
 
'--disable-client-side-phishing-detection',
 
'--disable-default-apps',
 
'--disable-hang-monitor',
 
'--disable-popup-blocking',
 
'--disable-prompt-on-repost',
 
'--disable-sync',
 
'--metrics-recording-only',
 
'--no-first-run',
 
'--safebrowsing-disable-auto-update',
 
'--enable-automation',
 
'--password-store=basic',
 
'--use-mock-keychain',
 
'--user-data',
 
'--hide-scrollbars',
 
'--mute-audio',
 
'--disable-setuid-sandbox',
 
"--disable-dev-shm-usage",
 
"--disable-gpu",
 
"--no-default-browser-check",
 
"--disable-extensions",
 
"--disable-translate",
 
"--disable-logging",
 
"--headless",
 
"--no-sandbox",
 
"--remote-debugging-port=0",
 
"--window-size=1440,900",
 
"--disable-web-security",
 
"--disable-renderer-backgrounding",
 
"--disable-background-timer-throttling"
 
]
 
}
 
});
 
  
 
/* Or for Firefox */
yaddaCore(steps, {
useBrowser:  true,
capabilities: {
browserName:  'firefox',
args: [
 
'--disable-background-networking',
 
'--disable-background-timer-throttling',
 
'--disable-client-side-phishing-detection',
 
'--disable-default-apps',
 
'--disable-hang-monitor',
 
'--disable-popup-blocking',
 
'--disable-prompt-on-repost',
 
'--disable-sync',
 
'--metrics-recording-only',
 
'--no-first-run',
 
'--safebrowsing-disable-auto-update',
 
'--enable-automation',
 
'--password-store=basic',
 
'--use-mock-keychain',
 
'--user-data',
 
'--hide-scrollbars',
 
'--mute-audio',
 
'--disable-setuid-sandbox',
 
"--disable-dev-shm-usage",
 
"--disable-gpu",
 
"--no-default-browser-check",
 
"--disable-extensions",
 
"--disable-translate",
 
"--disable-logging",
 
"--headless",
 
"--no-sandbox",
 
"--remote-debugging-port=0",
 
"--window-size=1440,900",
 
"--disable-web-security",
 
"--disable-renderer-backgrounding",
 
"--disable-background-timer-throttling"
 
]
 
}
 
});
 

Configuration (browserstack)

For BrowserStack add a configuration object as the second parameter in yaddaCore.

Documentation for setting up the configuration object.

Please note to run multiple tests (scenarios) the driver needs to be quit at the end of each scenario

 
import { yaddaCore } from  'ya-done';
import  steps  from  './steps';
 
/* configure */
yaddaCore(steps,{
capabilities: {
browserName:  'Chrome', // other browsers available
browser_version:  '62.0',
os:  'Windows',
os_version:  '8',
resolution:  '1024x768',
'browserstack.user':  ${your_id},
'browserstack.key':  ${your_pass},
},
 
}
 
);
 

Adding a dictionary

Dictionaries have been abstracted for simple use in ya-done. Dictionaries allow the use of tables and variables within steps.

Pass in an array of objects to the yaddaLibrary. Objects need to have a name property and a type property. The name will equal the variable name to be used in the table and step. The type must be one of the 3 dictionaryTypes in ya-done. (String types are supported in yadda by default and require no dictionary configuration, a string variable will require step configuration though).

  • dictionaryTypes.TYPE_JSON

  • dictionaryTypes.TYPE_INTEGER

  • dictionaryTypes.TYPE_FLOAT

Example Dictionary

 
import { dictionaryTypes } from  'ya-done';
 
// define a dictionary
const  dictionary = [
{
name:  'dataObject',
type:  dictionaryTypes.TYPE_JSON,
 
},{
 
name:  'smallNumber'
type: dictionaryTypes.TYPE_INTEGER,
 
},{
 
name:  'bigNumber'
type: dictionaryTypes.TYPE_FLOAT,
 
}
 
];

Example use

Using the example project provided.

sample project structure

│ index.js
└───steps

│ │ index.js

└───features

│ hello.feature

index.js (project level)

 
import { yaddaCore } from  'ya-done';
yaddaCore(steps, {
useBrowser:  true,
capabilities: {
browserName:  'chrome',
args: [
 
'--disable-background-networking',
 
'--disable-background-timer-throttling',
 
'--disable-client-side-phishing-detection',
 
'--disable-default-apps',
 
'--disable-hang-monitor',
 
'--disable-popup-blocking',
 
'--disable-prompt-on-repost',
 
'--disable-sync',
 
'--metrics-recording-only',
 
'--no-first-run',
 
'--safebrowsing-disable-auto-update',
 
'--enable-automation',
 
'--password-store=basic',
 
'--use-mock-keychain',
 
'--user-data',
 
'--hide-scrollbars',
 
'--mute-audio',
 
'--disable-setuid-sandbox',
 
"--disable-dev-shm-usage",
 
"--disable-gpu",
 
"--no-default-browser-check",
 
"--disable-extensions",
 
"--disable-translate",
 
"--disable-logging",
 
"--headless",
 
"--no-sandbox",
 
"--remote-debugging-port=0",
 
"--window-size=1440,900",
 
"--disable-web-security",
 
"--disable-renderer-backgrounding",
 
"--disable-background-timer-throttling"
 
]
 
}
 
});
 

hello.feature

 
Feature: ya-done example
 
  
Scenario: webdriver is simple with ya-done
Given a web browser
When the browser navigates to github
Then the headers should not be hello world
And end the test will quit the driver
 
Where:
--------------------------------------------------------------------
| dataObject | smallNumber | bigNumber |
| [{"stuff": true, "otherStuff": true}] | 1 | 11.00 |
--------------------------------------------------------------------

index.js

import { yaddaCore, yaddaLibrary, dictionaryTypes } from  'ya-done';
 
// define a dictionary
 
const  dictionary = [
{
 
name:  'dataObject',
type:  dictionaryTypes.TYPE_JSON,
 
},{
 
name:  'smallNumber'
type: dictionaryTypes.TYPE_INTEGER,
 
},{
 
name:  'bigNumber'
type: dictionaryTypes.TYPE_FLOAT,
 
}
 
];
 
yaddaCore(() =>
 
yaddaLibrary(dictionary)
 
.when('the browser navigates to github', function  loadGithub(next) {
 
this.driver.get('http://github.com');
 
next();
 
})
 
.then('the headers should not be hello world', next  => {
 
expect('#site-container h1.heading').dom.to.not.contain.text('hello world');
 
  
 
next();
 
})
 
);
 

install and run the project

npm  i
 
npm  test

Keywords

none

install

npm i ya-done

Downloadsweekly downloads

135

version

1.2.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability