Browser test runner

This commit is contained in:
Thomas Aylott 2013-10-28 14:54:37 -04:00
parent 001bda28d9
commit c4ba8f8997
3 changed files with 41 additions and 0 deletions

27
test/browser-runner.js Normal file
View File

@ -0,0 +1,27 @@
;(function(){
var __filename = (function(){
var scripts = document.getElementsByTagName('script');
var a = document.createElement('a');
a.href = scripts[scripts.length-1].src;
return a.pathname;
}());
var __dirname = __filename.split('/').reverse().slice(1).reverse().join('/');
document.head.appendChild(function(){
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = __dirname + '/../vendor/jasmine/jasmine.css';
return link;
}());
var cacheBust = '?_=' + Date.now().toString(36);
document.write('<script src="' + __dirname + '/../build/jasmine.js' + cacheBust + '"><\/script>');
document.write('<script src="' + __dirname + '/../build/react.js' + cacheBust + '"><\/script>');
document.write('<script src="' + __dirname + '/../build/react-test.js' + cacheBust + '"><\/script>');
document.write('<script src="' + __dirname + '/../test/the files to test.generated.js' + cacheBust + '"><\/script>');
document.write('<script src="' + __dirname + '/../test/jasmine-execute.js' + cacheBust + '"><\/script>');
}());

3
test/browser.html Normal file
View File

@ -0,0 +1,3 @@
<!doctype html>
<meta charset=utf-8>
<script src="browser-runner.js"></script>

11
test/jasmine-execute.js Normal file
View File

@ -0,0 +1,11 @@
;(function(env){
// Clean up any nodes the previous test might have added.
env.afterEach(function() {
harness.removeNextSiblings(document.body);
harness.removeNextSiblings(document.getElementById("HTMLReporter"));
});
window.onload = function(){
env.execute();
}
})(jasmine.getEnv());