oracle-gaps: expect in a file-level afterAll fails with "Digest already called"
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
調査の方向性
packages/oracles/oracle-gaps/capture-setup.mjs を読んでください: matcher(811-824 行あたり)は、すべてのアサーションについて chai の Proxy.value ラッパーから呼ばれ、finishTest は、ファイルレベルの afterAll が実行される前に digest を確定して inTest をクリアします。issue にあるスタンドアロンの再現(capture-setup.mjs を setupFiles にした vitest 設定と、afterAll 内でアサートするテスト)を実行して、Digest already called を確認することから始めてください。完了とは、再現とリストされた 5 つの oracle ファイルが capture harness 下で通ること、およびファイルレベルのアサーションをスキップするかハッシュ化するかの判断が付いていることを意味します。
索引モデルが issue の本文から書いたものです。
説明
Summary
oracle-gaps reports an oracle file as failing with no mutant active, with Digest already called, when the file has an expect(...) in a file-level afterAll that runs after its last test. All of the file's tests pass.
Reproduction
Standalone reproduction against main at 7b6bae1, verified with Node 24.8.0 and Vitest 5.1.0:
SHA=7b6bae1683a386b9d5e9349bdd77c8bb96b37377
mkdir oracle-gaps-188 && cd oracle-gaps-188
npm init -y
npm i -D --ignore-scripts [email protected]
for file in capture-setup paths; do
curl -fsSLO "https://raw.githubusercontent.com/TanStack/oracles/$SHA/packages/oracles/oracle-gaps/$file.mjs"
done
cat > vitest.config.mjs <<'CONFIG'
import { defineConfig } from 'vitest/config'
export default defineConfig({ test: { setupFiles: ['./capture-setup.mjs'] } })
CONFIG
cat > repro.test.mjs <<'TEST'
import { afterAll, expect, it } from 'vitest'
it('passes', () => expect(1).toBe(1))
afterAll(() => expect(1).toBe(1))
TEST
echo '{"mutant":null,"select":null,"capture":"capture.jsonl"}' > state.json
ORACLE_GAPS_STATE=state.json npx vitest run
The one test passes, then the file fails:
Error: Digest already called
❯ Object.matcher capture-setup.mjs:822:14
821| } catch {
822| digest.update(`${name}(unrenderable)\n`)
❯ Proxy.value capture-setup.mjs:846:15
Adding if (!inTest) return at the top of matcher makes this reproduction pass.
The same failure in real oracle files: under the capture harness, virtual-row-fields-input-oracle had 4,908 tests pass and ordered-work-oracle.property had 690 tests pass. Each file then failed with this stack (line numbers are from e2af13a):
Error: Digest already called
❯ Object.matcher capture-setup.mjs:564:14
563| } catch {
564| digest.update(`${name}(unrenderable)\n`)
❯ Proxy.value capture-setup.mjs:588:15
❯ tests/query/virtual-row-fields-input-oracle.test.ts:143:7
Cause
finishTestfinalizes the test's hash withdigest.digest('hex')and setsinTest = false.- A new hash is only created in the next test's
beforeEach. - The chai wrapper calls
hooks.matcher(name, this)for every assertion, including those inafterAll. matcherhas noinTestguard, so it callsdigest.update(rendered)on the finalized hash. That throws inside itstry, and itscatchcallsdigest.update(...)again, so the error escapes from the hook.
Instrumentation showed each test's finishTest ran exactly once, so this is not a double finish.
Impact
Vitest fails the file because of the afterAll error. oracle-gaps then treats that oracle file as failing with no mutant active, so every mutant it owns is blocked and the report is provisional.
Five oracle files in packages/db/tests/query/ of TanStack/db were blocked:
ordered-work-oracle.property.test.ts(afterAllassertion around line 5391)virtual-row-fields-effect-oracle.test.tsvirtual-row-fields-input-oracle.test.ts(afterAllassertion around line 143)virtual-row-fields-oracle.test.tsvirtual-row-fields-types-oracle.test.ts
Run directly with Vitest, those five files pass (7,711 tests).
Workaround
Verified in a private copy of the tool:
matcher(name, assertion) {
// A file-level hook has no test row, and the last row closed its hash.
if (!inTest) return
try {
With it, all five files pass under the capture harness (7,711 tests). A complete gap report with this workaround was still running when this issue was filed, so its result is not confirmed.
Maintainers may want to adjust this: it deliberately leaves file-level assertions out of per-test hashes. The assertion itself still runs and can still fail the file.
Environment
TanStack/dbat725ba95c85372fd6d7e59a104e586cf23833e290@tanstack/oraclesfrom pkg.pr.new ate2af13a- Vitest 5.1.0
- Node 24.8.0
- The unguarded
matcheris still present onmainat7b6bae1683a386b9d5e9349bdd77c8bb96b37377
- 主要言語
- JavaScript
- スター
- 13
- フォーク
- 1
- 平均マージ
- 11時間 8分
- マージ済み PR(30日)
- 67
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/oracles のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
メンテナーはふだん 1 日以内に返信
TanStack/oracles の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client area対応中かも @lijy91 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
libnativeapi/nativeapi#53 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
KilledByAPixel/LittleJS#188 ·
-
[workshop-sync] workshop/06-install-gh-aw.md: outdated version example and gh aw init file listオープンdocumentation
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
githubnext/gh-aw-workshop#6053 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
JuliusBrussee/caveman#1567 ·
メンテナーはふだん 1 日以内に返信