diff --git a/.travis.yml b/.travis.yml index 25a6ae3..b4004dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,5 @@ language: node_js node_js: "node" before_install: - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start \ No newline at end of file + - sh -e /etc/init.d/xvfb start +script: npm run ci diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..dd7434d --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,58 @@ +const server = require('./test/server'); + +module.exports = function (grunt) { + const browsers = [{ + browserName: 'firefox', + platform: 'Windows 10' + }, { + browserName: 'googlechrome', + platform: 'linux' + }, { + browserName: 'safari', + platform: 'OS X 10.11', + version: '9.0' + }, { + browserName: 'internet explorer', + platform: 'Windows 8', + version: '10' + }, { + browserName: 'internet explorer', + platform: 'Windows 10', + version: '11' + }, { + browserName: 'internet explorer', + platform: 'Vista', + version: '9' + } + ]; + + grunt.registerTask('server', 'Start the test server', function() { + server.listen(3000).on('listening', () => { + console.log('Test server listening on port 3000'); + }); + }); + + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + server: {}, + + 'saucelabs-mocha': { + all: { + options: { + urls: [ + 'http://127.0.0.1:3000/test/browser/index.html' + ], + browsers: browsers, + build: process.env.TRAVIS_JOB_ID, + testname: 'feathers-client mocha tests', + throttled: 1 + } + } + }, + watch: {} + }); + + grunt.loadNpmTasks('grunt-saucelabs'); + + grunt.registerTask('default', [ 'server', 'saucelabs-mocha' ]); +}; diff --git a/package.json b/package.json index 272950e..4871f5d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,9 @@ "watch": "babel --watch -d lib/ src/", "jshint": "jshint src/. test/. --config", "mocha": "mocha test/*/**.test.js --compilers js:babel-core/register --recursive --timeout 10000", - "test": "npm run clean && npm run browserify && npm run jshint && npm run mocha" + "saucelabs": "grunt", + "test": "npm run clean && npm run browserify && npm run jshint && npm run mocha", + "ci": "npm test && npm run saucelabs" }, "directories": { "lib": "lib" @@ -69,6 +71,9 @@ "body-parser": "^1.12.4", "browserify": "^13.0.0", "feathers-memory": "^0.8.0", + "grunt": "^1.0.1", + "grunt-cli": "^1.2.0", + "grunt-saucelabs": "^9.0.0", "jsdom": "8.1.0", "jshint": "^2.8.0", "mocha": "^3.0.0", @@ -76,7 +81,6 @@ "request": "^2.56.0", "socket.io-client": "^1.3.5", "superagent": "^2.0.0", - "testee": "^0.2.5", "uglifyjs": "^2.4.10" } } diff --git a/readme.md b/readme.md index 1381857..89d6442 100644 --- a/readme.md +++ b/readme.md @@ -2,6 +2,8 @@ [](https://travis-ci.org/feathersjs/feathers-client) +[](https://saucelabs.com/u/feathersjs) + > A client for Feathers services supporting many different transport libraries. ## About diff --git a/test/browser/browser.test.js b/test/browser/browser.test.js deleted file mode 100644 index 5c92a77..0000000 --- a/test/browser/browser.test.js +++ /dev/null @@ -1,24 +0,0 @@ -import socketio from 'feathers-socketio'; -import assert from 'assert'; -import testee from 'testee'; -import app from '../fixture'; - -describe('Universal Feathers client browser test', function() { - before(function(done) { - this.server = app(function() { - this.configure(socketio()); - }).listen(7979, done); - }); - - after(function() { - this.server.close(); - }); - - it('runs the browser tests', done => { - testee.test(['test/browser/index.html'], ['firefox'], {}) - .then(function(data) { - assert.ok(data[0].passed > 0); - done(); - }).catch(done); - }); -}); diff --git a/test/browser/index.html b/test/browser/index.html index 2be2597..c27ed0d 100644 --- a/test/browser/index.html +++ b/test/browser/index.html @@ -7,7 +7,7 @@
- + @@ -15,7 +15,36 @@ diff --git a/test/browser/test.js b/test/browser/test.js index 487b032..33350f1 100644 --- a/test/browser/test.js +++ b/test/browser/test.js @@ -2,7 +2,7 @@ import assert from 'assert'; import baseTests from 'feathers-commons/lib/test/client'; const feathers = window.feathers; -const socket = window.io('http://localhost:7979'); +const socket = window.io(); describe('Universal Feathers client browser tests', function() { const app = feathers() @@ -29,6 +29,8 @@ describe('Universal Feathers client browser tests', function() { hook.result.ran = true; } }); + + after(() => app.service('todos').remove(null)); baseTests(app, 'todos'); diff --git a/test/fixture.js b/test/fixture.js index 3d48f09..ab4597c 100644 --- a/test/fixture.js +++ b/test/fixture.js @@ -1,7 +1,9 @@ -import feathers from 'feathers'; -import rest from 'feathers-rest'; -import bodyParser from 'body-parser'; -import memory from 'feathers-memory'; +const feathers = require('feathers'); +const hooks = require('feathers-hooks'); +const rest = require('feathers-rest'); +const bodyParser = require('body-parser'); +const memory = require('feathers-memory'); +const path = require('path'); Object.defineProperty(Error.prototype, 'toJSON', { value: function () { @@ -31,6 +33,7 @@ module.exports = function(configurer) { }); var app = feathers() + .configure(hooks()) // Set up REST and SocketIO APIs .configure(rest()); @@ -42,11 +45,26 @@ module.exports = function(configurer) { app.use(bodyParser.json()) .use(bodyParser.urlencoded({ extended: true })) // Host the current directory (for index.html) - .use(feathers.static(__dirname)) + .use(feathers.static(path.join(__dirname, '..'))) // Host our Todos service on the /todos path .use('/todos', todoService); - app.service('todos').create({ text: 'some todo', complete: false }, {}, function() {}); + const testTodo = { + text: 'some todo', + complete: false + }; + const service = app.service('todos'); + + service.create(testTodo); + service.after({ + remove(hook) { + if(hook.id === null) { + service._uId = 0; + return service.create(testTodo) + .then(() => hook); + } + } + }); return app; }; diff --git a/test/server.js b/test/server.js new file mode 100644 index 0000000..5c02cdd --- /dev/null +++ b/test/server.js @@ -0,0 +1,7 @@ +const socketio = require('feathers-socketio'); +const createApp = require('./fixture'); +const app = createApp(function() { + this.configure(socketio()); +}); + +module.exports = app;