Skip to content

Commit

Permalink
Merge pull request #8 from ktsn/change-e2e-test
Browse files Browse the repository at this point in the history
Change e2e test framework
  • Loading branch information
ktsn authored Nov 25, 2016
2 parents 4e88284 + 4b899ad commit 36cd77a
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 160 deletions.
3 changes: 0 additions & 3 deletions .testiumrc

This file was deleted.

12 changes: 0 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
language: node_js
node_js:
- "6"
env:
- CXX=g++-4.8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
script:
- echo
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"scripts": {
"prepublish": "npm run release",
"start": "run-s build:cjs watch:example",
"clean": "rm -rf dist .tmp",
"dev": "run-p watch:cjs watch:example",
"dev:test": "run-p watch:test testem",
Expand All @@ -39,10 +38,10 @@
"lint": "eslint --fix \"@(src|test|scripts|example)/**/*.@(js|vue)\"",
"testem": "testem",
"testem:ci": "testem ci --launch PhantomJS",
"test": "run-s test:*",
"test": "run-s lint flow test:*",
"test:unit": "run-s build:test testem:ci",
"test:e2e": "mocha --compilers js:babel-register test/e2e/example.js",
"release": "run-s lint flow test clean build"
"test:e2e": "npm run build:cjs && node test/e2e/runner.js",
"release": "run-s test clean build"
},
"devDependencies": {
"autoprefixer": "^6.5.1",
Expand All @@ -54,14 +53,13 @@
"babel-plugin-transform-flow-strip-types": "^6.8.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-power-assert": "^1.0.0",
"babel-register": "^6.14.0",
"cross-env": "^2.0.0",
"css-loader": "^0.25.0",
"eslint": "^3.0.0",
"eslint-plugin-flowtype": "^2.4.1",
"eslint-plugin-html": "^1.5.2",
"flow-bin": "^0.32.0",
"mocha": "^3.0.2",
"glob": "^7.1.1",
"node-sass": "^3.10.0",
"npm-run-all": "^3.0.0",
"postcss": "^5.2.4",
Expand All @@ -78,13 +76,13 @@
"rollup-plugin-vue": "^2.2.3",
"rollup-watch": "^2.5.0",
"style-loader": "^0.13.1",
"testcafe": "^0.10.0",
"testcafe-browser-provider-phantomjs": "^1.0.0",
"testem": "^1.6.0",
"testium-driver-sync": "^2.3.0",
"testium-mocha": "^1.1.0",
"uglifyjs": "^2.4.10",
"vue": "^2.0.0-rc.6",
"vue-loader": "^9.5.0",
"webpack": "^2.1.0-beta.23",
"webpack-dev-server": "^2.1.0-beta.4"
"vue": "^2.1.3",
"vue-loader": "^10.0.1",
"webpack": "^2.1.0-beta.27",
"webpack-dev-server": "^2.1.0-beta.11"
}
}
8 changes: 4 additions & 4 deletions scripts/webpack.config.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ module.exports = {
}
},
module: {
loaders: [
{ test: /\.js$/, loader: 'babel', exclude: /(node_modules|dist)/ },
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.vue$/, loader: 'vue' }
rules: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /(node_modules|dist)/ },
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.vue$/, loader: 'vue-loader' }
]
},
devServer: {
Expand Down
3 changes: 3 additions & 0 deletions test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
---
env:
mocha: true
globals:
fixture: true
test: true
91 changes: 0 additions & 91 deletions test/e2e/example.js

This file was deleted.

64 changes: 26 additions & 38 deletions test/e2e/pages/example.js
Original file line number Diff line number Diff line change
@@ -1,79 +1,67 @@
class ExamplePage {
constructor (browser) {
this.browser = browser
export default class ExamplePage {
constructor (t) {
this.t = t
}

get wait () {
return this.t
}

setName (name) {
this.browser.setValue('.name', name)
this.t = this.t.typeText('.name', name, { replace: true })
return this
}

setValue (value) {
this.browser.setValue('.value', value)
this.t = this.t.typeText('.value', String(value), { replace: true })
return this
}

setMin (min) {
this.browser.setValue('.min', min)
this.t = this.t.typeText('.min', String(min), { replace: true })
return this
}

setMax (max) {
this.browser.setValue('.max', max)
this.t = this.t.typeText('.max', String(max), { replace: true })
return this
}

setStep (step) {
this.browser.setValue('.step', step)
this.t = this.t.typeText('.step', String(step), { replace: true })
return this
}

toggleDisabled () {
this.browser.click('.disabled')
return this
}

mouseDownSlider () {
this.browser
.getElement('.range-slider-knob')
// intend to mouse down at center
// knob size === 20
.movePointerRelativeTo(10, 10)
this.browser.buttonDown()
return this
}

mouseUp () {
this.browser.buttonUp()
this.t = this.t.click('.disabled')
return this
}

moveSlider (offsetRatio) {
this.mouseDownSlider()
this.browser
.getElement('.range-slider-knob')
this.t = this.t.drag(
'.range-slider-knob',
// the width that knob can move is 200
// keep mouse position at the knob center
.movePointerRelativeTo(200 * offsetRatio + 10, 10)
this.mouseUp()
200 * offsetRatio,
0,
{ offsetX: 10, offsetY: 10 }
)
return this
}

getValue () {
return this.browser.getElement('.value').get('value')
return this.t.select('.value').value
}

getSliderName () {
return this.browser
.getElement('.range-slider input')
.get('name')
return this.t
.select('.range-slider input')
.then(el => el.getAttribute('name'))
}

getSliderValue () {
return this.browser
.getElement('.range-slider input')
.get('value')
return this.t
.select('.range-slider input')
.value
}
}

module.exports = ExamplePage
26 changes: 26 additions & 0 deletions test/e2e/runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const path = require('path')
const glob = require('glob')
const WebpackDevServer = require('webpack-dev-server')
const webpack = require('webpack')
const createTestCafe = require('testcafe')

const compiler = webpack(require('../../scripts/webpack.config.example'))

const server = new WebpackDevServer(compiler, {
contentBase: 'example',
noInfo: true
})

server.listen(8080, () => {
createTestCafe('localhost', 1337, 1338)
.then(testCafe => {
return testCafe
.createRunner()
.src(glob.sync(path.resolve(__dirname, 'specs/**/*.js')))
.browsers(['phantomjs'])
.run()
})
.then(() => {
process.exit()
})
})
Loading

0 comments on commit 36cd77a

Please sign in to comment.