Repository navigation
[wrangler] Quieten warnings and stray output in tests - #15209
Conversation
|
|
Codeowners approval required for this PR:
Show detailed file reviewers |
|
The message matches the snapshot. The change is sound. Let me review the whole change set holistically once more. Summary of my analysis:
All three changes are correct, well-scoped, and test-only. No logic bugs, security issues, or behavior regressions. The changes actually improve test hygiene. No actionable issues. LGTM |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
6784029 to
6e3a4b8
Compare
6e3a4b8 to
ca1ec82
Compare
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
Extends the same fixes to every other instance in the repo: - Hoist the `child_process` `vi.mock` in `versions.upload` to module scope. Written inside a `describe`, it misrepresented its scope: the call is hoisted anyway and mocks the module for the whole file. Vitest warns this "will become an error in a future version". - Replace `__dirname` with `import.meta.dirname` in 14 ESM Vite/Vitest configs (31 sites). Vite warns on each when loading the config. Node >=22 is already required, so `import.meta.dirname` is always available. - Stop two `console.warn` spies in the context-exports fixture from calling through, so the warnings they assert on no longer print. Drop a third spy that was never asserted against.
ca1ec82 to
a061429
Compare
Removes three sources of noise from the test output. No behaviour change — test and test-config only.
__dirnamein ESM configs. Vite warns when loading an ESM config that uses__dirname, once per site:Switched to
import.meta.dirnameacross 14 Vite/Vitest configs (31 sites). Safe: these packages require Node >= 22, andimport.meta.dirnamehas been available since 20.11.A
vi.mockcall inside adescribe.versions.upload.test.tsmockedchild_processfrom within adescribebody, which Vitest hoists to module scope anyway:Moved to module scope, so the code now reflects both when it runs and what it affects — the mock applies file-wide, not just to that
describe. Vitest says this will become a hard error, so it needs doing regardless.Errors leaking to stderr.
ai.local.test.tsasserted onvi.spyOn(logger, "error"), which observes the call but does not capture the output, so a real error was printed on every run:Switched to
mockConsoleMethods()with inline snapshots, matching the pattern used across the rest of the suite. This also tightens the two negative cases: they previously asserted only thatlogger.errorwas not called, and now assert that nothing at all was written to stderr.Similarly, two
console.warnspies in thecontext-exportsfixture called through to the real implementation, printing the warnings they assert on. A third spy was never asserted against at all, so it is dropped.Verified by running the affected files before and after: the warnings are gone and the tests still pass.