Skip to content

Commit

Permalink
Render main test suite as root resource of test server
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Jan 13, 2016
1 parent 667995f commit b043384
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
15 changes: 13 additions & 2 deletions script/phantomjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,16 @@ node ./script/server $port &>/dev/null &
server_pid=$!
trap "kill $server_pid" INT EXIT

node ./node_modules/.bin/mocha-phantomjs -s localToRemoteUrlAccessEnabled=true -s webSecurityEnabled=false "http://localhost:$port/test/test.html"
node ./node_modules/.bin/mocha-phantomjs -s localToRemoteUrlAccessEnabled=true -s webSecurityEnabled=false "http://localhost:$port/test/test-worker.html"
STATUS=0

run() {
node ./node_modules/.bin/mocha-phantomjs \
-s localToRemoteUrlAccessEnabled=true \
-s webSecurityEnabled=false \
"$@" || STATUS=$?
}

run "http://localhost:$port/"
run "http://localhost:$port/test/test-worker.html"

exit $STATUS
2 changes: 1 addition & 1 deletion script/saucelabs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ job="$(./script/saucelabs-api --raw "js-tests" <<JSON
"tags": ["$TRAVIS_PULL_REQUEST", "$TRAVIS_BRANCH"],
"tunnel-identifier": "$TRAVIS_JOB_NUMBER",
"platforms": [["$SAUCE_PLATFORM", "$SAUCE_BROWSER", "$SAUCE_VERSION"]],
"url": "http://localhost:$port/test/test.html",
"url": "http://localhost:$port/",
"framework": "mocha"
}
JSON
Expand Down
1 change: 1 addition & 0 deletions script/server
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ server = http.createServer(function(req, res) {
if (route) {
route(res, req);
} else {
if (pathname == '/') pathname = '/test/test.html'
fs.readFile(__dirname + '/..' + pathname, function(err, data) {
if (err) {
res.writeHead(404, {'Content-Type': types.txt});
Expand Down
6 changes: 3 additions & 3 deletions test/test-worker.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<head>
<meta charset="utf-8">
<title>Fetch Worker Tests</title>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script src="/node_modules/mocha/mocha.js"></script>

<script>
mocha.setup('tdd')

var worker = new Worker('worker.js')
var worker = new Worker('/test/worker.js')

worker.addEventListener('message', function(e) {
switch (e.data.name) {
Expand Down
13 changes: 6 additions & 7 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
<head>
<meta charset="utf-8">
<title>Fetch Tests</title>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="../node_modules/chai/chai.js"></script>
<script src="../node_modules/mocha/mocha.js"></script>
<script src="/node_modules/chai/chai.js"></script>
<script src="/node_modules/mocha/mocha.js"></script>
<script>
mocha.setup('tdd')
self.assert = chai.assert
</script>

<script src="../bower_components/es6-promise/promise.js"></script>
<script src="../fetch.js"></script>

<script src="test.js"></script>
<script src="/bower_components/es6-promise/promise.js"></script>
<script src="/test/test.js"></script>
<script src="/fetch.js"></script>

<script>
if (self.mochaPhantomJS) {
Expand Down
11 changes: 5 additions & 6 deletions test/worker.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
importScripts('../node_modules/chai/chai.js')
importScripts('../node_modules/mocha/mocha.js')
importScripts('/node_modules/chai/chai.js')
importScripts('/node_modules/mocha/mocha.js')

mocha.setup('tdd')
self.assert = chai.assert

importScripts('../bower_components/es6-promise/promise.js')
importScripts('../fetch.js')

importScripts('test.js')
importScripts('/bower_components/es6-promise/promise.js')
importScripts('/test/test.js')
importScripts('/fetch.js')

function title(test) {
return test.fullTitle().replace(/#/g, '');
Expand Down

0 comments on commit b043384

Please sign in to comment.