testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

The combination of video recording and concurrency breaks testcafe test hook execution

Open Makavelic opened this issue 2 years ago • 2 comments

What is your Scenario?

I want to run testcafe tests with video recording and concurrency.

What is the Current behavior?

If I enable both capabilities, some tests will execute before the .before block is complete.

What is the Expected behavior?

Tests should wait for the .before block to finish executing before they start.

What is your public website URL? (or attach your complete example)

VideoConcurrencyIssues.zip

What is your TestCafe test code?

import { t } from "testcafe";
let value = 0;
fixture("bugTest")
	.before(async () => { 
		await new Promise(r => setTimeout(r, 10000));
		// Value should be set before any test starts
		value = 10;
	})
	.beforeEach(async t => {
		await t.navigateTo(`file://${__dirname}/testcafeBug.html`);
	});

test("test1", async t => {
	await t.expect(value).eql(10);
});

test("test2", async t => {
	await t.expect(value).eql(10);
});

test("test3", async t => {
	await t.expect(value).eql(10);
});

Your complete configuration file

.testcaferc.json

{
    "videoPath": "artifacts/videos",
    "videoOptions": {
        "singleFile": true,
        "failedOnly": true,
        "pathPattern": "${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}.mp4"
    }
}

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

  1. Extract project
  2. Build project with yarn or npm
  3. Run command from terminal: testcafe chrome -c 3 tests

Expected: All tests should pass Actual: 2 tests fail because they execute before the .before block is done

TestCafe version

1.18.6

Node.js version

16.13.0

Command-line arguments

testcafe chrome -c 3 tests

Browser name(s) and version(s)

Chrome 100

Platform(s) and version(s)

Windows 10

Other

This also occurs if I use the Runner code instead of the CLI. When I'm debugging I always have to create my own locking mechanism to avoid this issue.

Makavelic avatar Apr 22 '22 19:04 Makavelic

I managed to reproduce the issue. I confirm that it appears only when video recording is enabled. We'll research this behavior.

AlexKamaev avatar Apr 26 '22 08:04 AlexKamaev

I managed to reproduce the issue. I confirm that it appears only when video recording is enabled. We'll research this behavior.

I just encountered the same problem but without video recording. No special configuration but it only happens on a specific test file (I can't determine what causes it) but figured its worth mentioning that its possibly a more global problem.

Makavelic avatar Sep 21 '22 18:09 Makavelic

Hi @Makavelic

Thank you for the additional information. We will keep it in mind when investigating the cause of the issue.

miherlosev avatar Sep 23 '22 06:09 miherlosev

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

github-actions[bot] avatar Sep 07 '23 01:09 github-actions[bot]

This is still an issue.

Makavelic avatar Sep 07 '23 03:09 Makavelic

Release v3.5.0-rc.1 addresses this.

github-actions[bot] avatar Dec 22 '23 11:12 github-actions[bot]

Release v3.5.0-rc.1 addresses this.

github-actions[bot] avatar Dec 22 '23 12:12 github-actions[bot]