Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Andrew Throener
    @trainerbill
    but I am writing tests for it so I kinda need it in there...
    Andrew Throener
    @trainerbill
    @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
    @TheSavior
    Truthfully, I’m not sure
    Andrew Throener
    @trainerbill
    just spit balling to try and get a resolution so they can fix it faste
    speedskater
    @speedskater
    @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
    @jasonenglish
    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.
    speedskater
    @speedskater
    @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
    @jasonenglish
    @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?
    speedskater
    @speedskater
    @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
    @jasonenglish
    @speedskater I think it might, I'll try doing that. thanks!
    Richard Marks
    @RichardMarks

    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
    there
    Gavri (Gabriel) Guy
    @gavriguy
    I tried to search for it but couldn’t get a clear answer - is there a way to rewire an es6 class instance method?
    speedskater
    @speedskater
    @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
    @TheSavior
    @speedskater Thank you very much!
    Robert Stiff
    @uatec
    greetings
    speedskater
    @speedskater
    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
    @dtothefp
    having issues with dynamic require in es6 file yelling that require is undefined
    //entry.js
    import thingToRewire from './thing'
    
    //thing.js
    export default thing () {
      require('./stuff')
    }
    speedskater
    @speedskater
    @dtothefp can you provide a sample project with your exact configuration?
    @/all published 1.0.0-rc-4
    Vincent Schramer
    @scvnc
    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
    @havenchyk
    Hi there! Is it possible to mock out the import from imported component?

    e.g.

    MyComponent.jsx has import someCoolFunctionThatShouldBeMocked

    Tom Rosier
    @tomrosier
    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
    @chrisbraddock
    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
    @chrisbraddock
    ^ I've used vue-templates webpack as a starting point so isparta is involved
    Navid
    @navid_pandesh_twitter
    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?
    Navid
    @navid_pandesh_twitter
    --stage 1
    Marc
    @reposman33
    Can I use Babel-rewire-plugin when I run a Mocha test from IntelliJ?
    Roy Mor
    @Kashio

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

    const map = {
     a,
     b,
     c
    };
    function run(options)  {
     map[options.val]();
    }
    function a() {...}
    function b() {...}
    function c() {...}

    a.spec.js

    import { a, __RewireAPI__ as ARewireAPI } from './a';
    
    describe('a', () => {
      describe('run', () => {
        const spy= jasmine.createSpy('spy').and.callFake(() => {
          ...
        });
        beforeEach(() => {
          ARewireAPI.__Rewire__('b', spy);
        });
        afterEach(() => {
          TooltipRewireAPI.__ResetDependency__('b');
        });
        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
    @Claire
    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
    @Claire
    Oh I see it's already reported as an issue speedskater/babel-plugin-rewire#109 ; but it's not fixed yet.
    bradjohnwoods
    @bradjohnwoods
    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 ?
    bradjohnwoods
    @bradjohnwoods
    ignore that, needed to add a plugins key to my babel.rc file
    Brandon Ramsey
    @brandonramsey
    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’
    etc...
    Bruno Teixeira
    @bmfteixeira_twitter
    hey guys?
    anyone there*
    ?
    John Wolfe
    @wolfejw86
    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?
    WangYan
    @clownvary
    emmm, no one
    Boltmerz
    @Boltmerz
    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:
    https://stackoverflow.com/questions/55911777/babel-plugin-rewire-get-mock-call-count