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

Cleanup throws error if TestCafe if Node.js instance was started with "--watch" #8234

Open
Klaster1 opened this issue Jul 14, 2024 · 2 comments
Labels
TYPE: bug The described behavior is considered as wrong (bug).

Comments

@Klaster1
Copy link

Klaster1 commented Jul 14, 2024

What is your Scenario?

I wrote some custom functions for TestCafe and decided to cover these with tests. The test setup consists of a Node.js built-in test runner that spawns TestCafe and asserts against TestCafe JSON reports. As goes with tests, you often want to run them in a watch mode.

What is the Current behavior?

What spawned from execSync, spawn or manually created runner instance (the createTestcafe API) and with the "--watch" flag, TestCafe runs the tests and throws.

TypeError: Cannot read properties of undefined (reading 'resolve')
    at CleanupProcess._onResponse (C:\dev\testcafe-repeat-test\node_modules\testcafe\lib\utils\temp-directory\cleanup-process\index.js:39:37)
    at ChildProcess.<anonymous> (C:\dev\testcafe-repeat-test\node_modules\testcafe\src\utils\temp-directory\cleanup-process\index.js:96:47)
    at ChildProcess.emit (node:events:519:28)
    at ChildProcess.emit (node:domain:488:12)
    at emit (node:internal/child_process:951:14)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

What is the Expected behavior?

TestCafe runs without throwing errors.

What is your TestCafe test code?

reproducer.zip

Steps to Reproduce

Create a TestCafe runner via the JS API and run an empty TestCafe test with it. When starting the .js, use "--watch" node argument.

TestCafe version

3.6.2

Node.js version

20.15.0

Platform(s) and version(s)

WIndows 11

@Klaster1 Klaster1 added the TYPE: bug The described behavior is considered as wrong (bug). label Jul 14, 2024
@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Jul 14, 2024
@Klaster1
Copy link
Author

Klaster1 commented Jul 14, 2024

Debugging indicates that this method does not validate the message contents. After I add if (!response.id) return to _onResponse, everything goes back to normal.

How a Node.js watch message payload looks:

{
  'watch:require': [
    'C:\\dev\\testcafe-repeat-test\\node_modules\\testcafe\\lib\\utils\\temp-directory\\cleanup-process\\commands.js'
  ]
}

@PavelMor25 PavelMor25 added the STATE: Issue accepted An issue has been reproduced. label Jul 18, 2024
Copy link

We appreciate you taking the time to share information about this issue. We reproduced the bug and added this ticket to our internal task queue. We'll update this thread once we have news.

@github-actions github-actions bot removed STATE: Need response An issue that requires a response or attention from the team. STATE: Issue accepted An issue has been reproduced. labels Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

2 participants