Create a gist now

Instantly share code, notes, and snippets.

@yleflour /wallaby.js
Last active Jul 22, 2016

Wallaby + React Native
/*
WallabyJS React Native Config
Works well with Mocha + Chai + Enzyme + React Native Mock
*/
/* eslint-disable */
var path = require('path');
module.exports = (wallaby) => ({
files: [
'src/**/*.js',
'!src/**/*.spec.js',
],
tests: [
'src/**/*.spec.js',
],
debug: true,
compilers: {
'**/*.js': wallaby.compilers.babel({
babelrc: false,
retainLines: true,
compact: true,
comments: false,
presets: ['react-native'],
plugins: 'transform-object-rest-spread',
sourceMaps: true
}),
},
env: {
type: 'node',
},
setup: () => {
// if some of your imported modules need to be transpiled
require("babel-register")({
only: [
/module1/,
/module2/,
],
retainLines: true,
compact: true,
comments: false,
presets: ['react-native'],
plugins: ['transform-object-rest-spread'],
sourceMaps: true
});
// if you require mocks
require('react-native-mock/mock.js');
// allow image import with mocha
require('mocha-image-compiler');
// if you use React Native global import
var path = require('path');
var Module = require('module').Module;
if (!Module._originalRequire) {
var modulePrototype = Module.prototype;
Module._originalRequire = modulePrototype.require;
modulePrototype.require = function (filePath) {
var pathParts = filePath.split('/');
var root = pathParts.shift();
if (root === 'PROJECT_NAME') { // <== Add your project name
return Module._originalRequire.call(
this,
path.join(wallaby.projectCacheDir, pathParts.join('/'))
);
}
return Module._originalRequire.call(this, filePath);
};
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment