Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fabric: Enable react-test-renderer tests in the new cpp-app template #12376

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

jonthysell
Copy link
Contributor

@jonthysell jonthysell commented Nov 10, 2023

Description

The upstream RN app template includes a jest test suite (run with yarn test) with a default test to render your app JS using the react-test-renderer. However, this only tests the iOS version of your app (it forces platform === 'ios') and therefore won't catch if there are issues in your windows platform files.

Using @rnx-kit/jest-preset, you can run jest tests against any platform via a custom jest config.

This PR adds @rnx-kit/jest-preset as a dependency to the new cpp-app template, as well as a jest.config.windows.js to use it. Furthermore it adds a script so users can run these tests for windows via yarn test:windows.

Finally this PR adds running yarn test:windows to the PR checks for testing the new app CLI.

Closes #11939

Type of Change

  • New feature (non-breaking change which adds functionality)

Why

To expand test coverage options for app developers.

Closes #11939

What

See above.

Screenshots

image

Testing

Ran the tests in the provided RN template.

Changelog

Should this change be included in the release notes: yes

The new Fabric app template supports yarn test:windows to run jest app rendering tests with react-test-renderer

Microsoft Reviewers: Open in CodeFlow

The upstream RN app template includes a jest test suite (run with `yarn test`) with a default test to render your app JS using the `react-test-renderer`. However, this only tests the iOS version of your app (it forces platform === 'ios') and therefore won't catch if there are issues in your `windows` platform files.

Using `@rnx-kit/jest-preset`, you can run jest tests against any platform via a custom jest config.

This PR adds `@rnx-kit/jest-preset` as a dev dependency to the new `cpp-app` template, as well as a `jest.config.windows.js` to use it. Furthermore it adds a script so users can run these tests for windows via `yarn test:windows`.

To support this, I've extended the templateUtils added in microsoft#12374 to include functionality to run `npm i` / `yarn` to install any new dependencies added.

Closes microsoft#11939
@jonthysell jonthysell marked this pull request as ready for review November 13, 2023 20:12
@jonthysell jonthysell requested review from a team as code owners November 13, 2023 20:12
@jonthysell jonthysell merged commit f58718e into microsoft:main Nov 17, 2023
43 checks passed
@jonthysell jonthysell deleted the cpp-app-rnxkit branch November 17, 2023 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

The new RNW app template should enable testing via rnx-kit
2 participants