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

disabled restart browser in devmode #8017

Merged
merged 1 commit into from
Sep 22, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/browser/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ export default class BrowserConnection extends EventEmitter {
}

private _waitForHeartbeat (): void {
if (this._options.developmentMode)
return;

this.heartbeatTimeout = setTimeout(() => {
const err = this._createBrowserDisconnectedError();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const reporter = createReporter({
},
});

function createConnection (browser) {
function createConnection (browser, devMode) {
return browserProviderPool
.getBrowserInfo(browser)
.then(browserInfo => {
const options = {
disableMultipleWindows: false,
nativeAutomation: config.nativeAutomation,
developmentMode: config.devMode,
developmentMode: devMode,
};

const connnection = new BrowserConnection(testCafe.browserConnectionGateway, browserInfo, false, options);
Expand Down Expand Up @@ -55,11 +55,11 @@ const initializeConnectionHangOnRestart = connection => {
};
};

function run (pathToTest, filter, initializeConnection = initializeConnectionLowHeartbeatTimeout) {
function run (pathToTest, filter, devMode = config.devMode, initializeConnection = initializeConnectionLowHeartbeatTimeout) {
const src = path.join(__dirname, pathToTest);
const browserNames = config.currentEnvironment.browsers.map(browser => browser.browserName || browser.alias);

return Promise.all(browserNames.map(browser => createConnection(browser)))
return Promise.all(browserNames.map(browser => createConnection(browser, devMode)))
.then(connections => {
connections.forEach(connection => initializeConnection(connection));

Expand Down Expand Up @@ -150,7 +150,14 @@ if (config.useLocalBrowsers) {
});

it('Should restart browser on timeout if the `closeBrowser` method hangs', function () {
return run('./testcafe-fixtures/index-test.js', 'Should restart browser on timeout if the `closeBrowser` method hangs', initializeConnectionHangOnRestart)
return run('./testcafe-fixtures/index-test.js', 'Should restart browser on timeout if the `closeBrowser` method hangs', config.devMode, initializeConnectionHangOnRestart)
.then(() => {
expect(errors.length).eql(0);
});
});

it('Shouldn\'t restart browser when it does not respond and developmentMode on', function () {
return run('./testcafe-fixtures/index-test.js', 'Shouldn\'t restart browser when it does not respond and developmentMode on', true)
.then(() => {
expect(errors.length).eql(0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,15 @@ test('Should log error on browser disconnect', async t => {
t.testRun.browserConnection.emit('error', new Error('force error'));
}, 5000);
});

test('Shouldn\'t restart browser when it does not respond and developmentMode on', async t => {
const userAgent = await getUserAgent();

counter[userAgent] = counter[userAgent] || 0;

counter[userAgent]++;

await hang();

await t.expect(counter[userAgent]).eql(1);
});