Skip to content

Commit

Permalink
add mock before render #27
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchellesap committed Feb 28, 2020
1 parent a9bdb47 commit 1fba648
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ script:
- pre-commit run -a
- npm install -g expo-cli --loglevel=error
- npm install --log-level=error
#- npm test # Tests disabled for now
- npm test
18 changes: 12 additions & 6 deletions App.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import React from "react";
import App from "./App";

import renderer from "react-test-renderer";

import App from "./App";
// Mock application
jest.mock("expo", () => ({
AppLoading: "AppLoading"
}));

jest.mock("./navigation/navigation", () => "navigation");

describe("<App />", () => {
it("has 1 child", () => {
const tree = renderer.create(<App />).toJSON();
expect(tree.children.length).toBe(1);
});
// Snapshot test
test("renders correctly", () => {
const tree = renderer.create(<App />).toJSON();
expect(tree).toMatchSnapshot();
});
3 changes: 3 additions & 0 deletions __snapshots__/App.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders correctly 1`] = `<navigation />`;
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ module.exports = {

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
transformIgnorePatterns: [
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|sentry-expo|native-base|react-native-screens|react-native|rn-sliding-up-panel)"
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|sentry-expo|native-base|react-native-screens|react-native|rn-sliding-up-panel|react-native-maps|react-test-renderer)"
]

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
Expand Down

0 comments on commit 1fba648

Please sign in to comment.