Skip to content

Concurrency greater than 1 spoils the hook before the test runs #8398

@JakubMaz

Description

@JakubMaz

What is your Scenario?

I want to prepare the environment in gobal hook before test runs and run tests with concurrency equal 2.

What is the Current behavior?

Tests are not waiting for finish prepareing environemnt.
Tests from 2nd fixture runs immediately.
Tests from 1st fixture waits for environment be prepared.

Logs from my code looks like that:
start preparing environment
test2.1
environment prepared
test1.1

What is the Expected behavior?

All test instances are waiting for the global hook to prepare the environment

Logs should looks like that:
start preparing environment
test1.1
test2.1
environment prepared

What is your TestCafe test code?

.testcaferc.cjs

module.exports = {
    src: "./tests",
    browsers: ["chrome:--disable-search-engine-choice-screen"],
    baseUrl: "https://devexpress.github.io/testcafe/example/",
    skipJsErrors: true,
    concurrency: 2,
    hooks: {
        testRun: {
            before: async () => {
                console.info('before hook')
                await new Promise(resolve => setTimeout(resolve, 10000)); //preparing environment
                console.info('after hook')
            }
        }
    }
}

tests/test.js

fixture`fixture1`

test('test1.1', async () => {
    console.log('test1.1')
});

fixture`fixture2`

test('test2.1', async () => {
    console.log('test2.1')
});

TestCafe version

3.7.0

Node.js version

20.18.0

Command-line arguments

testcafe

Metadata

Metadata

Assignees

No one assigned

    Labels

    STATE: StaleAn outdated issue that will be automatically closed by the Stale bot.TYPE: bugThe described behavior is considered as wrong (bug).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions