Skip to content

Commit

Permalink
Problem: No client side tests (#1001)
Browse files Browse the repository at this point in the history
Solution: Implement webdriverio + headless chrome client side tests in Travis CI and include an example test for the home page. (`homepage.spec.js`)
  • Loading branch information
anbud committed Apr 7, 2018
1 parent 223cfc1 commit ec35cdb
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ sudo: required

language: node_js

addons:
chrome: stable

node_js:
- '8'

Expand All @@ -11,6 +14,9 @@ before_install:
- export LC_ALL=C
- curl https://install.meteor.com | /bin/sh
- export PATH="$HOME/.meteor:$PATH"
- npm install selenium-standalone@latest -g
- selenium-standalone install
- selenium-standalone start &

cache:
directories:
Expand All @@ -19,6 +25,10 @@ cache:

before_script:
- meteor npm install
- meteor npm install --unsafe wdio-mocha-framework webdriverio assert
- meteor --production &
- sleep 300 # wait for Meteor to start, it takes some time, 5 minutes should be sufficient

script:
- meteor test --driver-package=meteortesting:mocha --once
- ./node_modules/.bin/wdio wdio.conf.js
- meteor test --driver-package=meteortesting:mocha --once --port 5000
13 changes: 13 additions & 0 deletions imports/ui/pages/returnedCurrencies/homepage.ui-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const assert = require('assert')

const baseUrl = 'http://localhost:3000' // baseUrl of the app we are testing, it's localhost here, as we're starting a local server in Travis CI cycle

// see the full webdriverio browser API here: http://webdriver.io/api.html
describe('Home page', function () {
it('Currencies should render properly', function () {
browser.url(`${baseUrl}/`) // navigate to the home route `/`
browser.pause(2000) // let it load, wait for 2 seconds
assert(browser.isExisting('.currency-card'), true) // check if at least one currency card has rendered, isExisting === $() !== undefined
assert(browser.isVisible('.currency-card'), true) // check if at least one currency card is visible on the page isVisible === $().is(':visible')
})
})
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions wdio.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
exports.config = {
specs: ['./imports/**/*.ui-test.js'],
exclude: [],
maxInstances: 10,
capabilities: [{
browserName: 'chrome',
chromeOptions: {
args: ['--headless', '--disable-gpu', '--window-size=1280,800'],
binary: '/usr/bin/google-chrome-stable'
}
}],
sync: true,
logLevel: 'silent',
coloredLogs: true,
deprecationWarnings: true,
bail: 0,
screenshotPath: './screens/',
baseUrl: 'http://localhost:3000',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
framework: 'mocha',
reporters: ['dot'],
mochaOpts: {
ui: 'bdd'
}
}

0 comments on commit ec35cdb

Please sign in to comment.