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

fix: disableConcurrency with quarantine mode (closes #8087) #8088

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/runner/browser-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ export default class BrowserJob extends AsyncEventEmitter {
}

private async _onTestRunRestart (testRunController: TestRunController): Promise<void> {
const conectionId = testRunController.testRun.browserConnection.id;

this._removeFromCompletionQueue(testRunController);
this._testRunControllerQueue.unshift(testRunController);
this._getTestControllerQueue(conectionId).unshift(testRunController);

await this.emit('test-run-restart', testRunController);
}
Expand Down
9 changes: 9 additions & 0 deletions test/functional/fixtures/regression/gh-8087/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>gh-8087</title>
</head>
<body>
</body>
</html>
43 changes: 43 additions & 0 deletions test/functional/fixtures/regression/gh-8087/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const path = require('path');
const createTestCafe = require('../../../../../lib');
const { createReporter } = require('../../../utils/reporter');
const { expect } = require('chai');

let testCafe = null;
let runner = null;
let errors = null;

const reporter = createReporter({
reportTestDone (_, testRunInfo) {
errors = testRunInfo.errs;
},
});


const run = (pathToTest, concurrency) => {
const src = path.join(__dirname, pathToTest);

return createTestCafe('127.0.0.1', 1335, 1336)
.then(tc => {
testCafe = tc;
})
.then(() => {
runner = testCafe.createRunner();
return runner
.src(src)
.browsers(`chrome:headless`)
.reporter(reporter)
.concurrency(concurrency)
.run({ quarantineMode: { successThreshold: 1, attemptLimit: 3 } });
})
.then(() => {
testCafe.close();
});
};

describe('[Regression](GH-8087)', function () {
it('Should execute all fixture\'s test in one browser with quarantine Mode', function () {
return run('./testcafe-fixtures/index.js', 2)
.then(() => expect(errors.length).eql(0));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@


const testRunInfo = {
attemptCount: 0,
connections: {},
};

const addConnection = (connections, connectionId) => {
if (!connections[connectionId])
connections[connectionId] = 1;
else
connections[connectionId]++;
};


fixture `disableConcurrency fixture`
.beforeEach(async t => {
addConnection(testRunInfo.connections, t.testRun.browserConnection.id);
})
.afterEach(async t => {
await t.expect(Object.keys(testRunInfo.connections).length).eql(1);
})
.after(() => {
if (Object.keys(testRunInfo.connections).length !== 1 || Object.values(testRunInfo.connections)[0] !== 3)
throw new Error();
})
.disableConcurrency;

for (let i = 0; i <= 1; i++) {
test(`test ${i}`, async () => {
testRunInfo.attemptCount++;
if (testRunInfo.attemptCount < 2)
throw new Error();
});
}