mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-07-21 06:54:34 +00:00
test(claude): harden withPlatform mock against cross-file leak
The process.platform mock omitted configurable:true and never restored the value when the property had no own descriptor, leaving win32 mocked for later tests on the same Vitest worker. Add configurable + an else branch that deletes the override to expose the real inherited value.
This commit is contained in:
parent
89c94164d7
commit
9ca89523a1
1 changed files with 2 additions and 1 deletions
|
|
@ -18,11 +18,12 @@ const savedEnv = {
|
|||
|
||||
function withPlatform<T>(platform: typeof process.platform, run: () => T): T {
|
||||
const descriptor = Object.getOwnPropertyDescriptor(process, 'platform')
|
||||
Object.defineProperty(process, 'platform', { value: platform })
|
||||
Object.defineProperty(process, 'platform', { value: platform, enumerable: true, configurable: true })
|
||||
try {
|
||||
return run()
|
||||
} finally {
|
||||
if (descriptor) Object.defineProperty(process, 'platform', descriptor)
|
||||
else delete (process as { platform?: NodeJS.Platform }).platform
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue