Run tests using chromium headless.

This commit is contained in:
JC Brand 2017-06-13 12:22:02 +02:00
parent 1a95472ebe
commit e907bec4d8
4 changed files with 59 additions and 30 deletions

View File

@ -1,6 +1,17 @@
dist: trusty
language: node_js language: node_js
cache:
bundler: true
directories:
- node_modules
addons:
chrome: stable
node_js: node_js:
- 6 - 6
before_script: make dev
before_install:
- export DISPLAY=:99.0
install: make dev
before_script: make serve_bg
script: make check script: make check
sudo: false sudo: false

View File

@ -1,17 +1,17 @@
# You can set these variables from the command line. # You can set these variables from the command line.
BUILDDIR = ./docs BUILDDIR = ./docs
BUNDLE ?= ./.bundle/bin/bundle BUNDLE ?= ./.bundle/bin/bundle
GRUNT ?= ./node_modules/.bin/grunt GRUNT ?= ./node_modules/.bin/grunt
HTTPSERVE ?= ./node_modules/.bin/http-server HTTPSERVE ?= ./node_modules/.bin/http-server
ESLINT ?= ./node_modules/.bin/eslint ESLINT ?= ./node_modules/.bin/eslint
PAPER = PAPER =
PHANTOMJS ?= ./node_modules/.bin/phantomjs CHROMIUM ?= ./node_modules/.bin/run-headless-chromium
RJS ?= ./node_modules/.bin/r.js RJS ?= ./node_modules/.bin/r.js
PO2JSON ?= ./node_modules/.bin/po2json PO2JSON ?= ./node_modules/.bin/po2json
SASS ?= ./.bundle/bin/sass SASS ?= ./.bundle/bin/sass
CLEANCSS ?= ./node_modules/clean-css-cli/bin/cleancss --skip-rebase CLEANCSS ?= ./node_modules/clean-css-cli/bin/cleancss --skip-rebase
SPHINXBUILD ?= ./bin/sphinx-build SPHINXBUILD ?= ./bin/sphinx-build
SPHINXOPTS = SPHINXOPTS =
# Internal variables. # Internal variables.
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) ./docs/source ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) ./docs/source
@ -47,8 +47,12 @@ help:
## Miscellaneous ## Miscellaneous
.PHONY: serve .PHONY: serve
serve: stamp-npm serve: dev
$(HTTPSERVE) -p 8000 -c -1 $(HTTPSERVE) -p 8000 -c-1
.PHONY: serve_bg
serve_bg: dev
$(HTTPSERVE) -p 8000 -c-1 -s &
######################################################################## ########################################################################
## Translation machinery ## Translation machinery
@ -189,7 +193,7 @@ eslint: stamp-npm
.PHONY: check .PHONY: check
check: eslint check: eslint
$(PHANTOMJS) tests/run-jasmine2.js tests.html LOG_CR_VERBOSITY=INFO $(CHROMIUM) http://localhost:8000/tests.html
######################################################################## ########################################################################

View File

@ -61,10 +61,10 @@
"moment": "~2.18.1", "moment": "~2.18.1",
"npm": "^4.1.1", "npm": "^4.1.1",
"otr": "0.2.16", "otr": "0.2.16",
"phantomjs-prebuilt": "~2.1.14",
"pluggable.js": "https://github.com/jcbrand/pluggable.js.git#8f8c8235816f44cda0f855d6ca879445aaa486a1", "pluggable.js": "https://github.com/jcbrand/pluggable.js.git#8f8c8235816f44cda0f855d6ca879445aaa486a1",
"po2json": "^0.4.4", "po2json": "^0.4.4",
"requirejs": "2.3.3", "requirejs": "2.3.3",
"run-headless-chromium": "^0.1.1",
"sinon": "^2.1.0", "sinon": "^2.1.0",
"snyk": "^1.21.2", "snyk": "^1.21.2",
"strophe.js": "1.2.13", "strophe.js": "1.2.13",

View File

@ -8,6 +8,7 @@ config.paths.sinon = "node_modules/sinon/pkg/sinon";
config.paths.transcripts = "converse-logs/converse-logs"; config.paths.transcripts = "converse-logs/converse-logs";
config.paths.jasmine = "node_modules/jasmine-core/lib/jasmine-core/jasmine"; config.paths.jasmine = "node_modules/jasmine-core/lib/jasmine-core/jasmine";
config.paths.boot = "node_modules/jasmine-core/lib/jasmine-core/boot"; config.paths.boot = "node_modules/jasmine-core/lib/jasmine-core/boot";
config.paths["jasmine-console"] = "node_modules/jasmine-core/lib/console/console";
config.paths["jasmine-html"] = "node_modules/jasmine-core/lib/jasmine-core/jasmine-html"; config.paths["jasmine-html"] = "node_modules/jasmine-core/lib/jasmine-core/jasmine-html";
// config.paths["console-runner"] = "node_modules/phantom-jasmine/lib/console-runner"; // config.paths["console-runner"] = "node_modules/phantom-jasmine/lib/console-runner";
config.shim.jasmine = { config.shim.jasmine = {
@ -17,15 +18,15 @@ config.shim['jasmine-html'] = {
deps: ['jasmine'], deps: ['jasmine'],
exports: 'window.jasmineRequire' exports: 'window.jasmineRequire'
}; };
config.shim.boot = { config.shim['jasmine-console'] = {
deps: ['jasmine', 'jasmine-html'], deps: ['jasmine'],
exports: 'window.jasmineRequire' exports: 'window.jasmineRequire'
}; };
/* config.shim.boot = {
config.shim['console-runner'] = { deps: ['jasmine', 'jasmine-html', 'jasmine-console'],
deps: ['jasmine'] exports: 'window.jasmine'
}; };
*/
require.config(config); require.config(config);
// Polyfill 'bind' which is not available in phantomjs < 2.0 // Polyfill 'bind' which is not available in phantomjs < 2.0
@ -79,11 +80,24 @@ require(['jquery', 'mock', 'boot', 'sinon', 'wait-until-promise'],
window.localStorage.clear(); window.localStorage.clear();
window.sessionStorage.clear(); window.sessionStorage.clear();
var jasmineEnv = jasmine.getEnv();
var ConsoleReporter = window.jasmineRequire.ConsoleReporter();
var consoleReporter = new ConsoleReporter({
print: function print(message) {
console.log(message + '\x03\b');
},
onComplete: function onComplete(isSuccess) {
var exitCode = isSuccess ? 0 : 1;
console.info('All tests completed!' + exitCode);
},
showColors: true
});
jasmineEnv.addReporter(consoleReporter);
// Load the specs // Load the specs
require(specs, function () { require(specs, function () {
// Initialize the HTML Reporter and execute the environment (setup by `boot.js`) // Initialize the HTML Reporter and execute the environment (setup by `boot.js`)
// http://stackoverflow.com/questions/19240302/does-jasmine-2-0-really-not-work-with-require-js // http://stackoverflow.com/questions/19240302/does-jasmine-2-0-really-not-work-with-require-js
window.onload(); window.onload();
}); });
} });
);