codeceptjs
Advanced tools
Comparing version 0.4.12 to 0.4.13
@@ -0,1 +1,30 @@ | ||
## 0.4.13 | ||
* Added **retries** option `Feature` and `Scenario` to rerun fragile tests: | ||
```js | ||
Feature('Complex JS Stuff', {retries: 3}) | ||
Scenario('Not that complex', {retries: 1}, (I) => { | ||
// test goes here | ||
}); | ||
``` | ||
* Added **timeout** option `Feature` and `Scenario` to specify timeout. | ||
```js | ||
Feature('Complex JS Stuff', {retries: 3}) | ||
Scenario('Not that complex', {retries: 1}, (I) => { | ||
// test goes here | ||
}); | ||
``` | ||
* [WebDriverIO] Added `uniqueScreenshotNames` option to set unique screenshot names for failed tests. By @APshenkin. See [#299](https://github.com/Codeception/CodeceptJS/pull/299) | ||
* [WebDriverIO] `clearField` method improved to accept name/label locators and throw errors. | ||
* [Nightmare][SeleniumWebdriver][Protractor] `clearField` method added. | ||
* [Nightmare] Fixed `waitForElement`, and `waitForVisible` methods. | ||
* [Nightmare] Fixed `resizeWindow` by @norisk-it | ||
* Added italian [translation](http://codecept.io/translation/#italian). | ||
## 0.4.12 | ||
@@ -2,0 +31,0 @@ |
@@ -11,2 +11,3 @@ var events = require('events'); | ||
after: 'test.after', | ||
passed: 'test.passed', | ||
failed: 'test.failed', | ||
@@ -13,0 +14,0 @@ }, |
@@ -449,3 +449,3 @@ 'use strict'; | ||
* Wrapper for asynchronous [evaluate](https://github.com/segmentio/nightmare#evaluatefn-arg1-arg2). | ||
* Unlike NightmareJS implementation calling `done` will return its first argument. | ||
* Unlike NightmareJS implementation calling `done` will return its first argument. | ||
*/ | ||
@@ -462,5 +462,5 @@ executeAsyncScript(fn) { | ||
if (width === 'maximize') { | ||
return this.browser.manage().window().maximize(); | ||
throw new Error(`Nightmare doesn't support resizeWindow to maximum!`); | ||
} | ||
return this.browser.manage().window().setSize(width, height); | ||
return this.browser.viewport(width, height); | ||
} | ||
@@ -498,2 +498,9 @@ | ||
/** | ||
* {{> ../webapi/clearField }} | ||
*/ | ||
clearField(field) { | ||
return this.fillField(field, ''); | ||
} | ||
/** | ||
* {{> ../webapi/appendField }} | ||
@@ -724,4 +731,4 @@ */ | ||
} | ||
let locator = guessLocator(context) || { css: context}; | ||
this.browser.optionWaitTimeout = sec*1000 || this.options.waitForTimeout; | ||
let locator = guessLocator(context) || { css: context}; | ||
@@ -740,4 +747,6 @@ return this.browser.wait(function(by, locator, text) { | ||
return this.browser.wait(function(by, locator, text) { | ||
return codeceptjs.findElement(by, locator).offsetParent !== null; | ||
return this.browser.wait(function(by, locator) { | ||
var el = codeceptjs.findElement(by, locator); | ||
if (!el) return false; | ||
return el.offsetParent !== null; | ||
}, lctype(locator), lcval(locator)); | ||
@@ -753,3 +762,3 @@ } | ||
return this.browser.wait(function(by, locator, text) { | ||
return this.browser.wait(function(by, locator) { | ||
return codeceptjs.findElement(by, locator) !== null; | ||
@@ -991,2 +1000,2 @@ }, lctype(locator), lcval(locator)); | ||
return locator[Object.keys(locator)[0]] | ||
} | ||
} |
@@ -344,2 +344,14 @@ 'use strict'; | ||
/** | ||
* {{> ../webapi/clearField }} | ||
*/ | ||
clearField(field, value) { | ||
return co(findFields(this.browser, field)).then(co.wrap(function*(els) { | ||
if (!els.length) { | ||
throw new Error(`Field ${field} not found by name|text|CSS|XPath`); | ||
} | ||
return els[0].clear(); | ||
})); | ||
} | ||
/** | ||
* {{> ../webapi/checkOption }} | ||
@@ -634,4 +646,3 @@ */ | ||
sec = sec || this.options.waitforTimeout; | ||
let el = this.browser.findElement(guessLocator(locator) || by.css(locator)); | ||
return this.browser.wait(this.webdriver.until.elementsLocated(el), sec*1000); | ||
return this.browser.wait(this.webdriver.until.elementsLocated(guessLocator(locator) || by.css(locator)), sec*1000); | ||
} | ||
@@ -638,0 +649,0 @@ |
@@ -10,2 +10,3 @@ 'use strict'; | ||
const xpathLocator = require('../utils').xpathLocator; | ||
const hashCode = require('../utils').hashCode; | ||
const fileExists = require('../utils').fileExists; | ||
@@ -198,2 +199,3 @@ const assert = require('assert'); | ||
restart: true, | ||
uniqueScreenshotNames: false, | ||
manualStart: false, | ||
@@ -212,3 +214,2 @@ timeouts: { | ||
if (!this.options.url || !this.options.browser) { | ||
@@ -230,7 +231,6 @@ throw new Error(` | ||
static _checkRequirements() | ||
{ | ||
static _checkRequirements() { | ||
try { | ||
requireg("webdriverio"); | ||
} catch(e) { | ||
} catch (e) { | ||
return ["webdriverio"]; | ||
@@ -241,6 +241,11 @@ } | ||
static _config() { | ||
return [ | ||
{ name: 'url', message: "Base url of site to be tested", default: 'http://localhost' }, | ||
{ name: 'browser', message: 'Browser in which testing will be performed', default: 'firefox' } | ||
]; | ||
return [{ | ||
name: 'url', | ||
message: "Base url of site to be tested", | ||
default: 'http://localhost' | ||
}, { | ||
name: 'browser', | ||
message: 'Browser in which testing will be performed', | ||
default: 'firefox' | ||
}]; | ||
} | ||
@@ -250,3 +255,3 @@ | ||
if (!this.options.restart && !this.options.manualStart) { | ||
this.debugSection('Session','Starting singleton browser session'); | ||
this.debugSection('Session', 'Starting singleton browser session'); | ||
return this._startBrowser(); | ||
@@ -272,3 +277,6 @@ } | ||
let dimensions = this.options.windowSize.split('x'); | ||
this.browser.windowHandleSize({ width: dimensions[0], height: dimensions[1] }); | ||
this.browser.windowHandleSize({ | ||
width: dimensions[0], | ||
height: dimensions[1] | ||
}); | ||
} | ||
@@ -298,3 +306,8 @@ return this.browser; | ||
_failed(test) { | ||
let fileName = test.title.replace(/ /g, '_') + '.failed.png'; | ||
let fileName = ''; | ||
if (this.options.uniqueScreenshotNames) { | ||
fileName = test.title.substring(0, 10).replace(/ /g, '_') + '-' + hashCode(test.title) + '-' + hashCode(test.file) + '.failed.png'; | ||
} else { | ||
fileName = test.title.replace(/ /g, '_') + '.failed.png'; | ||
} | ||
return this.saveScreenshot(fileName); | ||
@@ -308,6 +321,6 @@ } | ||
return this.browser.element(withStrictLocator(locator)).then((res) => { | ||
this.browser.element = function (l) { | ||
this.browser.element = function(l) { | ||
return this.elementIdElement(res.value.ELEMENT, l); | ||
}; | ||
this.browser.elements = function (l) { | ||
this.browser.elements = function(l) { | ||
return this.elementIdElements(res.value.ELEMENT, l); | ||
@@ -344,3 +357,3 @@ }; | ||
_locateCheckable(locator) { | ||
return findCheckable(this.browser, locator).then(function(res){ | ||
return findCheckable(this.browser, locator).then(function(res) { | ||
return res.value; | ||
@@ -358,3 +371,3 @@ }) | ||
_locateClickable(locator) { | ||
return findClickable(this.browser, locator).then(function(res){ | ||
return findClickable(this.browser, locator).then(function(res) { | ||
return res.value; | ||
@@ -372,3 +385,3 @@ }) | ||
_locateFields(locator) { | ||
return findFields(this.browser, locator).then(function(res){ | ||
return findFields(this.browser, locator).then(function(res) { | ||
return res.value; | ||
@@ -418,3 +431,3 @@ }) | ||
} | ||
return findClickable(client, locator).then(function (res) { | ||
return findClickable(client, locator).then(function(res) { | ||
if (!res.value || res.value.length === 0) { | ||
@@ -437,3 +450,3 @@ if (typeof(locator) === "object") locator = JSON.stringify(locator); | ||
} | ||
return findClickable(client, locator).then(function (res) { | ||
return findClickable(client, locator).then(function(res) { | ||
if (!res.value || res.value.length === 0) { | ||
@@ -459,3 +472,3 @@ if (typeof(locator) === "object") locator = JSON.stringify(locator); | ||
fillField(field, value) { | ||
return findFields(this.browser, field).then(function (res) { | ||
return findFields(this.browser, field).then(function(res) { | ||
if (!res.value || res.value.length === 0) { | ||
@@ -473,3 +486,3 @@ throw new Error(`Field ${field} not found by name|text|CSS|XPath`); | ||
appendField(field, value) { | ||
return findFields(this.browser, field).then(function (res) { | ||
return findFields(this.browser, field).then(function(res) { | ||
if (!res.value || res.value.length === 0) { | ||
@@ -488,3 +501,3 @@ throw new Error(`Field ${field} not found by name|text|CSS|XPath`); | ||
selectOption(select, option) { | ||
return findFields(this.browser, select).then(function (res) { | ||
return findFields(this.browser, select).then(function(res) { | ||
if (!res.value || res.value.length === 0) { | ||
@@ -507,3 +520,5 @@ throw new Error(`Selectable field ${select} not found by name|text|CSS|XPath`); | ||
}); | ||
return this.unify(commands, { extractValue: true }).then((els) => { | ||
return this.unify(commands, { | ||
extractValue: true | ||
}).then((els) => { | ||
commands = []; | ||
@@ -527,3 +542,5 @@ let clickOptionFn = (el) => { | ||
// try by value | ||
return this.unify(commands, { extractValue: true }).then((els) => { | ||
return this.unify(commands, { | ||
extractValue: true | ||
}).then((els) => { | ||
if (els.length === 0) { | ||
@@ -549,3 +566,3 @@ throw new Error(`Option ${option} in ${select} was found neither by visible text not by value`); | ||
return findFields(this.browser, locator).then((el) => { | ||
this.debug("Uploading "+file); | ||
this.debug("Uploading " + file); | ||
return this.browser.uploadFile(file).then((res) => { | ||
@@ -574,3 +591,3 @@ if (!el.value || el.value.length === 0) { | ||
let elem = res.value[0]; | ||
return client.elementIdSelected(elem.ELEMENT).then(function (isSelected) { | ||
return client.elementIdSelected(elem.ELEMENT).then(function(isSelected) { | ||
if (isSelected.value) return true; | ||
@@ -586,3 +603,3 @@ return this[clickMethod](elem.ELEMENT); | ||
grabTextFrom(locator) { | ||
return this.browser.getText(withStrictLocator(locator)).then(function (text) { | ||
return this.browser.getText(withStrictLocator(locator)).then(function(text) { | ||
return text; | ||
@@ -601,3 +618,3 @@ }); | ||
grabHTMLFrom(locator) { | ||
return this.browser.getHTML(withStrictLocator(locator)).then(function (html) { | ||
return this.browser.getHTML(withStrictLocator(locator)).then(function(html) { | ||
return html; | ||
@@ -609,5 +626,5 @@ }); | ||
* {{> ../webapi/grabValueFrom }} | ||
*/ | ||
*/ | ||
grabValueFrom(locator) { | ||
return this.browser.getValue(withStrictLocator(locator)).then(function (text) { | ||
return this.browser.getValue(withStrictLocator(locator)).then(function(text) { | ||
return text; | ||
@@ -621,3 +638,3 @@ }); | ||
grabAttributeFrom(locator, attr) { | ||
return this.browser.getAttribute(withStrictLocator(locator), attr).then(function (text) { | ||
return this.browser.getAttribute(withStrictLocator(locator), attr).then(function(text) { | ||
return text; | ||
@@ -701,4 +718,4 @@ }); | ||
seeElement(locator) { | ||
return this.browser.isVisible(withStrictLocator(locator)).then(function (res) { | ||
return truth(`elements of ${locator}`,'to be seen').assert(res); | ||
return this.browser.isVisible(withStrictLocator(locator)).then(function(res) { | ||
return truth(`elements of ${locator}`, 'to be seen').assert(res); | ||
}); | ||
@@ -711,3 +728,3 @@ } | ||
dontSeeElement(locator) { | ||
return this.browser.isVisible(withStrictLocator(locator)).then(function (res) { | ||
return this.browser.isVisible(withStrictLocator(locator)).then(function(res) { | ||
return truth(`elements of ${locator}`, 'to be seen').negate(res); | ||
@@ -721,3 +738,3 @@ }); | ||
seeElementInDOM(locator) { | ||
return this.browser.elements(withStrictLocator(locator)).then(function (res) { | ||
return this.browser.elements(withStrictLocator(locator)).then(function(res) { | ||
return empty('elements').negate(res.value); | ||
@@ -731,3 +748,3 @@ }); | ||
dontSeeElementInDOM(locator) { | ||
return this.browser.elements(withStrictLocator(locator)).then(function (res) { | ||
return this.browser.elements(withStrictLocator(locator)).then(function(res) { | ||
return empty('elements').assert(res.value); | ||
@@ -756,14 +773,14 @@ }); | ||
/** | ||
* asserts that an element appears a given number of times in the DOM | ||
* Element is located by label or name or CSS or XPath. | ||
* | ||
* ```js | ||
* I.seeNumberOfElements('#submitBtn', 1); | ||
* ``` | ||
*/ | ||
* asserts that an element appears a given number of times in the DOM | ||
* Element is located by label or name or CSS or XPath. | ||
* | ||
* ```js | ||
* I.seeNumberOfElements('#submitBtn', 1); | ||
* ``` | ||
*/ | ||
seeNumberOfElements(selector, num) { | ||
return this.browser.elements(withStrictLocator(selector)) | ||
.then(function (res) { | ||
return assert.equal(res.value.length, num); | ||
}); | ||
.then(function(res) { | ||
return assert.equal(res.value.length, num); | ||
}); | ||
} | ||
@@ -775,3 +792,3 @@ | ||
seeInCurrentUrl(url) { | ||
return this.browser.url().then(function (res) { | ||
return this.browser.url().then(function(res) { | ||
return stringIncludes('url').assert(url, res.value); | ||
@@ -785,3 +802,3 @@ }); | ||
dontSeeInCurrentUrl(url) { | ||
return this.browser.url().then(function (res) { | ||
return this.browser.url().then(function(res) { | ||
return stringIncludes('url').negate(url, res.value); | ||
@@ -801,4 +818,4 @@ }); | ||
/** | ||
* {{> ../webapi/dontSeeCurrentUrlEquals }} | ||
*/ | ||
* {{> ../webapi/dontSeeCurrentUrlEquals }} | ||
*/ | ||
dontSeeCurrentUrlEquals(url) { | ||
@@ -874,4 +891,11 @@ return this.browser.url().then((res) => { | ||
*/ | ||
clearField(locator) { | ||
return this.browser.clearElement(withStrictLocator(locator)); | ||
clearField(field) { | ||
return findFields(this.browser, field).then(function(res) { | ||
if (!res.value || res.value.length === 0) { | ||
throw new Error(`Field ${field} not found by name|text|CSS|XPath`); | ||
} | ||
let elem = res.value[0]; | ||
return this.elementIdClear(elem.ELEMENT); | ||
}); | ||
} | ||
@@ -883,3 +907,3 @@ | ||
seeCookie(name) { | ||
return this.browser.getCookie(name).then(function (res) { | ||
return this.browser.getCookie(name).then(function(res) { | ||
return truth('cookie ' + name, 'to be set').assert(res); | ||
@@ -893,3 +917,3 @@ }); | ||
dontSeeCookie(name) { | ||
return this.browser.getCookie(name).then(function (res) { | ||
return this.browser.getCookie(name).then(function(res) { | ||
return truth('cookie ' + name, 'to be set').negate(res); | ||
@@ -911,3 +935,3 @@ }); | ||
acceptPopup() { | ||
return this.browser.alertText().then(function (res) { | ||
return this.browser.alertText().then(function(res) { | ||
if (res !== null) { | ||
@@ -923,3 +947,3 @@ return this.alertAccept(); | ||
cancelPopup() { | ||
return this.browser.alertText().then(function (res) { | ||
return this.browser.alertText().then(function(res) { | ||
if (res !== null) { | ||
@@ -935,5 +959,5 @@ return this.alertDismiss(); | ||
seeInPopup(text) { | ||
return this.browser.alertText().then(function (res) { | ||
return this.browser.alertText().then(function(res) { | ||
if (res === null) { | ||
throw new Error('Popup is not opened'); | ||
throw new Error('Popup is not opened'); | ||
} | ||
@@ -957,3 +981,3 @@ stringIncludes('text in popup').assert(text, res); | ||
let modifier; | ||
if (Array.isArray(key) && ~['Control','Command','Shift','Alt'].indexOf(key[0])) { | ||
if (Array.isArray(key) && ~['Control', 'Command', 'Shift', 'Alt'].indexOf(key[0])) { | ||
modifier = key[0]; | ||
@@ -974,12 +998,15 @@ } | ||
} | ||
return this.browser.windowHandleSize({ width, height }); | ||
return this.browser.windowHandleSize({ | ||
width, | ||
height | ||
}); | ||
} | ||
/** | ||
* Drag an item to a destination element. | ||
* | ||
* ```js | ||
* I.dragAndDrop('#dragHandle', '#container'); | ||
* ``` | ||
*/ | ||
/** | ||
* Drag an item to a destination element. | ||
* | ||
* ```js | ||
* I.dragAndDrop('#dragHandle', '#container'); | ||
* ``` | ||
*/ | ||
dragAndDrop(srcElement, destElement) { | ||
@@ -1021,4 +1048,4 @@ return this.browser.dragAndDrop( | ||
context = context || 'body'; | ||
return this.browser.waitUntil(function () { | ||
return this.getText(context).then(function (source) { | ||
return this.browser.waitUntil(function() { | ||
return this.getText(context).then(function(source) { | ||
if (Array.isArray(source)) { | ||
@@ -1100,3 +1127,3 @@ return source.filter(part => part.indexOf(text) >= 0).length > 0; | ||
} | ||
return this.browser.getText(withStrictLocator(context)).then(function (source) { | ||
return this.browser.getText(withStrictLocator(context)).then(function(source) { | ||
return stringIncludes(description)[assertType](text, source); | ||
@@ -1107,3 +1134,3 @@ }); | ||
function findClickable(client, locator) { | ||
if (typeof (locator) === 'object') return client.elements(withStrictLocator(locator)); | ||
if (typeof(locator) === 'object') return client.elements(withStrictLocator(locator)); | ||
if (isCSSorXPathLocator(locator)) return client.elements(locator); | ||
@@ -1119,3 +1146,3 @@ | ||
]); | ||
return client.elements(narrowLocator).then(function (els) { | ||
return client.elements(narrowLocator).then(function(els) { | ||
if (els.value.length) { | ||
@@ -1132,3 +1159,3 @@ return els; | ||
]); | ||
return client.elements(wideLocator).then(function (els) { | ||
return client.elements(wideLocator).then(function(els) { | ||
if (els.value.length) { | ||
@@ -1143,3 +1170,3 @@ return els; | ||
function findFields(client, locator) { | ||
if (typeof (locator) === 'object') return client.elements(withStrictLocator(locator)); | ||
if (typeof(locator) === 'object') return client.elements(withStrictLocator(locator)); | ||
if (isCSSorXPathLocator(locator)) return client.elements(locator); | ||
@@ -1163,3 +1190,3 @@ | ||
function proceedSeeField(assertType, field, value) { | ||
return findFields(this.browser, field).then(function (res) { | ||
return findFields(this.browser, field).then(function(res) { | ||
if (!res.value || res.value.length === 0) { | ||
@@ -1178,3 +1205,5 @@ throw new Error(`Field ${field} not found by name|text|CSS|XPath`); | ||
}); | ||
this.unify(commands, { extractValue: true }).then((val) => { | ||
this.unify(commands, { | ||
extractValue: true | ||
}).then((val) => { | ||
return stringIncludes('fields by ' + field)[assertType](value, val); | ||
@@ -1210,3 +1239,3 @@ }); | ||
function proceedSeeCheckbox(assertType, field) { | ||
return findFields(this.browser, field).then(function (res) { | ||
return findFields(this.browser, field).then(function(res) { | ||
if (!res.value || res.value.length === 0) { | ||
@@ -1217,3 +1246,5 @@ throw new Error(`Field ${field} not found by name|text|CSS|XPath`); | ||
res.value.forEach((el) => commands.push(this.elementIdSelected(el.ELEMENT))); | ||
return this.unify(commands, { extractValue: true }).then((selected) => { | ||
return this.unify(commands, { | ||
extractValue: true | ||
}).then((selected) => { | ||
return truth(`checkable field ${field}`, 'to be checked')[assertType](selected); | ||
@@ -1225,3 +1256,3 @@ }); | ||
function findCheckable(client, locator) { | ||
if (typeof (locator) === 'object') return client.elements(withStrictLocator(locator)); | ||
if (typeof(locator) === 'object') return client.elements(withStrictLocator(locator)); | ||
if (isCSSorXPathLocator(locator)) return client.elements(locator); | ||
@@ -1234,6 +1265,6 @@ | ||
]); | ||
return client.elements(byText).then(function (els) { | ||
return client.elements(byText).then(function(els) { | ||
if (els.value.length) return els; | ||
let byName = `.//input[@type = 'checkbox' or @type = 'radio'][@name = ${literal}]`; | ||
return client.elements(byName).then(function (els) { | ||
return client.elements(byName).then(function(els) { | ||
if (els.value.length) return els; | ||
@@ -1257,3 +1288,3 @@ return client.elements(locator); // by css or xpath | ||
if (!locator) return null; | ||
if (typeof (locator) !== 'object') return locator; | ||
if (typeof(locator) !== 'object') return locator; | ||
let key = Object.keys(locator)[0]; | ||
@@ -1265,7 +1296,10 @@ let value = locator[key]; | ||
switch (key) { | ||
case 'by': | ||
case 'xpath': | ||
case 'css': return value; | ||
case 'id': return '#' + value; | ||
case 'name': return `[name="${value}"]`; | ||
case 'by': | ||
case 'xpath': | ||
case 'css': | ||
return value; | ||
case 'id': | ||
return '#' + value; | ||
case 'name': | ||
return `[name="${value}"]`; | ||
} | ||
@@ -1272,0 +1306,0 @@ } |
@@ -27,3 +27,3 @@ /** | ||
suite.timeout(0); | ||
suite.on('pre-require', function (context, file, mocha) { | ||
@@ -44,9 +44,14 @@ var common = require('mocha/lib/interfaces/common')(suites, context); | ||
context.Feature = function (title) { | ||
context.Feature = function (title, opts) { | ||
if (suites.length > 1) { | ||
suites.shift(); | ||
} | ||
if (!opts) opts = {}; | ||
var suite = Suite.create(suites[0], title); | ||
suite.timeout(0); | ||
if (opts.retries) suite.retries(opts.retries); | ||
if (opts.timeout) suite.timeout(opts.timeout); | ||
suite.file = file; | ||
suite.timeout(0); | ||
suites.unshift(suite); | ||
@@ -83,3 +88,8 @@ suite.beforeEach('codeceptjs.before', scenario.setup); | ||
*/ | ||
context.Scenario = function (title, fn) { | ||
context.Scenario = function (title, opts, fn) { | ||
if ((typeof opts == 'function') && !fn) { | ||
fn = opts; | ||
opts = {} | ||
} | ||
var suite = suites[0]; | ||
@@ -94,2 +104,6 @@ if (suite.pending) { | ||
test.timeout(0); | ||
if (opts.retries) test.retries(opts.retries); | ||
if (opts.timeout) test.timeout(opts.timeout); | ||
suite.addTest(scenario.test(test)); | ||
@@ -96,0 +110,0 @@ return test; |
@@ -7,8 +7,15 @@ 'use strict'; | ||
event.dispatcher.on(event.test.failed, function () { | ||
failed = true; | ||
let failedTests = []; | ||
event.dispatcher.on(event.test.failed, function (test) { | ||
failedTests.push(test.fullTitle()); | ||
}); | ||
// if test was successful after retries | ||
event.dispatcher.on(event.test.passed, function (test) { | ||
failedTests = failedTests.filter((failed) => test.fullTitle() !== failed); | ||
}); | ||
event.dispatcher.on(event.all.result, function () { | ||
if (failed) process.exit(1); | ||
if (failedTests.length) process.exit(1); | ||
}); |
@@ -20,2 +20,3 @@ 'use strict'; | ||
test.fn = function (done) { | ||
recorder.errHandler(function (err) { | ||
@@ -34,2 +35,3 @@ recorder.session.start('teardown'); | ||
} catch (err) { | ||
event.emit(event.test.failed, test, err); | ||
done(err); | ||
@@ -45,2 +47,3 @@ return test; | ||
if (resume.done) { | ||
recorder.add('fire test.passed', () => event.emit(event.test.passed, test)); | ||
recorder.add('finish generator with no error', () => done()); // finish him | ||
@@ -62,2 +65,3 @@ } else { | ||
if (!isGenerator(testFn)) { | ||
recorder.add('fire test.passed', () => event.emit(event.test.passed, test)); | ||
recorder.add('finish test', () => done()); | ||
@@ -64,0 +68,0 @@ recorder.catch(); |
var fs = require('fs'); | ||
var path = require('path'); | ||
module.exports.fileExists = function (filePath) { | ||
module.exports.fileExists = function(filePath) { | ||
try { | ||
@@ -13,3 +13,3 @@ fs.statSync(filePath); | ||
module.exports.isFile = function (filePath) { | ||
module.exports.isFile = function(filePath) { | ||
var filestat; | ||
@@ -25,3 +25,3 @@ try { | ||
module.exports.getParamNames = function (fn) { | ||
module.exports.getParamNames = function(fn) { | ||
if (fn.isSinonProxy) return []; | ||
@@ -32,7 +32,7 @@ var funStr = fn.toString(); | ||
module.exports.installedLocally = function () { | ||
module.exports.installedLocally = function() { | ||
return path.resolve(__dirname + '/../').indexOf(process.cwd()) === 0; | ||
} | ||
module.exports.methodsOfObject = function (obj, className) { | ||
module.exports.methodsOfObject = function(obj, className) { | ||
var methods = []; | ||
@@ -52,3 +52,3 @@ | ||
Object.getOwnPropertyNames(obj).forEach((prop) => { | ||
if (typeof (obj[prop]) !== 'function') return; | ||
if (typeof(obj[prop]) !== 'function') return; | ||
if (standard.indexOf(prop) >= 0) return; | ||
@@ -65,4 +65,4 @@ if (prop.indexOf('_') === 0) return; | ||
module.exports.template = function (template, data) { | ||
return template.replace(/{{([^{}]*)}}/g, function (a, b) { | ||
module.exports.template = function(template, data) { | ||
return template.replace(/{{([^{}]*)}}/g, function(a, b) { | ||
var r = data[b]; | ||
@@ -74,14 +74,29 @@ if (r === undefined) return ''; | ||
module.exports.ucfirst = function (str) { | ||
module.exports.ucfirst = function(str) { | ||
return str.charAt(0).toUpperCase() + str.substr(1); | ||
}; | ||
module.exports.lcfirst = function (str) { | ||
module.exports.lcfirst = function(str) { | ||
return str.charAt(0).toLowerCase() + str.substr(1); | ||
}; | ||
module.exports.hashCode = function(str) { | ||
/* Getting 32bit hashCode of string like in Java. | ||
* Used in Screenshot name to provide short screenshot names | ||
*/ | ||
var hash = 0; | ||
var char; | ||
if (str.length == 0) return hash; | ||
for (var i = 0; i < str.length; i++) { | ||
char = str.charCodeAt(i); | ||
hash = ((hash << 5) - hash) + char; | ||
hash = hash & hash; // Convert to 32bit integer | ||
} | ||
return hash; | ||
}; | ||
module.exports.xpathLocator = { | ||
literal: (string) => { | ||
if (string.indexOf("'") > -1) { | ||
string = string.split("'", -1).map(function (substr) { | ||
string = string.split("'", -1).map(function(substr) { | ||
return "'" + substr + "'"; | ||
@@ -101,4 +116,4 @@ }).join(',"\'",'); | ||
submittedData: function (dataFile) { | ||
return function (key) { | ||
submittedData: function(dataFile) { | ||
return function(key) { | ||
var data = JSON.parse(fs.readFileSync(dataFile, 'utf8')); | ||
@@ -112,5 +127,5 @@ if (key) { | ||
expectError: function () { | ||
expectError: function() { | ||
throw new Error('should not be thrown'); | ||
} | ||
} |
{ | ||
"name": "codeceptjs", | ||
"version": "0.4.12", | ||
"version": "0.4.13", | ||
"description": "Modern Era Aceptance Testing Framework for NodeJS", | ||
@@ -5,0 +5,0 @@ "homepage": "http://codecept.io", |
exports['pt-BR'] = require('./pt-BR'); | ||
exports['ru-RU'] = require('./ru-RU'); | ||
exports['ru-RU'] = require('./ru-RU'); | ||
exports['it-IT'] = require('./it-IT'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
217153
49
6077