Testing
All platforms
2.5.0
Unistyles ships with own mocks that will help you to test your components that consume useStyles
and createStyleSheet
.
Using mocks
In order to use the library mocks you need to either use jest
or set process.env.NODE_ENV
to test
.
NativeEventEmitter
To mock NativeEventEmitter
that is imported internally from react-native
you can use the following code:
- Create
jest.setup.js
file:
- If you use
jest.config.js
:
- If you use
jest
inpackage.json
:
Support
Mocks support basic operations and are designed to mimic the setting of themes and breakpoints.
However, some operations, such as using plugins
or adaptiveThemes
, are not supported.