commit 70ab34162736cb36d47f12b5d111f7cc9f14e713
parent 214e424789f433a4906d9e13b8c0f17d8377f505
Author: Konstantin Tarkus <hello@tarkus.me>
Date: Mon, 9 Feb 2015 22:53:48 +0300
Fix Jest configuration. Closes #64
Diffstat:
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/package.json b/package.json
@@ -65,7 +65,7 @@
},
"jest": {
"rootDir": "./src",
- "scriptPreprocessor": "../node_modules/6to5-jest",
+ "scriptPreprocessor": "../preprocessor.js",
"unmockedModulePathPatterns": [
"react"
]
diff --git a/preprocessor.js b/preprocessor.js
@@ -0,0 +1,19 @@
+'use strict';
+
+var to5 = require('6to5-core');
+
+module.exports = {
+ process: function(src, filename) {
+ // Ignore files other than *.js and *.jsx
+ var ext = filename.split('.').pop();
+ if (!/\.jsx?$/i.test(filename)) {
+ return '';
+ }
+ // Ignore all files within node_modules
+ // 6to5 files can be .js, .es, .jsx or .es6
+ if (filename.indexOf('node_modules') === -1 && to5.canCompile(filename)) {
+ return to5.transform(src, { filename: filename }).code;
+ }
+ return src;
+ }
+};