@samitouri / QOS-React-2 / commits / c4ba8f8997

Browser test runner

Thomas Aylott committed Oct 28, 2013 at 14:54 UTC c4ba8f8997bd228f8fef90c5a5dc47b966fce929
3 files changed +41
test/browser-runner.js new
+27
@@ -0,0 +1,27 @@
1 +;(function(){
2 +
3 + var __filename = (function(){
4 + var scripts = document.getElementsByTagName('script');
5 + var a = document.createElement('a');
6 + a.href = scripts[scripts.length-1].src;
7 + return a.pathname;
8 + }());
9 +
10 + var __dirname = __filename.split('/').reverse().slice(1).reverse().join('/');
11 +
12 + document.head.appendChild(function(){
13 + var link = document.createElement('link');
14 + link.rel = 'stylesheet';
15 + link.href = __dirname + '/../vendor/jasmine/jasmine.css';
16 + return link;
17 + }());
18 +
19 + var cacheBust = '?_=' + Date.now().toString(36);
20 +
21 + document.write('<script src="' + __dirname + '/../build/jasmine.js' + cacheBust + '"><\/script>');
22 + document.write('<script src="' + __dirname + '/../build/react.js' + cacheBust + '"><\/script>');
23 + document.write('<script src="' + __dirname + '/../build/react-test.js' + cacheBust + '"><\/script>');
24 + document.write('<script src="' + __dirname + '/../test/the files to test.generated.js' + cacheBust + '"><\/script>');
25 + document.write('<script src="' + __dirname + '/../test/jasmine-execute.js' + cacheBust + '"><\/script>');
26 +
27 +}());
test/browser.html new
+3
@@ -0,0 +1,3 @@
1 +<!doctype html>
2 +<meta charset=utf-8>
3 +<script src="browser-runner.js"></script>
test/jasmine-execute.js new
+11
@@ -0,0 +1,11 @@
1 +;(function(env){
2 + // Clean up any nodes the previous test might have added.
3 + env.afterEach(function() {
4 + harness.removeNextSiblings(document.body);
5 + harness.removeNextSiblings(document.getElementById("HTMLReporter"));
6 + });
7 +
8 + window.onload = function(){
9 + env.execute();
10 + }
11 +})(jasmine.getEnv());