Skip to content

Importing types doesn't work in jest environment #8301

@vojvodics

Description

@vojvodics

Vue version

3.3.2

Link to minimal reproduction

https://github.com/vojvodics/vue3.3.1-jest-reproduction-example

Steps to reproduce

Clone reproduction repository and run npm run test

What is expected?

Tests should pass

What is actually happening?

Tests are failing with the following error:

    [@vue/compiler-sfc] No fs option provided to `compileScript` in non-Node environment. File system access is required for resolving imported types.

System Info

No response

Any additional comments?

A hacky solution is provided in the repo example. It is based on these files:
https://github.com/vuejs/core/blob/v3.3.2/packages/vue/compiler-sfc/index.js
https://github.com/vuejs/core/blob/v3.3.2/packages/vue/compiler-sfc/register-ts.js

Also related:

*initially it was v3.3.1, but I updated it to v3.3.2 and it is still present

Metadata

Metadata

Assignees

No one assigned

    Labels

    has workaroundA workaround has been found to avoid the problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions