oracle-gaps: expect in a file-level afterAll fails with "Digest already called"
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 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。完成意味著該重現與列出的五個 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 分鐘
- 30 天內合併 PR
- 67
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 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 一週以上 新手友好度 15/100
維護者通常 1 天內回覆
相似的 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 個 reaction ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
KilledByAPixel/LittleJS#188 ·
-
documentation
難度 1/5 1 小時以內 新手友好度 86/100
githubnext/gh-aw-workshop#6053 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 80/100
JuliusBrussee/caveman#1567 ·
維護者通常 1 天內回覆