Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Automated tests #323

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ node_js:
- '0.10'
install:
- npm install -g grunt-cli && npm install
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then curl https://gist.githubusercontent.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash; fi
notifications:
hipchat:
rooms:
Expand All @@ -16,3 +15,5 @@ env:
global:
- secure: dM7svnHPPu5IiUMeFWW5zg+iuWNpwt6SSDi3MmVvhSclNMRLesQoRB+7Qq5J/LiKhmjpv1/GlNVV0CTsHMRhZNwQ3fo38eEuTXv99aAflEITXwSEh/VntKViHbGFubn06EnVkJoH6MX3zJ6kbiwc2QdSQbywKzS6l6quUEpWpd0=
- secure: AnduYGXka5ft1x7V3SuVYqvlKLvJGhUaRNFdy4UDJr3ZVuwpQjE4TMDG8REmJIJvXfHbh4qY4N1cFSGnXkZ4bH21Xk0v9DLhsxbarKz+X2BvPgXs+Af9EQ6vLEy/5S1vMLxfT5+y+Ec5bVNGOsdUZby8Y21CRzSg6ADN9kwPGlE=
addons:
sauce_connect: true
64 changes: 61 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ module.exports = function(grunt) {
port: 9999,
keepalive: true
}
},
test: {
options: {
hostname: '*',
port: 9999
}
}
},
open : {
Expand Down Expand Up @@ -196,7 +202,53 @@ module.exports = function(grunt) {
autoWatch: false
}
},
protractor: {
options: {
configFile: 'test/functional/protractor.config.js'
},

chrome: {
options: {
args: {
capabilities: {
browserName: 'chrome'
}
}
}
},

firefox: {
options: {
args: {
capabilities: {
browserName: 'firefox'
}
}
}
},

safari: {
options: {
args: {
capabilities: {
browserName: 'safari'
}
}
}
},

ie: {
options: {
args: {
capabilities: {
browserName: 'internet explorer'
}
}
}
},

saucelabs:{}
}
});

// These plugins provide necessary tasks.
Expand All @@ -212,6 +264,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-github-releaser');
grunt.loadNpmTasks('grunt-version');
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('chg');


Expand Down Expand Up @@ -284,16 +337,21 @@ module.exports = function(grunt) {
grunt.task.run(['karma:phantomjs']);
} else if (process.env.TRAVIS) {
grunt.task.run(['karma:saucelabs']);
grunt.task.run(['connect:test', 'protractor:saucelabs']);
} else {
if (tasks.length === 0) {
tasks.push('chrome');
}
if (tasks.length === 1) {
tasks = tasks[0].split(',');
}
tasks = tasks.map(function(el) {
return 'karma:' + el;
});
tasks = tasks.reduce(function(acc, el) {
acc.push('karma:' + el);
if (/chrome|firefox|safari|ie/.test(el)) {
acc.push('protractor:' + el);
}
return acc;
}, ['connect:test']);

grunt.task.run(tasks);
}
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ the web](http://www.html5rocks.com/en/tutorials/track/basics/).
### Testing

For testing, you can either run `npm test` or use `grunt` directly.
If you use `npm test`, it will only run the karma tests using chrome.
If you use `npm test`, it will only run the karma and end-to-end tests using chrome.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So grunt test would not run the end-to-end tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grunt test will run the end-to-end tests.

You can specify which browsers you want the tests to run via grunt's `test` task.
You can use either grunt-style arguments or comma separated arguments:
```
Expand All @@ -201,10 +201,14 @@ Possible options are:
* `chromecanary`
* `phantomjs`
* `opera`
* `chrome`
* `safari`
* `firefox`
* `ie`
* `chrome`<sup>1</sup>
* `safari`<sup>1, 2</sup>
* `firefox`<sup>1</sup>
* `ie`<sup>1</sup>


_<sup>1</sup>supported end-to-end browsers_<br />
_<sup>2</sup>requires the [SafariDriver extension]( https://code.google.com/p/selenium/wiki/SafariDriver) to be installed_

## Hosting Considerations
Unlike a native HLS implementation, the HLS tech has to comply with
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"devDependencies": {
"chg": "^0.2.0",
"grunt": "~0.4.1",
"grunt": "^0.4.5",
"grunt-concurrent": "0.4.3",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-concat": "~0.3.0",
Expand All @@ -30,6 +30,7 @@
"grunt-github-releaser": "^0.1.17",
"grunt-karma": "~0.6.2",
"grunt-open": "0.2.3",
"grunt-protractor-runner": "git+https://github.com/forbesjo/grunt-protractor-runner.git#update-webdriver",
"grunt-shell": "0.6.1",
"grunt-version": "^1.0.0",
"karma": "~0.10.0",
Expand Down
38 changes: 38 additions & 0 deletions test/functional/protractor.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* global browser */

var config = {};

if (process.env.SAUCE_USERNAME) {
config.multiCapabilities = [{
browserName: 'chrome',
platform: 'Windows 8.1'
}, {
browserName: 'firefox',
platform: 'Windows 8.1'
}].map(function(caps) {
caps.name = process.env.TRAVIS_BUILD_NUMBER + process.env.TRAVIS_BRANCH;
caps.build = process.env.TRAVIS_BUILD_NUMBER;
caps['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER;
caps.recordScreenshots = false;
return caps;
});

config.sauceUser = process.env.SAUCE_USERNAME;
config.sauceKey = process.env.SAUCE_ACCESS_KEY;
config.maxSessions = 5;
config.maxDuration = 300;
}

config.baseUrl = 'http://localhost:9999/example.html';
config.specs = ['spec.js'];

config.framework = 'jasmine2';
config.onPrepare = function() {
browser.ignoreSynchronization = true;
};
config.jasmineNodeOpts = {
showColors: true,
defaultTimeoutInterval: 60000
};

exports.config = config;
21 changes: 21 additions & 0 deletions test/functional/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* global browser, $, describe, beforeEach, it, expect, player */

describe('Player', function() {
beforeEach(function() {
browser.get(browser.baseUrl);
});

it('should play', function() {
$('.vjs-big-play-button').click();
browser.executeAsyncScript(function(done) {
player.one('timeupdate', function() {
var result = !player.paused() &&
!player.ended() &&
player.error() === null;
done(result);
});
}).then(function(result) {
expect(result).toBe(true);
});
});
});