
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-native-savor
Advanced tools
React Native Savor Adds Delicious Flavors To Your React Native Apps, Like Tests, Coverage and Analysis.
Savor gives you all you need to write amazing tests, right out of the box, all in one place: a test framework, BDD and TDD assertions, stubbing/mocking, code coverage and static analysis.
Savor uses the following Open-Source libraries to make that happen:
Savor also gives you the ability to plug your tests into your continuous integration process via Coveralls for code coverage and Codacy for code analysis. It also support CodeClimate which is a tool that offers both static analysis and code coverage. To integrate with your CI tool, make sure you add a post-execution script that runs the following:
npm run coveralls
npm run codacy
npm run codeclimate
For Travis CI for example, this is what your .travis.yml file might look like:
language: node_js
node_js:
- "5.0"
after_success:
- npm run coveralls
- npm run codacy
- npm run codeclimate
STEP 1
Add Savor to your module as a development dependency:
npm install --save-dev react-native-savor
STEP 2
Add Savor to your module scripts:
"scripts": {
"savor": "react-native-savor"
}
If you'd like more granularity over your scripts you can also install single Savor commands:
"scripts": {
"savor": "react-native-savor",
"test": "react-native-savor test",
"lint": "react-native-savor lint",
"cover": "react-native-savor cover",
"coveralls": "react-native-savor coveralls",
"codacy": "react-native-savor codacy"
"codeclimate": "react-native-savor codeclimate"
}
Make sure you also configure Babel correctly in your package.json:
"babel": {
"plugins": ["transform-react-jsx"],
"presets": ["react-native", {}]
}
STEP 3
Make sure your code resides under a src directory and all your specs under a test/specs directory:
package.json
node_modules/
src/
main.js
test/
assets/
BasicComponent.js
specs/
main.js
You can now write tests under your test directory, like so:
import React, {
View,
Text,
StyleSheet
} from 'react-native'
import savor from '../../../..'
import BasicComponent from '../assets/react-native/BasicComponent'
const TestText = (<Text>test</Text>)
const TestComponent = (<BasicComponent/> )
savor.add('should mount a basic React Native component', function(context, done) {
const wrapper = context.shallow(TestComponent)
context.expect(wrapper.length).to.equal(1)
context.expect(wrapper).to.contain(TestText)
done()
}).
run('My React Native Tests')
When you add a test, you are given a context that contains the following:
context.expect // Using Chai
context.assert // Using Chai
context.stub // Using Sinon
context.shallow // Using Enzyme
context.mount // Using Enzyme
context.render // Using Enzyme
context.dir // The temporary test location
You can now simply run your tests like so:
npm test
You can check your coverage like this:
npm run coverage
You can lint your code like this:
npm run lint
Take a look at the example for more details on how to integrate Savor within your module.
Enjoy!
Copyright (c) 2016 I. Dan Calinescu
Licensed under the The MIT License (MIT) (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://raw.githubusercontent.com/idancali/react-native-savor/master/LICENSE
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
FAQs
A simple way of adding tests (and more) to your React Native apps
We found that react-native-savor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.