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.

0
Subscribe to my newsletter

Read articles from Ayomide Apantaku directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ayomide Apantaku
Ayomide Apantaku

Software Engineer