Skip to content

Commit

Permalink
make react-native mock optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Doron Pearl committed Jan 3, 2019
1 parent f38da7a commit b33b669
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/base-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class BaseDriver {

render(props) {
if (!this._component) {
const ComponentModule = require("proxyquire").noCallThru()(this.path, {...this.mocks});
const ComponentModule = this.mocks ? require("proxyquire").noCallThru()(this.path, {...this.mocks}) : require(this.path);
this._component = this.commonjs ? ComponentModule : ComponentModule[this.targetImport];
}
this.component = shallow(<this._component {...props}/>);
Expand Down
5 changes: 3 additions & 2 deletions src/rn-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import BaseDriver from './base-driver';

export default class RNDriver extends BaseDriver {

constructor({mocks, isRelativePathFromRoot = true, rootFolder = 'src/', ...props}) {
super({mocks: {'react-native': React, ...mocks}, isRelativePathFromRoot, rootFolder, ...props});
constructor({mocks, isRelativePathFromRoot = true, mockReactNative = true, rootFolder = 'src/', ...props}) {
const _mocks = mockReactNative ? {'react-native': React, ...mocks} : mocks;
super({mocks: _mocks, isRelativePathFromRoot, rootFolder, ...props});
}

getStylesByTestId(testId) {
Expand Down

0 comments on commit b33b669

Please sign in to comment.