You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been following the guide to create a simple integration test with Vitest. The missing bit is the D1 integration, as it seems like the test environment doesn't have access to the local DB binding from wrangler.toml. Here is my setup:
All of this works perfectly fine when running the local worker with npm run dev, but npm test will throw the following error:
Error: D1_ERROR: no such table: users: SQLITE_ERROR
Any ideas as to how to make Vitest access the local D1 database? is this possible? There is a recipe for executing a migration as part of the test, but ideally I'd like to run the integration test with the local db.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've been following the guide to create a simple integration test with Vitest. The missing bit is the D1 integration, as it seems like the test environment doesn't have access to the local DB binding from wrangler.toml. Here is my setup:
All of this works perfectly fine when running the local worker with
npm run dev
, butnpm test
will throw the following error:Error: D1_ERROR: no such table: users: SQLITE_ERROR
Any ideas as to how to make Vitest access the local D1 database? is this possible? There is a recipe for executing a migration as part of the test, but ideally I'd like to run the integration test with the local db.
Beta Was this translation helpful? Give feedback.
All reactions