babel-plugin-rewire
babel-plugin-rewire copied to clipboard
Karma&Browserify with config object does not work.
Hey, I have a karma.conf.js with the following content:
var babelPluginRewire = require('babel-plugin-rewire');
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../../',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['browserify', 'jasmine'],
[...]
browserify: {
debug: true,
plugin: ['tsify'],
transform: [['babelify', {plugins: [babelPluginRewire]}], ['stringify', {extensions: ['*.json']}]]
},
[...]
and I do not get any RewireApi object in my tests (the following test fails):
import React from 'react';
describe('rewire', () => {
it('works', () => {
expect(React.__RewireApi__).toBeDefined();
});
});
Can you help me with this?
Thanks for reporting this Bug and the Delay on this issue but I am currently on holidays and will return on the 23rd of november. I will comment on this Bug as soon as I will return.
Hi! Is there any updates on this issue?
After adding plugin to karma configs:
...
browserify: {
debug: true,
plugins: ['tsify'],
transform: [['babelify', {plugins: ['rewire']}], 'reactify']
},
...
I get following error for all tests' files:
ERROR [framework.browserify]: TypeError: /path_to_file.js: Property id of FunctionDeclaration expected node to be of a type ["Identifier"] but instead got null while parsing file: /path_to_file.js
@VoloshinS sorry haven't looked into it till now. fighting with babel 6 at the moment...