microsoft / microsoft/react-native-windows

yarn test fails in a new 0.76 app

Open
#14,112 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area: Tests bug Workstream: Test Coverage
Dominant language
C++
Stars
17.3k
Forks
1.2k
Avg merge
1d 13h
Merged PRs (30d)
33

Description

Problem Description

Found on react-native-xaml CI, running yarn test on a new 0.76 application has a reference error. Test still passes but will break CI

ReferenceError: You are trying to import a file after the Jest environment has been torn down. From __tests__/App.test.tsx.

      at require (node_modules/react-native/Libraries/Utilities/Appearance.js:44:28)
      at getState (node_modules/react-native/Libraries/Utilities/Appearance.js:118:26)
      at subscribe (node_modules/react-native/Libraries/Utilities/useColorScheme.js:19:51)
      at subscribeToStore (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:6232:10)
      at commitHookEffectListMount (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:13038:26)
      at commitPassiveMountOnFiber (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14461:11)
      at commitPassiveMountEffects_complete (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14421:9)
      at commitPassiveMountEffects_begin (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14408:7)
      at commitPassiveMountEffects (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14396:3)
      at flushPassiveEffectsImpl (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16287:3)
      at flushPassiveEffects (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16236:14)
      at node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16051:9
      at workLoop (node_modules/react-test-renderer/node_modules/scheduler/cjs/scheduler.development.js:266:34)
      at flushWork (node_modules/react-test-renderer/node_modules/scheduler/cjs/scheduler.development.js:239:14)
      at Immediate.performWorkUntilDeadline [as _onImmediate] (node_modules/react-test-renderer/node_modules/scheduler/cjs/scheduler.development.js:533:21)
 PASS  __tests__/App.test.tsx (9.484 s)
  √ renders correctly (1892 ms)

Image

Steps To Reproduce
  1. Create a new 0.76 application
  2. Run yarn and yarn test
Expected Results

yarn tests passes without a ReferenceError

CLI version

15.0.0

Environment
info Fetching system and libraries information...
System:
  OS: Windows 11 10.0.26100
  CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
  Memory: 35.57 GB / 63.85 GB
Binaries:
  Node:
    version: 18.18.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.5
    path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm:
    version: 8.18.0
    path: ~\AppData\Roaming\npm\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    AllowAllTrustedApps: Enabled
    Versions:
      - 10.0.17763.0
      - 10.0.18362.0
      - 10.0.19041.0
      - 10.0.22000.0
      - 10.0.22621.0
IDEs:
  Android Studio: AI-213.7172.25.2113.9014738
  Visual Studio:
    - 16.11.35325.158 (Visual Studio Enterprise 2019)
    - 17.11.35327.3 (Visual Studio Enterprise 2022)
Languages:
  Java:
    version: 11.0.16.1
    path: C:\Program Files\Eclipse Adoptium\jdk-11.0.16.101-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0
    wanted: 15.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.1
    wanted: 0.76.1
  react-native-windows:
    installed: 0.76.0
    wanted: 0.76.0
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Community Modules

No response

Target Platform Version

10.0.22621

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

Debug

Snack, code example, screenshot, or link to a repository

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue by creating a new React Native 0.76 application, running yarn, and then running yarn test. Start with tests/App.test.tsx and the Appearance.js/useColorScheme.js stack shown in the report. Done means yarn test completes without the post-teardown ReferenceError while the test still passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
desktop, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.