0.1.18 • Published 5 years ago

navigation-test-utils v0.1.18

Weekly downloads
57
License
-
Repository
-
Last release
5 years ago

navigation-test-utils

A utility library for testing w/ navigation-components

Provides some nice additions to the @testing-library/react-native render() method, as well as out of the box mocks to get up and running quickly with jest

Install

yarn add navigation-test-utils

Dependencies

navigation-components and this utility library share peer dependencies:

yarn add react-native-gesture-handler react-native-screens react-native-reanimated

this library also relies on these dev dependencies:

yarn add --dev @testing-library/react-native @testing-library/jest-native

Jest config:

  // ...

  "jest": {
    "preset": "@testing-library/react-native",
    "modulePathIgnorePatterns": [
      "<rootDir>/example"
    ],
    "transformIgnorePatterns": [
      "node_modules/(?!(react-native|react-native-screens|react-native-reanimated)/)"
    ],
    "setupFilesAfterEnv": [
      "@testing-library/react-native/cleanup-after-each",
      "navigation-test-utils/setup",
      "navigation-test-utils/cleanup-after-each"
    ],
    "transform": {
      "^.+\\.(t)sx?$": "ts-jest"
    }
  }

Reference

import {render, navigate} from 'navigation-test-utils

test('app', () => {
  navigate('/welcome') // navigates to an initial screen before starting the test

  const { getFocused } = render(<MyApp />)

  getFocused().debug() // outputs the current focused screen
  getFocused().getByText(/welcome/i) // query anything on the focused screen

  navigate('/deep/in/the/app') // navigate anywhere

  getFocused().debug() // e.g a deeply nested screen
})
0.1.18

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.15

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago