serveStaticJson and serveStaticText failing default CORS tests in dev-middleware
まだ誰も着手していません。
- 主要言語
- C++
- スター
- 127k
- フォーク
- 25.3k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 4
説明
Description
During the development of the dev-middleware package, the automated tests for serveStaticJson and serveStaticText fail because they expect default Access-Control-Allow-Origin headers in the response. The current implementation no longer includes these headers by default.
This causes test failures even though the main functionality of serving JSON or text works correctly.
Steps to reproduce
- Clone the repository.
2 . Run: yarn jest packages/dev-middleware/src/tests/ServerUtils-test.js --runInBand --verbose
- Observe that the tests for serveStaticJson and serveStaticText fail due to missing CORS headers.
Expected behavior:
Tests should pass or be updated to reflect the current implementation.
Actual behavior:
Tests fail because the response does not include "Access-Control-Allow-Origin": "*" as previously expected.
React Native Version
0.82.1
Affected Platforms
Build - MacOS
Output of npx @react-native-community/cli info
System:
OS: macOS 14.1.1
CPU: (10) arm64 Apple M1 Max
Memory: 417.81 MB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0
Yarn: 1.22.22
npm: 10.9.4
SDKs:
iOS SDK: 17A400
Android SDK: 33
npmPackages:
react: 19.1.1
react-native: 0.82.1
Stacktrace or Logs
FAIL packages/dev-middleware/src/__tests__/ServerUtils-test.js
ServerUtils
✕ serveStaticJson sets CORS header (285 ms)
✕ serveStaticText sets CORS header
✓ baseUrlForServer returns correct URL (1 ms)
● ServerUtils › serveStaticJson sets CORS header
expect(jest.fn()).toHaveBeenCalledWith(...expected)
Expected: 200, ObjectContaining {"Access-Control-Allow-Origin": "*", "Content-Type": "application/json"}
Received: 200, {"Content-Type": "application/json"}
● ServerUtils › serveStaticText sets CORS header
expect(jest.fn()).toHaveBeenCalledWith(...expected)
Expected: 200, ObjectContaining {"Access-Control-Allow-Origin": "*", "Content-Type": "text/plain"}
Received: 200, {"Content-Type": "text/plain"}
MANDATORY Reproducer
https://github.com/THE-Amrit-mahto-05/react-native-dev-middleware-repo.git
Screenshots and Videos
https://github.com/user-attachments/assets/bbec821b-f0a8-42a3-be58-a17fdceabf08
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
packages/dev-middleware/src/tests/ServerUtils-test.js から始めて、報告されている Yarn Jest コマンドを実行します。serveStaticJson と serveStaticText を調査し、欠落している CORS ヘッダーが意図された契約を反映しているかどうかを確認します。完了とは、テストと実装が一致し、対象のテストファイルがパスすることを意味します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react-native
- 領域
- devtools, testing-qa
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 58/100