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
cache:
bundler: true
directories:
- node_modules
addons:
chrome: stable
node_js:
- 6
before_script: make dev
before_install:
- export DISPLAY=:99.0
install: make dev
before_script: make serve_bg
script: make check
sudo: false

View File

@ -1,17 +1,17 @@
# You can set these variables from the command line.
BUILDDIR = ./docs
BUNDLE ?= ./.bundle/bin/bundle
GRUNT ?= ./node_modules/.bin/grunt
HTTPSERVE ?= ./node_modules/.bin/http-server
ESLINT ?= ./node_modules/.bin/eslint
PAPER =
PHANTOMJS ?= ./node_modules/.bin/phantomjs
RJS ?= ./node_modules/.bin/r.js
PO2JSON ?= ./node_modules/.bin/po2json
SASS ?= ./.bundle/bin/sass
CLEANCSS ?= ./node_modules/clean-css-cli/bin/cleancss --skip-rebase
SPHINXBUILD ?= ./bin/sphinx-build
SPHINXOPTS =
BUILDDIR = ./docs
BUNDLE ?= ./.bundle/bin/bundle
GRUNT ?= ./node_modules/.bin/grunt
HTTPSERVE ?= ./node_modules/.bin/http-server
ESLINT ?= ./node_modules/.bin/eslint
PAPER =
CHROMIUM ?= ./node_modules/.bin/run-headless-chromium
RJS ?= ./node_modules/.bin/r.js
PO2JSON ?= ./node_modules/.bin/po2json
SASS ?= ./.bundle/bin/sass
CLEANCSS ?= ./node_modules/clean-css-cli/bin/cleancss --skip-rebase
SPHINXBUILD ?= ./bin/sphinx-build
SPHINXOPTS =
# Internal variables.
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) ./docs/source
@ -47,8 +47,12 @@ help:
## Miscellaneous
.PHONY: serve
serve: stamp-npm
$(HTTPSERVE) -p 8000 -c -1
serve: dev
$(HTTPSERVE) -p 8000 -c-1
.PHONY: serve_bg
serve_bg: dev
$(HTTPSERVE) -p 8000 -c-1 -s &
########################################################################
## Translation machinery
@ -189,7 +193,7 @@ eslint: stamp-npm
.PHONY: check
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",
"npm": "^4.1.1",
"otr": "0.2.16",
"phantomjs-prebuilt": "~2.1.14",
"pluggable.js": "https://github.com/jcbrand/pluggable.js.git#8f8c8235816f44cda0f855d6ca879445aaa486a1",
"po2json": "^0.4.4",
"requirejs": "2.3.3",
"run-headless-chromium": "^0.1.1",
"sinon": "^2.1.0",
"snyk": "^1.21.2",
"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.jasmine = "node_modules/jasmine-core/lib/jasmine-core/jasmine";
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["console-runner"] = "node_modules/phantom-jasmine/lib/console-runner";
config.shim.jasmine = {
@ -17,15 +18,15 @@ config.shim['jasmine-html'] = {
deps: ['jasmine'],
exports: 'window.jasmineRequire'
};
config.shim.boot = {
deps: ['jasmine', 'jasmine-html'],
config.shim['jasmine-console'] = {
deps: ['jasmine'],
exports: 'window.jasmineRequire'
};
/*
config.shim['console-runner'] = {
deps: ['jasmine']
config.shim.boot = {
deps: ['jasmine', 'jasmine-html', 'jasmine-console'],
exports: 'window.jasmine'
};
*/
require.config(config);
// 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.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
require(specs, function () {
// 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
window.onload();
});
}
);
// 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
window.onload();
});
});