Skip to content

[Question] Cannot import from .ts into test.ts using vite aliases #17840

@ivarlovlie

Description

@ivarlovlie

Hi.
I have a sveltekit application I am trying to set up with playwright.
I want to be able to import from a .ts file into my tests but get an error in the lines of:
"Cannot find module /path/to/module-x imported from /a/test.ts".
I have a simple repro here, run npm i, npm run build and npm run test to reproduce the error.
Adding ".js" to the import turns the compiler into thinking that my alias $lib is a package, which is not the case.
My tsconfig has paths and baseUrl set correctly, i have tried to explicitly (without relying on extends) set baseUrl and paths to no avail.
Thankful for any feedback on this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions