Mocking reaction components ES6

I am trying to make fun of a dependency on one of my ES6 React components, but I think that at the moment I really am at a standstill. I researched google options, probably in two hours, but none of the solutions work, and I think I have exhausted all the options. The last decision I made, "babel-preset-rewire", seemed to be the most promising, but it threw an error even when I was tracking documents in T. Here is my attempt to use this babel plugin, but I am also open to other mocking options.

.babelrc

{ "plugins": ["rewire"], "presets": ["es2015", "react", "stage-0"] } 

Spec

 import { SignUp } from './signUp'; SignUp.__Rewire__('TopBarContainer', class TopBarMock { render() { return (<div></div>); } }); 

This is not even a React.Component extension, but the goal was just to get something basic. I can’t even get the Rewire function to be exported together with the module ... When I try to run the above code, I get the following error message:

TypeError: _get __ (...). Rewire is not a function

+5
source share

Source: https://habr.com/ru/post/1239329/


All Articles