From e907bec4d81e7733cb6ae07f82afd298264aec3e Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 13 Jun 2017 12:22:02 +0200 Subject: [PATCH] Run tests using chromium headless. --- .travis.yml | 13 ++++++++++++- Makefile | 36 ++++++++++++++++++++---------------- package.json | 2 +- tests/runner.js | 38 ++++++++++++++++++++++++++------------ 4 files changed, 59 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index a3cfa7467..3869187af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Makefile b/Makefile index 3bf60f2ba..6b760411b 100644 --- a/Makefile +++ b/Makefile @@ -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 ######################################################################## diff --git a/package.json b/package.json index e3ef88409..32bfc4fb1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/runner.js b/tests/runner.js index 03bbb13fc..e3009cd8b 100644 --- a/tests/runner.js +++ b/tests/runner.js @@ -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(); + }); +});