-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from derbyjs/update-test-deps
expect.js => chai & use browserify to bundle
- Loading branch information
Showing
6 changed files
with
43 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Derby Tests</title> | ||
<link rel="stylesheet" href="/mocha.css"> | ||
|
||
<body> | ||
|
||
<div id="mocha"></div> | ||
<script src="/mocha.js"></script> | ||
<script>mocha.setup('bdd')</script> | ||
|
||
<script src="/test.js"></script> | ||
|
||
<script> | ||
mocha.checkLeaks(); | ||
mocha.run(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,21 @@ | ||
var finalhandler = require('finalhandler'); | ||
var http = require('http'); | ||
var path = require('path'); | ||
var serveStatic = require('serve-static'); | ||
var browserify = require('browserify'); | ||
var express = require('express'); | ||
|
||
var expressApp = express(); | ||
expressApp.use(express.static(__dirname + '/public')); | ||
expressApp.use(express.static(__dirname + '/../node_modules/mocha')); | ||
|
||
// Default port is 5555. Override it with `PORT=____`, | ||
// or `PORT=0` to let Node pick an unused port. | ||
var port = parseInt(process.env.PORT, 10); | ||
if (!Number.isInteger(port)) { | ||
port = 5555; | ||
} | ||
// The test server only serves to this local machine by default. | ||
// To access it from any other network device, use `HOST=0.0.0.0`, | ||
// but be sure you trust the network you're on. | ||
var bindHost = process.env.HOST || '127.0.0.1'; | ||
|
||
|
||
// Serve files under Saddle's base directory, since test.html | ||
// loads Mocha from node_modules with a relative path. | ||
var serveTestDir = serveStatic(path.dirname(__dirname)); | ||
var server = http.createServer(function onRequest(req, res) { | ||
serveTestDir(req, res, finalhandler(req, res)); | ||
expressApp.get('/test.js', function(req, res, next) { | ||
var bundle = browserify({debug: true}); | ||
bundle.add(__dirname + '/test.mocha.js'); | ||
bundle.bundle(function(err, code) { | ||
if (err) return next(err); | ||
res.type('js'); | ||
res.send(code); | ||
}); | ||
}); | ||
|
||
server.listen(port, bindHost, function(err) { | ||
if (err) { | ||
console.log('Error starting browser test server:', err); | ||
server.close(); | ||
} else { | ||
var testUrl = 'http://127.0.0.1:' + port + '/test/test.html'; | ||
console.log('Test server started on network interface ' + bindHost + '.'); | ||
console.log('\nTo run browser tests, visit this URL:\n'); | ||
console.log(' ' + testUrl); | ||
} | ||
var port = process.env.PORT || 5555; | ||
var server = expressApp.listen(port, function(err) { | ||
console.log('%d listening. Go to: http://localhost:%d/', process.pid, port); | ||
}); |