Add e2e tests
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- '0.10'
|
- '0.10'
|
||||||
|
install:
|
||||||
|
- export DISPLAY=:99.0
|
||||||
|
- sh -e /etc/init.d/xvfb start
|
||||||
|
- npm install
|
||||||
10
package.json
10
package.json
@@ -4,7 +4,7 @@
|
|||||||
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
|
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "PATH=$PATH:./node_modules/.bin cake dist",
|
"build": "PATH=$PATH:./node_modules/.bin cake dist",
|
||||||
"test": "./node_modules/coffee-script/bin/cake dist"
|
"test": "./node_modules/coffee-script/bin/cake dist; ./node_modules/mocha/bin/mocha src/test/e2e/index.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -24,8 +24,12 @@
|
|||||||
"less": "~1.4.2"
|
"less": "~1.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"express": "3.x",
|
"chai": "^1.10.0",
|
||||||
|
"cors": "2.1.1",
|
||||||
"docco": "0.4.x",
|
"docco": "0.4.x",
|
||||||
"cors": "2.1.1"
|
"express": "3.x",
|
||||||
|
"http-server": "^0.7.4",
|
||||||
|
"mocha": "^2.1.0",
|
||||||
|
"selenium-webdriver": "^2.44.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
58
src/test/e2e/index.js
Normal file
58
src/test/e2e/index.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
var webdriver = require('selenium-webdriver');
|
||||||
|
var createServer = require('http-server').createServer;
|
||||||
|
var path = require('path');
|
||||||
|
var dist = path.join(__dirname, '..', '..', '..', 'dist');
|
||||||
|
var PORT = 8080;
|
||||||
|
|
||||||
|
console.log('started static server from', dist, 'at port', PORT);
|
||||||
|
|
||||||
|
var server = createServer({
|
||||||
|
root: dist,
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
server.listen(PORT);
|
||||||
|
|
||||||
|
var driver = new webdriver.Builder().
|
||||||
|
withCapabilities(webdriver.Capabilities.firefox()).
|
||||||
|
build();
|
||||||
|
|
||||||
|
|
||||||
|
describe('basics', function () {
|
||||||
|
|
||||||
|
this.timeout(10 * 1000);
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
driver.get('http://localhost:' + PORT);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have "Swagger UI" in title', function (done) {
|
||||||
|
|
||||||
|
driver.wait(function() {
|
||||||
|
return driver.getTitle().then(function(title) {
|
||||||
|
var hasTitle = title.indexOf('Swagger UI') > -1;
|
||||||
|
|
||||||
|
if (hasTitle) { done(); }
|
||||||
|
|
||||||
|
return hasTitle;
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('cleanup', function () {
|
||||||
|
|
||||||
|
it('kills the static server', function () {
|
||||||
|
server.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('quit the webdriver', function () {
|
||||||
|
driver.quit();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user