Browse Source

Run tests using chromium headless.

JC Brand 8 years ago
parent
commit
e907bec4d8
4 changed files with 59 additions and 30 deletions
  1. 12 1
      .travis.yml
  2. 20 16
      Makefile
  3. 1 1
      package.json
  4. 26 12
      tests/runner.js

+ 12 - 1
.travis.yml

@@ -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

+ 20 - 16
Makefile

@@ -1,17 +1,17 @@
 # You can set these variables from the command line.
 # 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.
 # 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
-	$(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
 ## 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
 
 
 
 
 ########################################################################
 ########################################################################

+ 1 - 1
package.json

@@ -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",

+ 26 - 12
tests/runner.js

@@ -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 = {
-    deps: ['jasmine', 'jasmine-html'],
+config.shim['jasmine-console'] = {
+    deps: ['jasmine'],
     exports: 'window.jasmineRequire'
     exports: 'window.jasmineRequire'
 };
 };
-/*
-config.shim['console-runner'] = {
-    deps: ['jasmine']
+config.shim.boot = {
+    deps: ['jasmine', 'jasmine-html', 'jasmine-console'],
+    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`)
-            // 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();
+    });
+});