Tests share module state: add a shared loader that resets modules per test
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- testing
調査の方向性
Read tests/unit/game-moves.test.js and tests/integration/game-flow.test.js, then inspect the module-level DOM references in js/board.js and js/game.js. Implement the shared loader and position-builder described in the issue, update both test files, and run npm test and npm run lint. Done when consecutive loads are shown to be independent and both test files use the helper.
索引モデルが issue の本文から書いたものです。
説明
Summary
Each beforeEach builds a new JSDOM and then requires the game modules, but nothing calls jest.resetModules(). A second test in the same file would get the cached modules, which still hold the first test's DOM nodes and game state.
Where
tests/unit/game-moves.test.js:6-109,tests/integration/game-flow.test.js:6-116(about 100 duplicated setup lines each)js/board.js:5,js/game.js:17-18(DOM nodes captured at module load)js/game.js:27(reset happens only when history is empty)
Details
This is from reading the code, assuming Jest's default of one module registry per test file; the suite was not run. It is invisible today only because each file holds exactly one test.
Impact
The first contributor who adds a second test to either file gets order-dependent failures or false passes. This blocks the test work in #41 and #42.
Suggested fix
Move the setup into one helper, for example tests/helpers/load-game.js, that calls jest.resetModules(), creates the JSDOM, sets the globals, requires the modules and returns { window, game, board }. Add a position-builder that places pieces on an empty board and sets king positions.
Acceptance criteria
- Both existing test files use the helper
- A test proves two consecutive loads are independent
- A position-builder exists for non-starting positions
Getting started
- Relevant files:
tests/unit/game-moves.test.js,tests/integration/game-flow.test.js - How to run tests:
npm install, thennpm testandnpm run lint - Related docs:
docs/ARCHITECTURE.md,.github/CONTRIBUTING.md
Filed by repo-audit/full-audit at 8a2c86c. Severity: medium. Effort: S. audit-key: testing|tests/unit/game-moves.test.js|beforeEach
- 主要言語
- JavaScript
- スター
- 4
- フォーク
- 2
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TMHSDigital/Static_Chess のほかの issue
-
enhancement good first issue severity: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
TMHSDigital/Static_Chess#53 ·
-
documentation good first issue severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
TMHSDigital/Static_Chess#49 ·
-
documentation good first issue severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
TMHSDigital/Static_Chess#48 ·
-
documentation severity: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
TMHSDigital/Static_Chess#47 ·
-
documentation good first issue severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
TMHSDigital/Static_Chess#46 ·
TMHSDigital/Static_Chess の issue をすべて見る
似ている issue
-
good first issue tests
難易度 1/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
1️⃣ phase/under-investigation flaky/confirmed flaky/needs-decision type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
growilabs/growi#12246 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
TMHSDigital/Free-Game-Dev-Assets#301 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100