Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

generate build artifacts from bundled test files

Christopher Hiller03464ff0c023
diff --git a/.gitignore b/.gitignore
index e36f1097..cc194250 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ lib/browser/diff.js
*.diff
npm-debug.log*
.envrc
+.karma/
diff --git a/karma.conf.js b/karma.conf.js
index a1484831..47867de1 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -1,6 +1,13 @@
'use strict';
+var fs = require('fs');
+var path = require('path');
+var mkdirp = require('mkdirp');
+var bundleDirpath = path.join(__dirname, '.karma');
+
module.exports = function(config) {
+ mkdirp.sync(bundleDirpath);
+
var cfg = {
frameworks: [
'browserify',
@@ -25,9 +32,20 @@ module.exports = function(config) {
debug: true,
configure: function configure(b) {
b.ignore('glob')
- .ignore('jade')
+ .ignore('pug')
.ignore('supports-color')
- .exclude('./lib-cov/mocha');
+ .exclude('./lib-cov/mocha')
+ .on('bundled', function (err, content) {
+ var filepath = path.join(bundleDirpath,
+ 'bundle.' + Date.now() + '.js');
+ if (!err) {
+ fs.writeFile(filepath, content, function (err) {
+ if (!err) {
+ console.error('Wrote test bundle to ' + filepath);
+ }
+ });
+ }
+ });
}
},
reporters: ['spec'],
diff --git a/package.json b/package.json
index f2ad7289..470f33f5 100644
--- a/package.json
+++ b/package.json
@@ -343,6 +343,7 @@
"karma-phantomjs-launcher": "^0.2.3",
"karma-sauce-launcher": "^1.0.0",
"karma-spec-reporter": "0.0.26",
+ "mkdirp": "^0.5.1",
"phantomjs": "1.9.8",
"should": "^9.0.2",
"through2": "^2.0.1",