Kaynağa Gözat

Better phantomjs test runnning and reporting

* Use phantom-jasmine instead of jasmine-reporters
* Update Makefile to use the test runner from phantom-jasmine
* Use newest phantomjs
* Use latest bower
* Turn of jquery effects when testing
JC Brand 11 yıl önce
ebeveyn
işleme
53a8f288bc
4 değiştirilmiş dosya ile 47 ekleme ve 31 silme
  1. 2 1
      .gitignore
  2. 28 3
      Makefile
  3. 3 3
      package.json
  4. 14 24
      tests_main.js

+ 2 - 1
.gitignore

@@ -12,7 +12,8 @@ node_modules
 components
 components
 docs/doctrees/environment.pickle
 docs/doctrees/environment.pickle
 tags
 tags
-test-reports
+stamp-npm
+stamp-bower
 
 
 # OSX
 # OSX
 .DS_Store
 .DS_Store

+ 28 - 3
Makefile

@@ -5,6 +5,7 @@ PAPER        =
 BUILDDIR     = ./docs
 BUILDDIR     = ./docs
 
 
 BOWER 		?= node_modules/.bin/bower
 BOWER 		?= node_modules/.bin/bower
+PHANTOMJS	?= node_modules/.bin/phantomjs
 
 
 # Internal variables.
 # Internal variables.
 PAPEROPT_a4     = -D latex_paper_size=a4
 PAPEROPT_a4     = -D latex_paper_size=a4
@@ -51,13 +52,37 @@ release:
 	sed -i "s/(Unreleased)/(`date +%Y-%m-%d`)/" docs/CHANGES.rst
 	sed -i "s/(Unreleased)/(`date +%Y-%m-%d`)/" docs/CHANGES.rst
 	grunt minify
 	grunt minify
 
 
-dev:
+
+########################################################################
+## Install dependencies
+
+stamp-npm: package.json
 	npm install
 	npm install
