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
This commit is contained in:
JC Brand 2014-04-18 17:39:45 +02:00
parent a9da15bb2f
commit 53a8f288bc
4 changed files with 47 additions and 31 deletions

3
.gitignore vendored
View File

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

View File

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

View File

@ -30,9 +30,9 @@
"grunt-cli": "~0.1.9",
"grunt": "~0.4.1",
"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-cssmin": "~0.6.1"
},

View File

@ -3,21 +3,11 @@ config.paths.mock = "tests/mock";
config.paths.utils = "tests/utils";
config.paths.jasmine = "components/jasmine/lib/jasmine-core/jasmine";
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'] = {
deps: ['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);
// 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
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 () {},
fBound = function () {
return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
@ -47,6 +37,7 @@ require([
"jasmine-html"
], function($, converse, mock, jasmine) {
// Set up converse.js
$.fx.off = true;
window.converse_api = converse;
window.localStorage.clear();
converse.initialize({
@ -64,12 +55,11 @@ require([
var i;
for (i=0, len=buf.length; i<len; i++) {
buf[i] = Math.floor(Math.random()*256);
}
}
}
};
require([
"jasmine-console-reporter",
"jasmine-junit-reporter",
"console-runner",
"spec/converse",
"spec/otr",
"spec/eventemitter",
@ -82,19 +72,19 @@ require([
// Jasmine stuff
var jasmineEnv = jasmine.getEnv();
var reporter;
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;
} 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) {
return htmlReporter.specFilter(spec);
return reporter.specFilter(spec);
};
jasmineEnv.updateInterval = 100;
jasmineEnv.updateInterval = 0;
}
jasmineEnv.execute();
});