diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..e275ba28 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - '0.10' +install: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - npm install \ No newline at end of file diff --git a/package.json b/package.json index 56529725..5c2c32de 100644 --- a/package.json +++ b/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", "scripts": { "build": "PATH=$PATH:./node_modules/.bin cake dist", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "./node_modules/coffee-script/bin/cake dist; ./node_modules/mocha/bin/mocha src/test/e2e/index.js" }, "repository": { "type": "git", @@ -24,8 +24,12 @@ "less": "~1.4.2" }, "devDependencies": { - "express": "3.x", + "chai": "^1.10.0", + "cors": "2.1.1", "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" } } diff --git a/src/test/e2e/index.js b/src/test/e2e/index.js new file mode 100644 index 00000000..8101dbc9 --- /dev/null +++ b/src/test/e2e/index.js @@ -0,0 +1,63 @@ +var webdriver = require('selenium-webdriver'); +var createServer = require('http-server').createServer; +var expect = require('chai').expect; +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) { + expect(title).to.contain('Swagger UI'); + done(); + } + + return hasTitle; + }); + }, 1000); + }); +}); + +describe('cleanup', function () { + + it('kills the static server', function () { + server.close(); + }); + + it('quit the webdriver', function () { + driver.quit(); + }); +}) + + +