]> git.wincent.com - hextrapolate.git/commitdiff
Add standard test tools
authorGreg Hurrell <greg@hurrell.net>
Fri, 31 Jul 2015 13:32:55 +0000 (06:32 -0700)
committerGreg Hurrell <greg@hurrell.net>
Fri, 31 Jul 2015 13:39:31 +0000 (06:39 -0700)
mocha/bootstrap.js [new file with mode: 0644]
mocha/mocha.opts [new file with mode: 0644]
mocha/watch-reporter.js [new file with mode: 0644]
package.json
src/__mocks__/stub.js [new file with mode: 0644]
src/__tests__/stub-test.js [new file with mode: 0644]

diff --git a/mocha/bootstrap.js b/mocha/bootstrap.js
new file mode 100644 (file)
index 0000000..a6239ac
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * Copyright 2015-present Greg Hurrell. All rights reserved.
+ * Licensed under the terms of the MIT license.
+ */
+
+require('babel/polyfill');
+
+var fs = require('fs');
+var path = require('path');
+
+process.on('unhandledRejection', function(reason, promise) {
+  throw reason;
+});
+
+global.expect = require('expect');
+
+require('babel/register')(
+  JSON.parse(
+    fs.readFileSync(
+      path.join(__dirname, '..', '.babelrc')
+    )
+  )
+);
diff --git a/mocha/mocha.opts b/mocha/mocha.opts
new file mode 100644 (file)
index 0000000..d11d13a
--- /dev/null
@@ -0,0 +1,3 @@
+--require mocha/bootstrap
+--recursive
+--reporter list
diff --git a/mocha/watch-reporter.js b/mocha/watch-reporter.js
new file mode 100644 (file)
index 0000000..f9ddc20
--- /dev/null
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2015-present Greg Hurrell. All rights reserved.
+ * Licensed under the terms of the MIT license.
+ */
+
+var Base = require('mocha').reporters.Base;
+
+/**
+ * Like the "min" reporter that comes with Mocha[0], but doesn't clear the
+ * screen.
+ *
+ * @see https://github.com/mochajs/mocha/blob/master/lib/reporters/min.js
+ * @see https://github.com/mochajs/mocha/wiki/Third-party-reporters
+ */
+function WatchReporter(runner) {
+  var self = this;
+  Base.call(this, runner);
+  runner.on('end', function() {
+    if (this.stats.failures) {
+      Base.prototype.epilogue.call(self);
+    }
+  });
+}
+
+module.exports = WatchReporter;
index cd36e2dc7bd71d30fcd2a1b536f35d3237c1d3bc..ae91d9d50f3430b42e98e6f6f064b1a7de2b65b6 100644 (file)
@@ -3,8 +3,9 @@
   "version": "1.0.0",
   "description": "Boilerplate for ReactJS project with hot code reloading",
   "scripts": {
+    "lint": "eslint src",
     "start": "node server.js",
-    "lint": "eslint src"
+    "test": "mocha --opts mocha/mocha.opts 'src/**/__mocks__/*.js' 'src/**/__tests__/*-test.js'"
   },
   "repository": {
     "type": "git",
   },
   "homepage": "https://github.com/gaearon/react-hot-boilerplate",
   "devDependencies": {
+    "babel": "^5.8.19",
     "babel-core": "^5.4.7",
     "babel-eslint": "^3.1.9",
     "babel-loader": "^5.1.2",
     "eslint-plugin-react": "^2.3.0",
+    "expect": "^1.8.0",
+    "mocha": "^2.2.5",
     "react-hot-loader": "^1.2.7",
+    "sinon": "^1.15.4",
     "webpack": "^1.9.6",
     "webpack-dev-server": "^1.8.2"
   },
diff --git a/src/__mocks__/stub.js b/src/__mocks__/stub.js
new file mode 100644 (file)
index 0000000..ee41022
--- /dev/null
@@ -0,0 +1 @@
+// TODO: replace with actual mock files
diff --git a/src/__tests__/stub-test.js b/src/__tests__/stub-test.js
new file mode 100644 (file)
index 0000000..058ace2
--- /dev/null
@@ -0,0 +1 @@
+// TODO: replace with actual test files