Skip to content

Commit

Permalink
Browser test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
subtleGradient committed Nov 6, 2013
1 parent 001bda2 commit c4ba8f8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/browser-runner.js
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions test/browser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!doctype html>
<meta charset=utf-8>
<script src="browser-runner.js"></script>
11 changes: 11 additions & 0 deletions test/jasmine-execute.js
Original file line number Diff line number Diff line change
@@ -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());

0 comments on commit c4ba8f8

Please sign in to comment.