afterEach hooks run outer suite first, unlike Jest
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react-native, typescript
調査の方向性
packages/runtime/src/runner/hooks.ts の collectInheritedHooks から始め、beforeEach と afterEach のフック順序に関する既存のテストを読みます。入れ子になったスイートで報告された順序を再現し、afterEach では最も内側のスイートからフックが実行される一方、beforeEach は現在の順序を維持することを確認します。テストで報告された動作が修正されたと確認できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
collectInheritedHooks in packages/runtime/src/runner/hooks.ts collects hooks from the root suite down and runs them in that order for both beforeEach and afterEach.
Jest and Vitest run afterEach the other way round, innermost suite first. So an afterEach in setupFilesAfterEnv runs before a test file’s own afterEach. Anything that checks cleanup at the top level then sees resources the test hasn’t closed yet. Reversing the list for afterEach fixes it.
We have a library that runs in both Node.JS and React Native through different native bindings and we reuse the same test suite between them.
System Info
System:
OS: macOS 15.6
CPU: (14) arm64 Apple M4 Pro
Memory: 141.98 MB / 48.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 24.16.0
path: /Users/user/.nvm/versions/node/v24.16.0/bin/node
Yarn:
version: 1.22.22
path: /Users/user/.nvm/versions/node/v24.16.0/bin/yarn
npm:
version: 11.13.0
path: /Users/user/.nvm/versions/node/v24.16.0/bin/npm
Watchman:
version: 2025.10.20.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 25.2
- iOS 26.2
- macOS 26.2
- tvOS 26.2
- visionOS 26.2
- watchOS 26.2
Android SDK:
API Levels:
- "34"
- "35"
- "36"
- "37"
Build Tools:
- 34.0.0
- 35.0.0
- 36.0.0
- 36.1.0
- 37.0.0
System Images:
- android-24 | Google APIs ARM 64 v8a
- android-29 | Google APIs ARM 64 v8a
- android-35 | ARM 64 v8a
- android-35 | Google APIs ARM 64 v8a
- android-36.1 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.27812.49.2514.14217341
Xcode:
version: 26.2/17C52
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.17
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.2.0
wanted: latest
react:
installed: 19.3.0
wanted: 19.3.0
react-native:
installed: 0.88.0
wanted: 0.88.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: true
newArchEnabled: true
React Native Harness Version
1.6.0
Reproduction
Steps to reproduce
npm installnpx expo run:ios --no-bundlerto build and install the app. If you don't have an iPhone 17 Pro simulator on iOS 26.2, change the simulator inrn-harness.config.mjsfirst.npm run test:ios
The second test in afterEach.harness.ts fails:
● inner › afterEach hooks of the first test ran inner first
expected 'outer afterEach > inner afterEach' to be 'inner afterEach > outer afterEach'
The outer suite's afterEach runs before the inner suite's. Jest and Vitest run afterEach hooks from the innermost suite outwards. It happens on every platform: the order comes from collectInheritedHooks in packages/runtime/src/runner/hooks.ts, which returns the hooks root first for afterEach as well as beforeEach. Reversing the list for afterEach makes the test pass.
- 主要言語
- TypeScript
- スター
- 335
- フォーク
- 23
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 54
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
callstackincubator/react-native-harness のほかの issue
-
On Windows, `report.test.ts`'s unwritable-folder case creates `\dev\null\nope` at the drive root instead of meeting an unwritable folder対応中かも @TheSeydiCharyyev が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
callstackincubator/react-native-harness#301 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
callstackincubator/react-native-harness#128 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
callstackincubator/react-native-harness#303 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
callstackincubator/react-native-harness#300 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
callstackincubator/react-native-harness#299 ·
メンテナーはふだん 1 日以内に返信
callstackincubator/react-native-harness の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Graphify-Labs/graphify#4860 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
sveltejs/eslint-plugin-svelte#1615 ·
メンテナーはふだん 7 日以内に返信
-
Parallel reticle_verify opens per-flow leases without the source lease's ignoreHTTPSErrors対応中かも @as992949791 が今日担当しました。 オープンgood first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
reticlehq/reticle#2033 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信