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

Run tests in different browsers sequentially #2495

Closed
Lukas-Kullmann opened this issue Jun 6, 2018 · 3 comments
Closed

Run tests in different browsers sequentially #2495

Lukas-Kullmann opened this issue Jun 6, 2018 · 3 comments
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: question The issue contains a question that won't be addressed.

Comments

@Lukas-Kullmann
Copy link

Is there a way to make tests run as soon as a browser is connected? Currently if you run tests in multiple browsers at the same time, browsers wait for each other before running the tests.
This is not desirable for us since we use browserstack and our license only allows one connection at a time, but we want to run the tests in five different browsers. So we would like to run the tests in these browsers sequentially.
Is there a possibility to do this (e.g. by passing some option to the test run)?

@miherlosev miherlosev added the TYPE: question The issue contains a question that won't be addressed. label Jun 6, 2018
@miherlosev
Copy link
Collaborator

At present, you can do it by running TestCafe for each browser.

testcafe "browserstack:Chrome@67.0:Windows 10" /tests
testcafe "browserstack:Firefox@60.0:Windows 10" /tests
testcafe "browserstack:Internet Explorer@11.0:Windows 10" /tests
etc.

TestCafe does not allow running tests in several browsers sequentially at the level of one test run.

 
 
 

@nabrahamson
Copy link

I hope it's alright to add this code snippet to this closed issue.
@Lukas-Kullmann

I've figured out a way to do this in a scripted node application using async/await. Please see the code below

const browsers = [
  ['browserstack:edge@17.0:Windows 10', 'browserstack:chrome@68.0:Windows 10'],
  ['browserstack:firefox@61.0:Windows 10', 'browserstack:firefox@61.0:OS X High Sierra'],
  ['browserstack:chrome@68.0:OS X High Sierra', 'browserstack:safari@11.1:OS X High Sierra'],
];

const runTest = async browser => {
  console.log('starting tests');
  await createTestCafe('localhost', 1337, 1338)
    .then(tc => {
      testcafe = tc;
      const runner = testcafe.createRunner();

      return runner
        .src(['web-tests/*.ts'])
        .browsers(browser)
        .run();
    })
    .then(async failedCount => {
      console.log('Tests failed: ' + failedCount);
      await testcafe.close();
      return;
    });
}

const runAllBrowsers = async () => {
  for (const browser of browsers) {
    await runTest(browser);
  }
}

Adjust the browsers array to include the browsers you want to execute your tests against. The array may be a list of strings, or arrays containing browsers to run parallel. In my case, I can reliably run against 2-3 browsers synchronously.

@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: question The issue contains a question that won't be addressed.
Projects
None yet
Development

No branches or pull requests

3 participants