Comments (7)
Another alternative, for just mocking the Config.FOO
usage:
// __mocks__/react-native-config.js
export default {
FOO_BAR: 'baz',
};
from react-native-config.
I've been able to use this module when testing with mocha by 'simply' adding the following to a file that I require to run tests:
import { NativeModules } from 'react-native';
// http://stackoverflow.com/a/35045012/999076
require('babel-core/register')({
ignore: '/node_modules/(?!Project)/'
});
NativeModules.ReactNativeConfig = {};
from react-native-config.
Hey there!
So sorry for the delay, I'd definitely be down to merge this in to make sure this behaves well with test. Would you be willing to make a stab at a pull request?
Thanks!
from react-native-config.
Closing for now, still open to ideas merging react-native-config-node or just making testing easier here!
from react-native-config.
@phillbaker thank you ! works for me :-)
from react-native-config.
I've been able to use this module when testing with mocha by 'simply' adding the following to a file that I require to run tests:
import { NativeModules } from 'react-native'; // http://stackoverflow.com/a/35045012/999076 require('babel-core/register')({ ignore: '/node_modules/(?!Project)/' }); NativeModules.ReactNativeConfig = {};
jest.doMock('react-native', () => {
// Extend ReactNative
const ReactNative = require.requireActual('react-native');
return Object.setPrototypeOf(
{
// Redefine an export, like a component
NativeModules: {
...ReactNative.NativeModules,
ReactNativeConfig: {
ENV: 'production', // your env key
}
},
Jest -^24.9.0
Works like charm
from react-native-config.
Another alternative, for just mocking the
Config.FOO
usage:// __mocks__/react-native-config.js export default { FOO_BAR: 'baz', };
anyone can confirm this still work?. I tried on my project but not luck
from react-native-config.
Related Issues (20)
- Config is empty after upgrade to RN 0.71 HOT 32
- "/tmp/envfile" is buggy when its contents are empty string (iOS)
- Cannot invoke method toInteger() on null object HOT 2
- Inconsistent Environment File Loading in Android Studio vs React Native CLI
- ERROR in ./src/CONFIG.ts 3:0-41 [web-server] Module not found: Error: Can't resolve 'react-native-config' in '/Volumes/Personal/code-work/rn-projects/zaions/expensify-app-fork/src'
- is it possible to pass params but not set ENVFILE when run assemble release HOT 1
- How to import NSExceptionDomains as an environment variable?
- Variable are UNDEFINED on IOS HOT 14
- Could not find method android() for arguments [dotenv_4bgzrl46y7i0xnvnmgzr6qa4c$_run_closure1@3fa75e8b] on project ':app' of type org.gradle.api.Project.
- How to read config in Kotlin class in react native 0.73? HOT 1
- RNConfig Empty Android HOT 2
- MainApplication.kt:27:58 Type mismatch: inferred type is String but Boolean was expected HOT 1
- Not working on ReactNative 0.73 HOT 1
- Error retrieving namespace value from .env file during build process
- hey, did you find a way to make it work?
- Update the documentation HOT 3
- Issue with kotlin DSL
- ios undefined problem HOT 7
- [Question] - Is this lib abandoned?
- Compatibility of react-native-config with React Native 0.73+ HOT 1
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 react-native-config.