Use vitest#expect from the local context#12403
Conversation
|
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
petebacondarwin
left a comment
There was a problem hiding this comment.
As a follow up we should refactor all the expect usage in MSW handlers to just return 500 responses instead. It is considered an anti-pattern to do expectation checks inside these handlers.
I'm adding that to the parent issue to make sure to do that at the end. Thanks for the review! |
Part of #12346
Part of a series (#12347, #12356, #12373, #12385) handling simple refactors, one package at a time to keep the review simpler.
This PR handles bucket 1 out of 4 of the wrangler package.
Code was created by OpenNext/Opus:
Wrangler Bucket 1 Migration Summary
Overview
Migrated 39 test files in
packages/wrangler/src/__tests__/from directoriespages/,d1/,kv/, andqueues/to useexpectfrom the test context instead of importing it from vitest.ESLint Configuration
Added to
packages/wrangler/eslint.config.mjs:Files Changed
Trivial Files Migrated (27)
These files were fully converted to use
expectfrom the test context:d1/ (13 files):
convert-timestamp-to-iso.test.tscreate.test.tsd1.test.tsexecute.test.tsexport.test.tsinfo.test.tsinsights.test.tslist.test.tsmigrate.test.tssplitter.test.tstimeTravel.test.tstrimmer.test.tsutils.test.tskv/ (2 files):
help.test.tslocal.test.tspages/ (11 files):
dev.test.tsfilepath-routing.test.tsfunctions-build.test.tspages-build-env.test.tspages-deployment-tail.test.tspages.test.tsproject-delete.test.tsproject-validate.test.tsroutes-consolidation.test.tsroutes-transformation.test.tsroutes-validation.test.tsqueues/ (1 file):
queues-subscription.test.tsComplex Files Disabled (12)
These files have the lint rule disabled with
/* eslint-disable workers-sdk/no-vitest-import-expect */:d1/delete.test.tsexpectused inmockDatabaseDeletehelper functionkv/bulk.test.tsexpectused in MSW request handlerskv/key.test.tsexpectused in MSW request handlerskv/namespace.test.tstest.eachpatternspages/deploy.test.tstest.eachpatternspages/deployment-list.test.tsexpectused in MSW handlerspages/pages-download-config.test.tsexpectused in MSW handlerspages/project-create.test.tsexpectused in MSW handlerspages/project-list.test.tsexpectused in MSW handlerspages/project-upload.test.tsexpectused in MSW handlerspages/secret.test.tsexpectused in MSW handlersqueues/queues.test.tstest.eachpatternsConversion Pattern
Before:
After:
Verification
pnpm --filter wrangler check:lintpasses with 0 errorsRemaining Buckets
pages/,d1/,kv/,queues/r2/,cloudchamber/,containers/,vectorize/versions/,autoconfig/,api/,deploy/,dev/,config/,utils/,core/,metrics/A picture of a cute animal (not mandatory, but encouraged)