-
-
Save nim23/fc22fb7a6e50162d3afa61d52424545c to your computer and use it in GitHub Desktop.
'use strict' | |
let wallabify = require('wallabify') | |
let babelify = require('babelify') | |
let babel = require('babel') | |
let es6ToEs5Preprocessor = file => babel | |
.transform(file.content, {sourceMap: true, filename: file.path, stage: 2}) | |
let wallabyPostProcessor = wallabify({ | |
entryPatterns: ['./src/**/*.spec.js'] | |
}, | |
function (b) { | |
b.transform(babelify, { | |
extensions: ['.jsx', '.js'] | |
}) | |
}) | |
module.exports = function (wallaby) { | |
return { | |
files: [ | |
{pattern: 'node_modules/babel-polyfill/dist/polyfill.js', instrument: false}, | |
{pattern: 'src/utils/karma.polyfill.js', instrument: false}, | |
{pattern: 'src/**/*.js', load: false}, | |
{pattern: 'src/**/*.jsx', load: false}, | |
{pattern: 'src/**/*.json', instrument: false}, | |
{pattern: 'src/**/*.spec.js', ignore: true} | |
], | |
tests: [ | |
{pattern: './src/**/*.spec.js', load: false} | |
], | |
postprocessor: wallabyPostProcessor, | |
testFramework: 'jasmine', | |
setup: function () { | |
// required to trigger tests loading | |
window.__moduleBundler.loadTests() | |
}, | |
preprocessors: { | |
'src/**/*.js': es6ToEs5Preprocessor, | |
'src/**/*.spec.js': es6ToEs5Preprocessor, | |
'src/**/*.jsx': es6ToEs5Preprocessor | |
}, | |
compilers: { | |
'src/**/*.js': wallaby.compilers.babel({ | |
stage: 2 | |
}), | |
'src/**/*.spec.js': wallaby.compilers.babel({ | |
stage: 2 | |
}), | |
'src/**/*.jsx': wallaby.compilers.babel({ | |
stage: 2 | |
}) | |
}, | |
debug: true | |
} | |
} |
@ArtemGovorov Thanks for the reply. Wallabify/Browserify now complains about not finding a particular module [my guess something to do with entry patterns]. The project is based off of this boilerplate https://github.com/MadeInHaus/react-flux-gulp-starter. The test files sit right next to source file in current project setup.
let wallabyPostProcessor = wallabify({
entryPatterns: ['./src/client.js']
})
This here fixes the error but 0 test's are actually run which has been baffling me since yesterday.
@nim23
As specified in the docs, when using entryPatterns
, you also have to list your tests
pattern, so it should be:
let wallabyPostProcessor = wallabify({
entryPatterns: ['src/client.js', 'src/**/*.spec.js']
})
Also don't use the ./
anywhere in your config.
If it doesn't help, I'll need a sample repo where I could reproduce the issue.
Also, are you using babel 5? I'm asking about the babel version because the boilerplate project you have referenced is using Babel 6. But you have configured your wallaby babel compiler as you are using babel 5 (passing stage: 2
). If you are using babel 6 and you have .babelrc
file, you need just this: compilers: {'src/**/*.js*': wallaby.compilers.babel()}
(or pass correct babel 6 options, like presets
, etc.).
@ArtemGovorov the project uses babel 5 and is shrink-wrapped. Unfortunately the boilerplate has since moved ahead and updated to babel 6. I will try to put up a sample repo with exactly the same setup my as my environment and ping you. Sorry about the confusion.
@nim23 Github doesn't send out notifications for being mentioned in a gist, so please share the link to the sample repo by creating an issue in our repo.
A few things you have are duplicating each other or not required. Here is the simplified version: