Skip to content

Example TypeScript + React-Native + Jest project that integrates Detox for writing end-to-end tests

License

Notifications You must be signed in to change notification settings

brenboh/ts-detox-example

 
 

Repository files navigation

TypeScript + React-Native + Jest + Detox Example Project

This is an example React-Native project that incorporates:

  • TypeScript
    • Can be used for source code, unit tests, and end-to-end tests
  • Jest to run both your unit and end-to-end tests
    • Uses ts-jest to allow Jest to understand your TS files
  • Detox
    • Configured to support iOS and Android

This project uses emin93's react-native-template-typescript as a bootstrap.

The main goal of this project is to demonstrate how to incorporate Detox into a pre-existing TS/RN/Jest project, but you can use it as a starter template as well.

React Native CLI template

You can create a project similar to this one using the React Native CLI and react-native-template-ts-detox-jest

FAQ

Adding support for baseUrl/paths

If you want to use TypeScript's baseUrl and paths options, you'll need to configure

  • Babel (for development) - Babel won't natively transform your module paths like TypeScript would, so you'll need to provide a plugin that will mimic that behavior.
    npm install -D babel-plugin-module-resolver
    # yarn: yarn add -D babel-plugin-module-resolver
    • In babel.config.js, add the following:
    // ...
    "plugins": [
        [
            "module-resolver",
            {
                "root": [ /* Put your `baseUrl` here */ ],
                "alias": {
                    // Put your `paths` setup here
                }
            }
        ]
    ]
    // ...
  • ts-jest - Refer to this section in the ts-jest docs.
  • When running iOS, you may encounter "Multiple commands produce ..." if you're using XCode 10. This is usually fixed by forcing XCode to use the legacy build system

TODO

  • Write documentation on setting this up from scratch
  • Create a script/tool to automate creating projects with this structure

Contributing

Issues and PRs are welcome!

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

MIT

About

Example TypeScript + React-Native + Jest project that integrates Detox for writing end-to-end tests

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 33.0%
  • TypeScript 28.5%
  • Java 16.6%
  • Python 14.6%
  • JavaScript 7.3%