Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

afterEach hooks run outer suite first, unlike Jest

Abierto Apto para principiantes
#296 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
82/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
react-native, typescript
Área
mobile, testing

Línea de trabajo

Empieza con collectInheritedHooks en packages/runtime/src/runner/hooks.ts y luego lee las pruebas existentes sobre el orden de los hooks beforeEach y afterEach. Reproduce el orden indicado con suites anidadas y verifica que los hooks se ejecuten primero en la suite más interna para afterEach, mientras que beforeEach mantiene el orden actual. La tarea está terminada cuando la prueba confirme que se ha corregido el comportamiento indicado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

https://github.com/TimoGlastra/harness-aftereach-repro/commit/6bae61176e88fe33a14953ad755b35dddbd37d6b

Steps to reproduce
  1. npm install
  2. npx expo run:ios --no-bundler to build and install the app. If you don't have an iPhone 17 Pro simulator on iOS 26.2, change the simulator in rn-harness.config.mjs first.
  3. 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.

Lenguaje dominante
TypeScript
Estrellas
335
Forks
23
Merge medio
1 d 8 h
PR fusionados (30 d)
54

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de callstackincubator/react-native-harness

Todos los issues de callstackincubator/react-native-harness

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.