Resolving "Object literal may only specify known properties, and 'test' does not exist in type 'UserConfigExport'"

Cover Image for Resolving "Object literal may only specify known properties, and  'test' does not exist in type 'UserConfigExport'"

I was setting up tests for a Vite project using vitest and stumbled upon a very weird error while including my setup test file in the vite.config.ts:

It turns out test isn't exported from UserConfigExport interface and it only allows properties defined by the type/interface. A quick lookup led me to this solution on Stackoverflow and it turns out I to have import defineConfig from "vitest" instead of "vite" to allow the test property. This fixed it and made the error go away.