diff --git a/.circleci/build.sh b/.circleci/build.sh new file mode 100755 index 000000000..b53ab223e --- /dev/null +++ b/.circleci/build.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -e + +cd test + +docker-compose build \ + --build-arg NODE_VERSION=$NODE_VERSION \ + test-unit \ + test-helpers \ + test-acceptance.webdriverio \ + test-acceptance.nightmare \ + json_server + +docker-compose pull \ + php \ + selenium.chrome diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..7909ae619 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,35 @@ +version: 2 + +defaults: &defaults + machine: + image: circleci/classic:201710-02 + docker_layer_caching: true + steps: + - checkout + - run: .circleci/build.sh + - run: .circleci/test.sh + +jobs: + node 6.9.5: + <<: *defaults + environment: + - NODE_VERSION: 6.9.5 + + node 8.9.1: + <<: *defaults + environment: + - NODE_VERSION: 8.9.1 + + node 9.2.0: + <<: *defaults + environment: + - NODE_VERSION: 9.2.0 + +workflows: + version: 2 + + test_all: + jobs: + - node 6.9.5 + - node 8.9.1 + - node 9.2.0 diff --git a/.circleci/test.sh b/.circleci/test.sh new file mode 100755 index 000000000..6ad78178f --- /dev/null +++ b/.circleci/test.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -e + +cd test + +docker-compose run --rm test-unit +docker-compose run --rm test-helpers test/helper +docker-compose run --rm test-helpers test/rest +docker-compose run --rm test-acceptance.webdriverio +docker-compose run --rm test-acceptance.nightmare diff --git a/lib/utils.js b/lib/utils.js index ab9f36118..890e65cf0 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -173,9 +173,6 @@ module.exports.test = { } return data; }; - }, - - expectError: function () { - throw new Error('should not be thrown'); } + }; diff --git a/test/helper/AppiumWeb_test.js b/test/helper/AppiumWeb_test.js index 82d524815..d3239e1e4 100644 --- a/test/helper/AppiumWeb_test.js +++ b/test/helper/AppiumWeb_test.js @@ -13,7 +13,6 @@ let path = require('path'); let fs = require('fs'); let fileExists = require('../../lib/utils').fileExists; let AssertionFailedError = require('../../lib/assert/error'); -let expectError = require('../../lib/utils').test.expectError; let webApiTests = require('./webapi'); let within = require('../../lib/within') require('co-mocha')(require('mocha')); diff --git a/test/helper/Appium_test.js b/test/helper/Appium_test.js index f8493017c..b69ebd3c1 100644 --- a/test/helper/Appium_test.js +++ b/test/helper/Appium_test.js @@ -8,7 +8,6 @@ let path = require('path'); let fs = require('fs'); let fileExists = require('../../lib/utils').fileExists; let AssertionFailedError = require('../../lib/assert/error'); -let expectError = require('../../lib/utils').test.expectError; require('co-mocha')(require('mocha')); let apk_path = 'https://github.com/Codeception/CodeceptJS/raw/Appium/test/data/mobile/selendroid-test-app-0.17.0.apk' @@ -102,13 +101,11 @@ describe('Appium', function () { it('should assert when app is/is not installed', () => { return app.seeAppIsInstalled("io.super.app") - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('expected app io.super.app to be installed'); }) .then(() => app.seeAppIsNotInstalled("io.selendroid.testapp")) - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('expected app io.selendroid.testapp not to be installed'); @@ -124,7 +121,6 @@ describe('Appium', function () { it('should assert for wrong screen', () => { return app.seeCurrentActivityIs(".SuperScreen") - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('expected current activity to be .SuperScreen'); @@ -137,7 +133,6 @@ describe('Appium', function () { it('should return correct status about lock @second', () => { return app.seeDeviceIsUnlocked() .then(() => app.seeDeviceIsLocked()) - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('expected device to be locked'); @@ -150,7 +145,6 @@ describe('Appium', function () { it('should return correct status about lock', () => { return app.seeOrientationIs('PORTRAIT') .then(() => app.seeOrientationIs('LANDSCAPE')) - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('expected orientation to be LANDSCAPE'); @@ -217,7 +211,6 @@ describe('Appium', function () { it('should hide device Keyboard @quick', () => { return app.click('~startUserRegistrationCD') .then(() => app.click('//android.widget.CheckBox')) - .then(expectError) .catch((e) => { e.message.should.include('Clickable element android.widget.CheckBox was not found by text|CSS|XPath'); }) @@ -226,7 +219,7 @@ describe('Appium', function () { }); it('should assert if no keyboard', () => { - return app.hideDeviceKeyboard('pressKey', 'Done').then(expectError) + return app.hideDeviceKeyboard('pressKey', 'Done') .catch((e) => { e.message.should.include( 'An unknown server-side error occurred while processing the command. Original error: Soft keyboard not present, cannot hide keyboard'); @@ -248,7 +241,6 @@ describe('Appium', function () { it('should react on notification opening', () => { return app.seeElement('//android.widget.FrameLayout[@resource-id="com.android.systemui:id/quick_settings_container"]') - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('expected elements of //android.widget.FrameLayout[@resource-id="com.android.systemui:id/quick_settings_container"] to be seen'); @@ -425,7 +417,6 @@ describe('Appium', function () { describe('#waitForText', () => { it('should return error if not present', () => { return app.waitForText('Nothing here', 1, '~buttonTestCD') - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.be.equal('expected element ~buttonTestCD to include "Nothing here"'); diff --git a/test/helper/Nightmare_test.js b/test/helper/Nightmare_test.js index ea6e3c6f9..f716b2c26 100644 --- a/test/helper/Nightmare_test.js +++ b/test/helper/Nightmare_test.js @@ -11,7 +11,6 @@ let fs = require('fs'); let fileExists = require('../../lib/utils').fileExists; let AssertionFailedError = require('../../lib/assert/error'); let formContents = require('../../lib/utils').test.submittedData(path.join(__dirname, '/../data/app/db')); -let expectError = require('../../lib/utils').test.expectError; require('co-mocha')(require('mocha')); let webApiTests = require('./webapi'); @@ -88,7 +87,6 @@ describe('Nightmare', function () { it('should fail when text is not on site', () => { return I.amOnPage('/') .then(() => I.see('Something incredible!')) - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('web application'); @@ -99,7 +97,6 @@ describe('Nightmare', function () { it('should fail when clickable element not found', () => { return I.amOnPage('/') .then(() => I.click('Welcome')) - .then(expectError) .catch((e) => { e.should.be.instanceOf(Error); e.message.should.include('Clickable'); @@ -109,7 +106,6 @@ describe('Nightmare', function () { it('should fail when text on site', () => { return I.amOnPage('/') .then(() => I.dontSee('Welcome')) - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('web application'); @@ -119,7 +115,6 @@ describe('Nightmare', function () { it('should fail when test is not in context', () => { return I.amOnPage('/') .then(() => I.see('debug', {css: 'a'})) - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.toString().should.not.include('web page'); diff --git a/test/helper/Protractor_test.js b/test/helper/Protractor_test.js index f6184d8c0..7f03ca8ba 100644 --- a/test/helper/Protractor_test.js +++ b/test/helper/Protractor_test.js @@ -16,7 +16,6 @@ var expect = chai.expect; let AssertionFailedError = require('../../lib/assert/error'); let formContents = require('../../lib/utils').test.submittedData(path.join(__dirname, '/../data/app/db')); let fileExists = require('../../lib/utils').fileExists; -let expectError = require('../../lib/utils').test.expectErrors; require('co-mocha')(require('mocha')); @@ -281,7 +280,6 @@ describe('Protractor', function() { it('should throw error if field is not empty', function*() { yield I.amOnPage('/#/options'); return I.seeInField('#ssh', 'something') - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.be.equal('expected field by #ssh to include "something"'); @@ -475,7 +473,6 @@ describe('Protractor', function() { it('should return error if not present', function*() { if (I.isProtractor5) return; return I.waitForText('Nothing here', 0, '#hello') - .then(expectError) .thenCatch((e) => { e.message.should.include('Wait timed out'); }); @@ -484,7 +481,6 @@ describe('Protractor', function() { it('should return error if waiting is too small', function*() { if (I.isProtractor5) return; return I.waitForText('Boom!', 0.5) - .then(expectError) .thenCatch((e) => { e.message.should.include('Wait timed out'); }); diff --git a/test/helper/SeleniumWebdriver_test.js b/test/helper/SeleniumWebdriver_test.js index 217c765d2..4d81f741b 100644 --- a/test/helper/SeleniumWebdriver_test.js +++ b/test/helper/SeleniumWebdriver_test.js @@ -11,7 +11,6 @@ let fs = require('fs'); let fileExists = require('../../lib/utils').fileExists; let AssertionFailedError = require('../../lib/assert/error'); let formContents = require('../../lib/utils').test.submittedData(path.join(__dirname, '/../data/app/db')); -let expectError = require('../../lib/utils').test.expectError; require('co-mocha')(require('mocha')); let webApiTests = require('./webapi'); @@ -86,7 +85,6 @@ describe('SeleniumWebdriver', function () { it('should fail when text is not on site', () => { return I.amOnPage('/') .then(() => I.see('Something incredible!')) - .then(expectError) .thenCatch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('web application'); @@ -96,7 +94,6 @@ describe('SeleniumWebdriver', function () { it('should fail when text on site', () => { return I.amOnPage('/') .then(() => I.dontSee('Welcome')) - .then(expectError) .thenCatch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('web application'); @@ -106,7 +103,6 @@ describe('SeleniumWebdriver', function () { it('should fail when test is not in context', () => { return I.amOnPage('/') .then(() => I.see('debug', {css: 'a'})) - .then(expectError) .thenCatch((e) => { e.should.be.instanceOf(AssertionFailedError); e.toString().should.not.include('web page'); diff --git a/test/helper/WebDriverIO_test.js b/test/helper/WebDriverIO_test.js index 4fbfb767f..50e01bba1 100644 --- a/test/helper/WebDriverIO_test.js +++ b/test/helper/WebDriverIO_test.js @@ -11,7 +11,6 @@ let fs = require('fs'); let fileExists = require('../../lib/utils').fileExists; let AssertionFailedError = require('../../lib/assert/error'); let formContents = require('../../lib/utils').test.submittedData(path.join(__dirname, '/../data/app/db')); -let expectError = require('../../lib/utils').test.expectError; let webApiTests = require('./webapi'); let within = require('../../lib/within') @@ -72,13 +71,11 @@ describe('WebDriverIO', function () { it('should fail when text is not on site', () => { return wd.amOnPage('/') .then(() => wd.see('Something incredible!')) - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('web page'); }) .then(() => wd.dontSee('Welcome')) - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('web page'); @@ -90,7 +87,6 @@ describe('WebDriverIO', function () { it('should throw error if field is not empty', () => { return wd.amOnPage('/form/empty') .then(() => wd.seeInField('#empty_input', 'Ayayay')) - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.be.equal('expected fields by #empty_input to include "Ayayay"'); @@ -177,7 +173,6 @@ describe('WebDriverIO', function () { .then(() => wd.seeAttributesOnElements('//form', { method: "post"})) .then(() => wd.seeAttributesOnElements('//form', { method: "post", action: `${site_url}/` })) .then(() => wd.seeAttributesOnElements('//form', { method: "get"})) - .then(expectError) .catch((e) => { assert.equal(e.message, `Not all elements (//form) have attributes {"method":"get"}`); }); @@ -188,7 +183,6 @@ describe('WebDriverIO', function () { .then(() => wd.seeAttributesOnElements('a', { 'qa-id': "test", 'qa-link': 'test'})) .then(() => wd.seeAttributesOnElements('//div', { 'qa-id': 'test'})) .then(() => wd.seeAttributesOnElements('a', { 'qa-id': "test", href: '/info'})) - .then(expectError) .catch((e) => { e.message.should.include(`Not all elements (a) have attributes {"qa-id":"test","href":"/info"}`); }); @@ -200,7 +194,6 @@ describe('WebDriverIO', function () { return wd.amOnPage('/') .then(() => wd.seeTitleEquals('TestEd Beta 2.0')) .then(() => wd.seeTitleEquals('TestEd Beta 2.')) - .then(expectError) .catch((e) => { assert.equal(e.message, `expected web page title to be TestEd Beta 2., but found TestEd Beta 2.0`); }); @@ -212,7 +205,6 @@ describe('WebDriverIO', function () { return wd.amOnPage('/') .then(() => wd.seeTextEquals('Welcome to test app!', 'h1')) .then(() => wd.seeTextEquals('Welcome to test app', 'h1')) - .then(expectError) .catch((e) => { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include("expected element h1 'Welcome to test app' to equal 'Welcome to test app!'"); @@ -234,7 +226,6 @@ describe('WebDriverIO', function () { .then(() => wd.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"})) .then(() => wd.seeCssPropertiesOnElements('h3', { 'font-weight': "bold", display: 'block'})) .then(() => wd.seeCssPropertiesOnElements('h3', { 'font-weight': "non-bold"})) - .then(expectError) .catch((e) => { e.message.should.include(`Not all elements (h3) have CSS property {"font-weight":"non-bold"}`); }); @@ -245,7 +236,6 @@ describe('WebDriverIO', function () { .then(() => wd.seeCssPropertiesOnElements('a', { color: "rgba(0, 0, 238, 1)", cursor: 'auto'})) .then(() => wd.seeCssPropertiesOnElements('//div', { display: 'block'})) .then(() => wd.seeCssPropertiesOnElements('a', { 'margin-top': "0em", cursor: 'auto'})) - .then(expectError) .catch((e) => { e.message.should.include(`Not all elements (a) have CSS property {"margin-top":"0em","cursor":"auto"}`); }); @@ -278,7 +268,6 @@ describe('WebDriverIO', function () { return wd.amOnPage('/info') .then(() => wd.waitInUrl('/info')) .then(() => wd.waitInUrl('/info2', 0.1)) - .then(expectError) .catch((e) => { assert.equal(e.message, `expected url to include /info2, but found ${site_url}/info`); }); @@ -288,7 +277,6 @@ describe('WebDriverIO', function () { .then(() => wd.waitUrlEquals('/info')) .then(() => wd.waitUrlEquals(`${site_url}/info`)) .then(() => wd.waitUrlEquals('/info2', 0.1)) - .then(expectError) .catch((e) => { assert.equal(e.message, `expected url to be ${site_url}/info2, but found ${site_url}/info`); }); @@ -314,7 +302,6 @@ describe('WebDriverIO', function () { return wd.amOnPage('/info') .then(() => wd.waitForValue('//input[@name= "rus"]', "Верно")) .then(() => wd.waitForValue('//input[@name= "rus"]', "Верно3", 0.1)) - .then(expectError) .catch((e) => { assert.equal(e.message, `element (//input[@name= "rus"]) is not in DOM or there is no element(//input[@name= "rus"]) with value "Верно3" after 0.1 sec`); }); @@ -326,7 +313,6 @@ describe('WebDriverIO', function () { return wd.amOnPage('/info') .then(() => wd.waitNumberOfVisibleElements('//div[@id = "grab-multiple"]//a', 3)) .then(() => wd.waitNumberOfVisibleElements('//div[@id = "grab-multiple"]//a', 2, 0.1)) - .then(expectError) .catch((e) => { assert.equal(e.message, `The number of elements //div[@id = "grab-multiple"]//a is not 2 after 0.1 sec`); }); @@ -344,7 +330,6 @@ describe('WebDriverIO', function () { return wd.amOnPage('/') .then(() => wd.click('More info')) .then(() => wd.switchToNextTab(2)) - .then(expectError) .catch((e) => { assert.equal(e.message, "There is no ability to switch to next tab with offset 2"); }); @@ -375,7 +360,6 @@ describe('WebDriverIO', function () { .then(() => wd.waitInUrl('about:blank')) .then(() => wd.switchToPreviousTab(2)) .then(() => wd.waitInUrl('/info')) - .then(expectError) .catch((e) => { assert.equal(e.message, "There is no ability to switch to previous tab with offset 2"); }); @@ -409,7 +393,6 @@ describe('WebDriverIO', function () { it('should return error if not present', () => { return wd.amOnPage('/dynamic') .then(() => wd.waitForText('Nothing here', 1, '#text')) - .then(expectError) .catch((e) => { e.message.should.be.equal('element (#text) is not in DOM or there is no element(#text) with text "Nothing here" after 1 sec'); }); @@ -418,7 +401,6 @@ describe('WebDriverIO', function () { it('should return error if waiting is too small', () => { return wd.amOnPage('/dynamic') .then(() => wd.waitForText('Dynamic text', 0.1)) - .then(expectError) .catch((e) => { e.message.should.be.equal('element (body) is not in DOM or there is no element(body) with text "Dynamic text" after 0.1 sec'); }); @@ -442,7 +424,6 @@ describe('WebDriverIO', function () { it('should return error if iframe selector is invalid', () => { return wd.amOnPage('/iframe') .then(() => wd.switchTo('#invalidIframeSelector')) - .then(expectError) .catch((e) => { e.should.be.instanceOf(Error); e.message.should.be.equal('Element #invalidIframeSelector was not found by text|CSS|XPath'); @@ -452,7 +433,6 @@ describe('WebDriverIO', function () { it('should return error if iframe selector is not iframe', () => { return wd.amOnPage('/iframe') .then(() => wd.switchTo('h1')) - .then(expectError) .catch((e) => { e.should.be.instanceOf(Error); e.seleniumStack.type.should.be.equal('NoSuchFrame'); diff --git a/test/rest/ApiDataFactory_test.js b/test/rest/ApiDataFactory_test.js index 5c3edce3e..81ca88cda 100644 --- a/test/rest/ApiDataFactory_test.js +++ b/test/rest/ApiDataFactory_test.js @@ -9,7 +9,6 @@ let path = require('path'); let fs = require('fs'); let fileExists = require('../../lib/utils').fileExists; let AssertionFailedError = require('../../lib/assert/error'); -let expectError = require('../../lib/utils').test.expectError; let I; let dbFile = path.join(__dirname, '/../data/rest/db.json'); require('co-mocha')(require('mocha'));