Comments (9)
Note that my setup.js
file for mocha already denotes pre-transpilation of this package with Babel before running the test, yet it still fails.
// setup.js
import fs from 'fs';
import path from 'path';
import register from 'babel-core/register';
// Ignore all node_modules except these
const modulesToCompile = [
'@exponent/ex-navigation',
'react-clone-referenced-element',
'react-native',
'react-native-material-design',
'react-native-mock',
].map((moduleName) => new RegExp(`/node_modules/${moduleName}`));
const rcPath = path.join(__dirname, '../../../..', '.babelrc');
const source = fs.readFileSync(rcPath).toString();
const config = JSON.parse(source);
config.ignore = (filename) => {
if ((/\/node_modules\//).test(filename)) {
const matches = modulesToCompile.filter((regex) => regex.test(filename));
const shouldIgnore = matches.length === 0;
return shouldIgnore;
}
return false;
};
register(config);
// Setup mocks
require('react-native-mock/mock');
from ex-navigation.
Update: I've isolated the failures to components that use the @withNavigation
decorator. There needs to be a way to mock this somehow for the tests, but I'm not sure how.
import { connect } from 'react-redux';
import { withNavigation } from '@exponent/ex-navigation';
@withNavigation
export class TheComponent extends Component {
...
}
export default connect(mapStateToProps, mapDispatchToProps)(TheComponent);
Update 2: I lied.
After doing some more debugging, I've come to the conclusion that pretty much every exportable by this library seems to cause the transpile error.
import { StackNavigation } from '@exponent/ex-navigation';
import { withNavigation } from '@exponent/ex-navigation';
import { createRouter } from '@exponent/ex-navigation';
from ex-navigation.
Theoretically this issue would be resolved if we could connect to ex-navigation's redux store, as that would eliminate the need for Not necessarily true per Update 2 above.@withNavigation
altogether.
from ex-navigation.
@joncursi is there any way you could provide a small example repo that isolates this case? we don't use mocha @ exponent, so it's difficult for me to test this without code
from ex-navigation.
@joncursi did u solve ur issue?
from ex-navigation.
This did the trick for me to run my mocha tests again after installing @exponent/ex-navigation
:
mockery.registerMock('@exponent/ex-navigation', {
createRouter: () => {},
});
Not fully published yet, but see this other issue for more info.
from ex-navigation.
I think https://github.com/lelandrichardson/react-native-mock provides a lot of mocked versions of the component
Otherwise, jest automock all the component itself, making in much easier to test
from ex-navigation.
Agreed, however lelandrichardson/react-native-mock
only mocks react-native
core native modules, not third party libraries, and yes, while Jest has become really nice to work with thanks to its handy mocking feature, you can't alway make the switch from your testing library (Mocha in this case).
from ex-navigation.
there are some really good codemods to help in this case
https://github.com/skovhus/jest-codemods
from ex-navigation.
Related Issues (20)
- turn caching off for some pages HOT 1
- error code 404 , it crashes upon scanning of QR.
- Compatibility with RN 0.47 HOT 2
- how to do change toolbar color with drawer
- Large gap on nav bar header on Android HOT 5
- Android back button navigation pop does not trigger onWillChangeTab
- importing NavigationProvider throws undefined is not an object (evaluating PropTypes.shape in NavigationPropTypes.js:30:26) HOT 10
- Styling the default back button on the left side of the navbar HOT 1
- @expo/ex-navigation > [email protected] has incorrect peer dependency "react@^0.13.0 || ^0.14.0 || ^15.0.0 || ^16.0.0".
- Version 4.0
- tiveart HOT 1
- TypeError: undefined is not an object (evaluating 'navigationState.navigators')
- expo does not support NavigatorIOS ?
- Use react-navigation instead of expo/ex-navigation
- How To Hide TabBar on Particular Screen Using Expo/ex-navigation
- Unmount TabItem in TabNavigation
- Support for the experimental syntax 'exportNamespaceFrom' isn't currently enabled HOT 3
- Issue with babel 7 HOT 1
- [question] Pop to root [solved]
- UnhandledPromiseRejectionWarning: UnableToResolveError: Unable to resolve module @exponent/ex-navigation from
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ex-navigation.