Any ideas how to get worker constructors into Vitest?

Trying to create an object using a constructor from the worker. However the worker types only specify interfaces, leading to the error in the screenshot.

I've tried to use the vitest/packages/web-worker package from https://github.com/vitest-dev/vitest/tree/main/packages/web-worker

And set up vitest.config.js like so:
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    setupFiles: ['@vitest/web-worker'],
  },
})


However I'm not able to use any of the types from worker runtime it seems.

I'm trying to mock an EmailMessage replicating the actual thing here: https://github.com/webbertakken/email-worker/blob/526b020af8bcefcd9ecfeb81eb264e8d826b633a/test/helpers/createEmailMessage.ts#L20

Any ideas?
image.png
Was this page helpful?