Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript can't compile tests using Testcafe version >1.6.0 if module @types/jest is in the project #4435

Closed
LucasMaupin opened this issue Oct 30, 2019 · 6 comments
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot.

Comments

@LucasMaupin
Copy link

TypeScript can't compile tests using Testcafe version >1.6.0 if module @types/jest is in the project.

When I compile the tests I get the following compilation errors:

  • "Property 'expect' does not exist on type 'DoneCallback'."
  • "Property 'click' does not exist on type 'DoneCallback'."
  • "Property 'wait' does not exist on type 'DoneCallback'."
  • "Property 'before' does not exist on type 'It'."

In this case test is of type jest.It instead of TestFn. There seems to be an issue in the declaration file index.d.ts - "Cannot redeclare block-scoped variable 'test'.ts(2451)"

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Oct 30, 2019
@AndreyBelym
Copy link
Contributor

Thank you for your report. This issue looks as a duplicate of #4405. The fix will be available in testcafe@1.6.1. If you don't mind installing pre-release versions, you can install testcafe@1.6.1-alpha.2 and test it in your environment.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Oct 30, 2019
@vire
Copy link

vire commented Nov 1, 2019

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Nov 1, 2019
@arubtsov arubtsov assigned arubtsov and unassigned arubtsov Nov 6, 2019
@AndreyBelym
Copy link
Contributor

I think it isn't necessary since this problem is fixed in testcafe@1.6.1. For those people who like to precompile their tests, it's better to put a note in @types/jest README, since jest's definitions actually cause the problem. It can be reproduced easily with other test frameworks like mocha, QUnit, etc. And we have to use workarounds to stay compatible with more popular test frameworks like jest.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Nov 6, 2019
@vire
Copy link

vire commented Nov 6, 2019

@AndreyBelym actually with

  • testcafe@1.6.1
  • jest@24.9.0
  • @types/jest@24.0.22

I have types collision where my testcafe files work as expected because fixture and test resolve to

// node_modules/testcafe/ts-defs/index.d.ts
declare const fixture: FixtureFn;
declare const test: TestFn;

while unit test files written in jest test(...) resolve as well to

// node_modules/testcafe/ts-defs/index.d.ts
declare const fixture: FixtureFn;
declare const test: TestFn;

there are multiple options

  1. not using test in jest's files 😞
  2. creating typescript definition file *.d.ts workaround
  3. modifying types on either @types/jest (what should be the desired definition?) or modifying testcafe definition files (that was done in testcafe@1.6.1

Do you have a suggestion how to resolve this problem?

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Nov 6, 2019
@AndreyBelym
Copy link
Contributor

AndreyBelym commented Nov 7, 2019

You will get testcafe's definitions for test only if you start *.ts files with the testcafe command or if you import the testcafe module in other *.ts files. Only definitions from the node_modules/@types directory are loaded automatically by default when compiling any TypeScript source file. Please, create a new bug report and provide an example that can be used to reproduce the problem, or at least provide your configuration files (tsconfig.json, package.json, Gulpfile.js, etc.) and your directory structure.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Nov 7, 2019
@lock
Copy link

lock bot commented Nov 17, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Nov 17, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot.
Projects
None yet
Development

No branches or pull requests

4 participants