From f3ae01186b8de45f5660754769c9aa66ed830940 Mon Sep 17 00:00:00 2001 From: Jordan Scales Date: Thu, 23 Jul 2015 10:33:17 -0400 Subject: [PATCH] include mocha fixes to run babel+JSX --- package.json | 2 +- test/babel-hook.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/babel-hook.js diff --git a/package.json b/package.json index a6f20e1d..b07af0ed 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "prod": "webpack -p", "dev": "webpack -d --devtool hidden --output-file=tota11y.js", "lint": "eslint index.js plugins test", - "test": "mocha --compilers js:babel/register test/*.js", + "test": "mocha --require test/babel-hook test/*.js", "live-test": "webpack-dev-server --hot --inline" }, "license": "MIT" diff --git a/test/babel-hook.js b/test/babel-hook.js new file mode 100644 index 00000000..c9e647fc --- /dev/null +++ b/test/babel-hook.js @@ -0,0 +1,14 @@ +/** + * A mocha hook that will run before each test. + * + * This sets up babel with options, and stores our JSX transpile target. + */ + +// Register all future "require"s with babel +require("babel/register")({ + // Let babel know to transpile JSX into E(...) + jsxPragma: "E", +}); + +// Store our custom JSX transpile target as a global +E = require("../element.js");