index.js 889 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var fs = require('fs');
  2. var test = require('../')
  3. , runTests = test.runTests
  4. , load = test.load;
  5. var express = require('express')
  6. , app = express();
  7. app.use(function(req, res, next) {
  8. var setHeader = res.setHeader;
  9. res.setHeader = function(name) {
  10. switch (name) {
  11. case 'Cache-Control':
  12. case 'Last-Modified':
  13. case 'ETag':
  14. return;
  15. }
  16. return setHeader.apply(res, arguments);
  17. };
  18. next();
  19. });
  20. var dir = __dirname + '/../tests'
  21. , files = {};
  22. app.get('/test.js', function(req, res, next) {
  23. var test = fs.readFileSync(__dirname + '/test.js', 'utf8')
  24. , files = load();
  25. test = test.replace('__TESTS__', JSON.stringify(files));
  26. test = test.replace('__MAIN__', runTests + '');
  27. res.contentType('.js');
  28. res.send(test);
  29. });
  30. app.use(express.static(__dirname + '/../../lib'));
  31. app.use(express.static(__dirname));
  32. app.listen(8080);