Search code examples
typescripttestingautomated-teststestcafepageobjects

Can I run TestCafe tests with unused Typescript page objects


I'm writing tests in TestCafe using Page Objects pattern.

Some of the page objects are written beforehand (before they are actually used), since I know the page and know what to expect.

But, when trying to run tests with unused page objects I will get an error message like:

Error: TypeScript compilation failed.
C:/path-to/a.page-object.ts (40, 7): 'PageObjectExample' is declared but never used.

Is there a TestCafe or TypeScript option to (temporarily) allow for the compilation of these kinds of tests?


Solution

  • It appears that you are using a custom tsconfig because this error occurs due to the noUnusedLocal option. Get rid of this option in your config.

    See also:

    Ignore all errors in a typescript file

    Customize TestCafe Compiler Options