Skip to content

Commit 62c4ec6

Browse files
chore: recreate expo example 2026-06-11 (#123)
1 parent 6248939 commit 62c4ec6

19 files changed

Lines changed: 3031 additions & 3658 deletions

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ See the focused guides before making task-specific changes:
2121
- [Coding Style](docs/agents/coding-style.md)
2222
- [Testing](docs/agents/testing.md)
2323
- [Git Workflow](docs/agents/git-workflow.md)
24+
- [Recreating Examples](docs/agents/recreating-examples.md)
2425
- [Instruction Audit](docs/agents/instruction-audit.md)

docs/agents/recreating-examples.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Recreating Example Apps
2+
3+
When an example needs to be refreshed against the latest framework version, follow this workflow: scaffold a fresh app from the official template, then restore the Reassure setup and perf tests from the existing code.
4+
5+
## General Workflow
6+
7+
1. **Capture what must be restored** — before removing anything, note the files that are not generated by the scaffold tool: `src/*.perf.tsx`, `jest-setup.js` / `jest.setup.ts`, `jest.config.*`, `babel.config.*`, `reassure-tests.sh`, `dangerfile.js`, `README.md`.
8+
2. **Remove the old example** — delete the example directory (e.g. `examples/web-vite`).
9+
3. **Scaffold a fresh app** — run the official getting-started command for that framework (see per-example commands below). Use the same template flags as the original.
10+
4. **Rename / move into place** — the scaffold tool creates a subdirectory; move it to `examples/<name>` and ensure `package.json` `"name"` matches the original.
11+
5. **Restore Reassure setup** — follow the setup steps in that example's `README.md`. See the per-example section below for specifics.
12+
6. **Restore perf tests** — copy `src/*.perf.tsx` files back. Adjust imports if the scaffold changed any paths.
13+
7. **Restore `README.md`** — replace the scaffold-generated README with the reassure-setup README that was there before (or update it to match the new template version).
14+
8. **Validate** — from inside the example directory run `yarn install && yarn test && yarn perf-test && yarn typecheck`.
15+
16+
Always use `yarn`, not `npm`, for every install and script invocation.
17+
18+
---
19+
20+
## Per-Example Details
21+
22+
### `web-vite` — React + TypeScript + Vite
23+
24+
**Scaffold command:**
25+
```sh
26+
yarn create vite web-vite --template react-ts
27+
```
28+
29+
**Reassure setup** (after scaffolding):
30+
1. Install dev dependencies: `jest`, `jest-environment-jsdom`, `@types/jest`, `@testing-library/react`, `@testing-library/dom`, `@babel/preset-env`, `@babel/preset-react`, `@babel/preset-typescript`, `@types/babel__preset-env`, `reassure`, `danger`.
31+
2. Restore `jest.config.cjs` and `babel.config.cjs` from the previous version (the scaffold does not generate these).
32+
3. Restore `jest-setup.js` — it calls `configure({ testingLibrary: 'react' })` from `reassure`.
33+
4. Run `yarn reassure init` — this generates `reassure-tests.sh`, `dangerfile.js`, and adds `.reassure` to `.gitignore`.
34+
5. Add `"test": "jest"`, `"perf-test": "reassure"`, and `"typecheck": "tsc --noEmit"` to `package.json` `"scripts"`.
35+
36+
**Key config files to restore:** `jest.config.cjs`, `babel.config.cjs`, `jest-setup.js`.
37+
38+
---
39+
40+
### `web-nextjs` — Next.js
41+
42+
**Scaffold command:**
43+
```sh
44+
yarn create next-app web-nextjs --typescript --eslint --app --src-dir --import-alias "@/*"
45+
```
46+
Accept defaults for any prompts not listed above.
47+
48+
**Reassure setup** (after scaffolding):
49+
1. Install dev dependencies: `jest`, `jest-environment-jsdom`, `@types/jest`, `@testing-library/react`, `@testing-library/dom`, `@testing-library/jest-dom`, `ts-node`, `reassure`, `danger`.
50+
2. Restore `jest.config.ts` from the previous version.
51+
3. Restore `jest.setup.ts` — it calls `configure({ testingLibrary: 'react' })` from `reassure`.
52+
4. Run `yarn reassure init` — generates `reassure-tests.sh`, `dangerfile.js`, `.gitignore` entry.
53+
5. Add `"test": "jest"` and `"perf-test": "reassure"` to `package.json` `"scripts"`.
54+
55+
**Key config files to restore:** `jest.config.ts`, `jest.setup.ts`.
56+
57+
---
58+
59+
### `native-expo` — Expo React Native
60+
61+
**Scaffold command:**
62+
```sh
63+
npx create-expo-app native-expo --template blank-typescript
64+
```
65+
66+
**Reassure setup** (after scaffolding):
67+
1. Install dev dependencies: `@testing-library/react-native`, `@types/jest`, `reassure`, `danger`. (Expo templates already include Jest and a basic preset.)
68+
2. Restore `jest.config.js` from the previous version — it sets `preset: 'react-native'` and points to the setup file.
69+
3. Restore `jest-setup.js` — it calls `configure({ testingLibrary: 'react-native' })` from `reassure`.
70+
4. Run `yarn reassure init` — generates `reassure-tests.sh`, `dangerfile.js`, `.gitignore` entry.
71+
5. Add `"test": "jest"`, `"perf-test": "reassure"`, and `"typecheck": "tsc --noEmit"` to `package.json` `"scripts"` if missing.
72+
73+
**Key config files to restore:** `jest.config.js`, `jest-setup.js`.
74+
75+
---
76+
77+
### `native-cli` — React Native CLI
78+
79+
**Scaffold command:**
80+
```sh
81+
npx @react-native-community/cli init NativeCli --template react-native-template-typescript
82+
```
83+
Then rename the directory to `native-cli` and set `"name"` in `package.json` to `reassure-native-example` (matching the original).
84+
85+
**Reassure setup** (after scaffolding):
86+
1. Install dev dependencies: `@testing-library/react-native`, `@types/jest`, `reassure`, `danger`. (The CLI template already ships Jest via `react-native` preset.)
87+
2. Replace the generated `jest.config.js` with the restored version — it sets `preset: 'react-native'` and points to the setup file.
88+
3. Restore `jest-setup.js` — it calls `configure({ testingLibrary: 'react-native' })` from `reassure`.
89+
4. Run `yarn reassure init` — generates `reassure-tests.sh`, `dangerfile.js`, `.gitignore` entry.
90+
5. Add `"perf-test": "reassure"` and `"typecheck": "tsc --noEmit"` to `package.json` `"scripts"` if missing.
91+
92+
**Key config files to restore:** `jest.config.js`, `jest-setup.js`.
93+
94+
---
95+
96+
## Perf Tests
97+
98+
All examples contain perf tests under `src/`:
99+
100+
- `TestList.perf.tsx` — measures list rendering performance.
101+
- `AsyncComponent.perf.tsx` — measures async component rendering performance.
102+
103+
Copy these files back after scaffolding. Check imports against the new scaffold's file layout and adjust if needed. Run `yarn perf-test` to confirm they execute without errors.
104+
105+
## Avoiding Image Churn
106+
107+
Scaffold tools regenerate image assets from their own templates on every run. These binary files often differ byte-for-byte from the ones already in the repo even when visually identical, producing noisy, meaningless diffs in git.
108+
109+
**Rule: prefer the existing committed images over freshly generated ones.**
110+
111+
After scaffolding, restore the original images by copying them from git before staging anything:
112+
113+
```sh
114+
git checkout HEAD -- <path-to-image-or-directory>
115+
```
116+
117+
Locations to restore per example:
118+
119+
| Example | Images to restore |
120+
|---------|-------------------|
121+
| `native-cli` | `android/app/src/main/res/mipmap-*/ic_launcher.png` and `ic_launcher_round.png` (10 files) |
122+
| `native-expo` | `assets/adaptive-icon.png`, `assets/icon.png`, `assets/splash-icon.png`, `assets/favicon.png` |
123+
| `web-nextjs` | `public/*.svg`, `src/app/favicon.ico` |
124+
| `web-vite` | `public/vite.svg`, `src/assets/react.svg` |
125+
126+
Only commit a regenerated image if the asset itself genuinely changed (e.g. the framework updated its default branding). In that case, note it explicitly in the commit message.
127+
128+
---
129+
130+
## Files Never Generated by Scaffold Tools
131+
132+
These must always be restored manually:
133+
134+
| File | Purpose |
135+
|------|---------|
136+
| `src/*.perf.tsx` | Reassure performance tests |
137+
| `jest-setup.js` / `jest.setup.ts` | Jest setup with `configure()` call |
138+
| `jest.config.*` | Jest configuration (env, preset, setup file) |
139+
| `babel.config.*` | Babel presets for Jest (web examples only) |
140+
| `reassure-tests.sh` | CI script for baseline/branch comparison |
141+
| `dangerfile.js` | Danger config for PR reporting |
142+
| `README.md` | Reassure setup documentation |

examples/native-expo/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ yarn-error.*
3636
# typescript
3737
*.tsbuildinfo
3838

39+
# generated native folders
40+
/ios
41+
/android
42+
3943
# Reassure
4044
.reassure/

examples/native-expo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ This example showcases Reassure setup for React Native Expo app.
1111
* generate `reassure-tests.sh` CI script
1212
* generate `dangerfile.js` config for `danger`
1313
* add `.reasure` entry to `.gitignore`
14-
5. (optional) Add `configure({ testingLibrary: 'react-native' });` to your `jest-setup.js` file
14+
5. (optional) Add `configure({ testingLibrary: 'react-native' });` to your `jest-setup.js` file

examples/native-expo/app.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,17 @@
66
"orientation": "portrait",
77
"icon": "./assets/icon.png",
88
"userInterfaceStyle": "light",
9-
"newArchEnabled": true,
10-
"splash": {
11-
"image": "./assets/splash-icon.png",
12-
"resizeMode": "contain",
13-
"backgroundColor": "#ffffff"
14-
},
159
"ios": {
1610
"supportsTablet": true
1711
},
1812
"android": {
1913
"adaptiveIcon": {
20-
"foregroundImage": "./assets/adaptive-icon.png",
21-
"backgroundColor": "#ffffff"
14+
"backgroundColor": "#E6F4FE",
15+
"foregroundImage": "./assets/android-icon-foreground.png",
16+
"backgroundImage": "./assets/android-icon-background.png",
17+
"monochromeImage": "./assets/android-icon-monochrome.png"
2218
},
23-
"edgeToEdgeEnabled": true
19+
"predictiveBackGestureEnabled": false
2420
},
2521
"web": {
2622
"favicon": "./assets/favicon.png"
-17.1 KB
Binary file not shown.
17.1 KB
Loading
76.9 KB
Loading
4.04 KB
Loading

examples/native-expo/babel.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)