-	${BOWER} update;
+	touch stamp-npm
 
 
-clean:
+stamp-bower: stamp-npm bower.json
+	$(BOWER) install
+	touch stamp-bower
+
+clean::
+	rm -f stamp-npm stamp-bower
+	rm -rf node_modules components
 	-rm -rf $(BUILDDIR)/*
 	-rm -rf $(BUILDDIR)/*
 
 
+dev: clean
+	npm install
+	${BOWER} update;
+
+
+########################################################################
+## Tests
+
+check:: stamp-npm
+	$(PHANTOMJS) node_modules/phantom-jasmine/lib/run_jasmine_test.coffee tests.html
+
+########################################################################
+## Documentation
+
 html:
 html:
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
 	@echo
 	@echo

+ 3 - 3
package.json

@@ -30,9 +30,9 @@
     "grunt-cli": "~0.1.9",
     "grunt-cli": "~0.1.9",
     "grunt": "~0.4.1",
     "grunt": "~0.4.1",
     "grunt-contrib-jshint": "~0.6.0",
     "grunt-contrib-jshint": "~0.6.0",
-    "phantomjs": "~1.9.1-0",
-    "jasmine-reporters": "~0.2.1",
-    "bower": "~1.0.0",
+    "phantom-jasmine": "0.1.8",
+    "phantomjs": "~1.9.7-1",
+    "bower": "latest",
     "grunt-contrib-requirejs": "~0.4.1",
     "grunt-contrib-requirejs": "~0.4.1",
     "grunt-contrib-cssmin": "~0.6.1"
     "grunt-contrib-cssmin": "~0.6.1"
   },
   },

+ 14 - 24
tests_main.js

@@ -3,21 +3,11 @@ config.paths.mock = "tests/mock";
 config.paths.utils = "tests/utils";
 config.paths.utils = "tests/utils";
 config.paths.jasmine = "components/jasmine/lib/jasmine-core/jasmine";
 config.paths.jasmine = "components/jasmine/lib/jasmine-core/jasmine";
 config.paths["jasmine-html"] = "components/jasmine/lib/jasmine-core/jasmine-html";
 config.paths["jasmine-html"] = "components/jasmine/lib/jasmine-core/jasmine-html";
-config.paths["jasmine-console-reporter"] = "node_modules/jasmine-reporters/src/jasmine.console_reporter";
-config.paths["jasmine-junit-reporter"] = "node_modules/jasmine-reporters/src/jasmine.junit_reporter";
-
+config.paths["console-runner"] = "node_modules/phantom-jasmine/lib/console-runner";
 config.shim['jasmine-html'] = {
 config.shim['jasmine-html'] = {
     deps: ['jasmine'],
     deps: ['jasmine'],
     exports: 'jasmine'
     exports: 'jasmine'
 };
 };
-config.shim['jasmine-console-reporter'] = {
-    deps: ['jasmine-html'],
-    exports: 'jasmine'
-};
-config.shim['jasmine-junit-reporter'] = {
-    deps: ['jasmine-html'],
-    exports: '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
@@ -27,8 +17,8 @@ if (!Function.prototype.bind) {
             // closest thing possible to the ECMAScript 5 internal IsCallable function
             // closest thing possible to the ECMAScript 5 internal IsCallable function
             throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
             throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
         }
         }
-        var aArgs = Array.prototype.slice.call(arguments, 1), 
-            fToBind = this, 
+        var aArgs = Array.prototype.slice.call(arguments, 1),
+            fToBind = this,
             fNOP = function () {},
             fNOP = function () {},
             fBound = function () {
             fBound = function () {
             return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
             return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
@@ -47,6 +37,7 @@ require([
     "jasmine-html"
     "jasmine-html"
     ], function($, converse, mock, jasmine) {
     ], function($, converse, mock, jasmine) {
         // Set up converse.js
         // Set up converse.js
+        $.fx.off = true;
         window.converse_api = converse;
         window.converse_api = converse;
         window.localStorage.clear();
         window.localStorage.clear();
         converse.initialize({
         converse.initialize({
@@ -64,12 +55,11 @@ require([
                     var i;
                     var i;
                     for (i=0, len=buf.length; i<len; i++) {
                     for (i=0, len=buf.length; i<len; i++) {
                         buf[i] = Math.floor(Math.random()*256);
                         buf[i] = Math.floor(Math.random()*256);
-                    } 
+                    }
                 }
                 }
             };
             };
             require([
             require([
-                "jasmine-console-reporter",
-                "jasmine-junit-reporter",
+                "console-runner",
                 "spec/converse",
                 "spec/converse",
                 "spec/otr",
                 "spec/otr",
                 "spec/eventemitter",
                 "spec/eventemitter",
@@ -82,19 +72,19 @@ require([
 
 
                 // Jasmine stuff
                 // Jasmine stuff
                 var jasmineEnv = jasmine.getEnv();
                 var jasmineEnv = jasmine.getEnv();
+                var reporter;
                 if (/PhantomJS/.test(navigator.userAgent)) {
                 if (/PhantomJS/.test(navigator.userAgent)) {
-                    jasmineEnv.addReporter(new jasmine.TrivialReporter());
-                    jasmineEnv.addReporter(new jasmine.JUnitXmlReporter('./test-reports/'));
-                    jasmineEnv.addReporter(new jasmine.ConsoleReporter());
+                    reporter = new jasmine.ConsoleReporter();
+                    window.console_reporter = reporter;
+                    jasmineEnv.addReporter(reporter);
                     jasmineEnv.updateInterval = 0;
                     jasmineEnv.updateInterval = 0;
                 } else {
                 } else {
-                    var htmlReporter = new jasmine.HtmlReporter();
-                    jasmineEnv.addReporter(htmlReporter);
-                    jasmineEnv.addReporter(new jasmine.ConsoleReporter());
+                    reporter = new jasmine.HtmlReporter();
+                    jasmineEnv.addReporter(reporter);
                     jasmineEnv.specFilter = function(spec) {
                     jasmineEnv.specFilter = function(spec) {
-                        return htmlReporter.specFilter(spec);
+                        return reporter.specFilter(spec);
                     };
                     };
-                    jasmineEnv.updateInterval = 100;
+                    jasmineEnv.updateInterval = 0;
                 }
                 }
                 jasmineEnv.execute();
                 jasmineEnv.execute();
             });
             });