Jakub Fojtik
Jakub Fojtik

Reputation: 706

Testcafe Studio imports not working in Typescript

In Testcafe Studio importing works for Javascript, but not Typescript. I'm following the example, just with Typescript.

page-model.ts

export default class Page {}

tests.ts

import * as page from './page-model';

The import string is underlined with an error:

Cannot find module './page-model' or its corresponding type declarations.(2307)

What else is needed to make it work?

I considered a similar question, but even Javascript file imports show the same error.

Maybe it's related to a configuration Note:

TestCafe resolves user-specified relative paths against the TestCafe installation folder.

EDIT The whole question is about Testcafe Studio, I did not realize the distinction until just now. Updated question and tags.

Upvotes: 1

Views: 418

Answers (1)

Alexey Popov
Alexey Popov

Reputation: 1047

I used this example, rewrote it with TypeScript, and ran it. As a result, the test was successfully completed.

Make sure that the path to your file with the page model in the test file is correct.

Also, you import the Page by default, which means that you do not need to export it with *. Just export it as follows: import page from './page-model';

Upvotes: 1

Related Questions