Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Andrew Throener
    but I am writing tests for it so I kinda need it in there...
    Andrew Throener
    @TheSavior So when I just do a straight build should i not see the __noRewire somewhere? It seems like that is what prevents the plugin from trying to rewire again... but on my builds I am not seeing it anywhere.
    Eli White
    Truthfully, I’m not sure
    Andrew Throener
    just spit balling to try and get a resolution so they can fix it faste
    @trainerbill Can you provide your sample file in a PR (similar to the existing samples) ?
    Regarding the wildcard import. This is intentional. The reason is by allowing to import the rewire to exist on a wildcard import it may break existing code. E.g. it would be possible another module using your module expectes that only certain functions or objects are exported and breaks on the rewiring api. But you can use a named import to get to the API.
    Jason English
    Does rewire work with external libs? I'm able to get it to work with my existing modules, but when trying to rewire a lib I import, none of the rewire api exists.
    @jasonenglish Theoretically if you transform the code of the external library it should work as well. What is your reason to do this?
    Jason English
    @speedskater jasmine unit tests where it expects that the method is called with the correct arguments
    @speedskater is there a better practice for testing function calls from external libraries?
    @jasonenglish Maybe. Assume you want to test your module A, which has a dependency to module B, where B is an external module. In this case you only have to transform module A because. By transforming module A you are able to rewire the dependencies to methods of B within A. This allows you to track and spy on the external calls. Does this answer your question?
    Jason English
    @speedskater I think it might, I'll try doing that. thanks!
    Richard Marks

    I am trying to get babel-plugin-rewire@1.0.0-rc-2 to work on a babel 6 karma mocha webpack setup, and I have followed the instructions in the readme, and I am ending up with the following error

    Uncaught TypeError: Cannot read property 'Rewire' of undefined

    Any advice/assistance would be most appreciated

    that is double underscore Rewire double underscore ... gitter interpreted it as markdown oops
    Uncaught TypeError: Cannot read property '__Rewire__' of undefined
    Gavri (Gabriel) Guy
    I tried to search for it but couldn’t get a clear answer - is there a way to rewire an es6 class instance method?
    @RichardMarks do you have a sample for your problem?
    @gavriguy rewireing only instance methods is not possible. But you can rewire the class itself.
    @TheSavior a new version rc-3 is out there with your PR.
    @/all I will again have a look at some issues on the upcoming monday.
    Eli White
    @speedskater Thank you very much!
    Robert Stiff
    Hi. And sorry to everybody for the delays. I was quite busy due to a release at my company. I will be on hollidays for the upcoming two weeks and will try to work on issues and PR in the week starting at Monday June 27th.
    David Fox-Powell
    having issues with dynamic require in es6 file yelling that require is undefined
    import thingToRewire from './thing'
    export default thing () {
    @dtothefp can you provide a sample project with your exact configuration?
    @/all published 1.0.0-rc-4
    Vincent Schramer
    Sort of unrelated discussion: I really enjoy the testing patterns that rewire enables.. does anyone know about some strategies for applying it to TypeScript? Is there a way to use this with TypeScript or some typescript-plugin-rewire equivalent?
    Uladzimir Havenchyk
    Hi there! Is it possible to mock out the import from imported component?


    MyComponent.jsx has import someCoolFunctionThatShouldBeMocked

    Tom Rosier
    has anyone seen this error before Warning: [BABEL] src/file_parser.es6: Unknown option: foreign.visitor. Check out http://babeljs.io/docs/usage/options/ for more info Use --force to continue.
    Chris Braddock
    I need some help getting Rewire working. I think it may be at least being included as a plugin now, but I can't say for sure. I can tell it's doing something now because when I enable the plugin I see in my test output: PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR LOG: 'named exports are not supported in *.vue files.' however, I do not see any __RewireAPI__ being added to exports in my test files :(
    Chris Braddock
    ^ I've used vue-templates webpack as a starting point so isparta is involved
    hi all, i found project and cant start it, i use nodemon --exec babel -- --stage 1 --optional strict -- index.js, but there are error "Error: Cannot find module '/home/wq/rozum2/1'" i think that the reason is in babel, what can be wrong?
    --stage 1
    Can I use Babel-rewire-plugin when I run a Mocha test from IntelliJ?
    Roy Mor

    How can I spy on a function that is references from an object? Example:

    const map = {
    function run(options)  {
    function a() {...}
    function b() {...}
    function c() {...}


    import { a, __RewireAPI__ as ARewireAPI } from './a';
    describe('a', () => {
      describe('run', () => {
        const spy= jasmine.createSpy('spy').and.callFake(() => {
        beforeEach(() => {
          ARewireAPI.__Rewire__('b', spy);
        afterEach(() => {
        it('calls b()', () => {
          a.run({val: 'b'}); // doesn't call the spy because what actually being called is the reference from the map object
    Claire Martinez
    has anyone had any luck running the 1.x version of the require plugin with karma/jasmine on Phantomjs? its working on Chrome but not Phantomjs for me.
    I get errs like TypeError: 'undefined' is not a function (evaluating '_get__('AGGrid').__ResetDependency__('AgGridReact')') at :322
    Claire Martinez
    Oh I see it's already reported as an issue speedskater/babel-plugin-rewire#109 ; but it's not fixed yet.
    hey guys, i’m trying to do a simple rewire and I get this error: TypeError: _photoImgFileHandler$2.default.Rewire is not a function
    is there another requirements other than installing babel-plugin-rewire through npm ?
    ignore that, needed to add a plugins key to my babel.rc file
    Brandon Ramsey
    I feel like I’m doing something wrong — When I put babel-plugin-rewire into place, all of my imports into my tested files start failing. I saw the ignoredIdentifiers config option — Am I supposed to ignore everything that is imported into all of my tested files? Some of my imports look like:
    import {Map} from ‘immutable’
    import {flatMap} from ‘lodash’
    Bruno Teixeira
    hey guys?
    anyone there*
    John Wolfe
    good morning, i have a question. is it possible to use ES6 promises without module bundling when using babel through gulp on my js files?
    emmm, no one
    Hello, Everyone, I want to ask is there a way to get the mocked function details like returned values and args in babel-plugin-rewire?
    Please see this link: