I m trying to test some worker code

I'm trying to test some worker code using this guide https://miniflare.dev/testing/jest. I was able to test KV use, does anyone know what I need to add to my jest.config.js to test D1 use?
1 Reply
esdee
esdeeOP2y ago
If anyone else is stuck with this problem, I did the following: In jest.config.js I added the following
testEnvironmentOptions: {
bindings: { PRIVATE: 'test private', PUBLIC: 'test public' },
d1Databases: ['__D1_BETA__<name-of-db>'],
d1Persist: true,
},
testEnvironmentOptions: {
bindings: { PRIVATE: 'test private', PUBLIC: 'test public' },
d1Databases: ['__D1_BETA__<name-of-db>'],
d1Persist: true,
},
And in my test after const env = getMiniflareBindings() I added env.<name-of-db> = __D1_BETA__<name-of-db>
Want results from more Discord servers?
Add your server