Skip to content

Commit

Permalink
Setup Travis CI and Jest test suite for React Native.
Browse files Browse the repository at this point in the history
  • Loading branch information
billmalarky committed Oct 23, 2017
1 parent d6e0b78 commit cad15ea
Show file tree
Hide file tree
Showing 6 changed files with 2,026 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .babelrc
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
14 changes: 14 additions & 0 deletions .travis.yml
@@ -0,0 +1,14 @@

#
# Travis CI config
# https://docs.travis-ci.com/user/customizing-the-build/
#

language: node_js

node_js:
- "7"

cache:
directories:
- "node_modules"
11 changes: 10 additions & 1 deletion package.json
Expand Up @@ -31,6 +31,15 @@
},
"homepage": "https://github.com/billmalarky/react-native-image-cache-hoc#readme",
"devDependencies": {
"jest": "^21.2.1"
"jest": "^21.2.1",
"react-test-renderer": "^16.0.0",
"should": "^13.1.2"
},
"jest": {
"preset": "react-native"
},
"dependencies": {
"react": "^16.0.0",
"react-native": "^0.49.3"
}
}
14 changes: 14 additions & 0 deletions tests/__snapshots__/travis.test.js.snap
@@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Travis CI Test renders correctly 1`] = `
<View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
>
Test
</Text>
</View>
`;
42 changes: 42 additions & 0 deletions tests/travis.test.js
@@ -0,0 +1,42 @@

// Load dependencies
import should from 'should';
import React from 'react';
import 'react-native';
import { View, Text } from 'react-native';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

// Ensure Travis CI tests are working.
describe('Travis CI Test', function() {

it('should execute a test.', () => {
const expectedObject = {
test: 'value'
};

expectedObject.should.deepEqual({
test: 'value'
});
});

it('renders correctly', () => {

const tree = renderer.create(
<View>
<Text>Test</Text>
</View>
);
expect(tree).toMatchSnapshot(); //If UI changes, this snapshot must be updated. See comment below.

/**
The next time you run the tests, the rendered output will be compared to the previously created snapshot.
The snapshot should be committed along code changes. When a snapshot test fails, you need to inspect whether it is an intended or unintended change.
If the change is expected you can invoke Jest with npm test -- -u to overwrite the existing snapshot.
*/

});


});

0 comments on commit cad15ea

Please sign in to comment.