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

Cypress performance degradation after several failed tests (one by one). #7077

Closed
RomanShmandrovskyi opened this issue Apr 20, 2020 · 2 comments
Labels

Comments

@RomanShmandrovskyi
Copy link

RomanShmandrovskyi commented Apr 20, 2020

Current behavior:

Caught this problem when tried to generate Mochawesome report. So, I just artificially failed several tests for this. I need add different content for different Errors during test run to Mochawesome report.

After several failed tests that go one by one, cypress performance begin decrease. Here is the sample from my console:

diffs

Time execution for failed tests got from report.
In two runs spec are the same. Tests in suite are also the same and do the same assertions.

On image I failed 4 tests and after that performance was lower as in run without this failed tests. For 21 tests time execution was increased on more than one minute.

Desired behavior:

Think it isn't good if I have many tests in one suite and several first of them - filed.

Test code to reproduce

Unfortunately, can't provide some code samples or some test automation framework. But can provide additional information:

  1. All tests execute quite heavy custom Cypress tasks: from 3 to 5 tasks per one test that work with images (image composing, working with image bitmap, images joining, trimming transparent images background, converting from one image MIME type to other and so on). Also almost each test spec using Cypress.Blob class functionality.
  2. On test (inside each spec) level all cypress commands are wrapped into sync NodeJS code:

beforeEach hook in suite:

import loginPage from '../../../support/pages/loginPage';

beforeEach('Login to application', () => { 
      loginPage().login(); 
});

and JS function:

import user from '../entities/user';

const EMAIL_INPUT_CSS = 'input#email';
const PASSWORD_INPUT_CSS = 'input#password';
const LOGIN_FORM_CSS = 'form';

export default function loginPage() {
  return {
    login() {
      cy.visit(Cypress.env('host'));

      cy.get(EMAIL_INPUT_CSS)
        .type(user().email);
      cy.get(PASSWORD_INPUT_CSS)
        .type(user().password);
      cy.get(LOGIN_FORM_CSS)
        .submit();
    },
  };
}

on other layers exists cypress custom commands (using Cypress.Commands.add)
3. Also I disabled video recording (but if it on, it hasn't any influence);
4. I run Cypress specs programmatically using Cypress Module API:

const cypress = require('cypress');
const yargs = require('yargs');

const argv = yargs
  .option('spec', { alias: 's' })
  .option('browser', { alias: 'b', default: 'chrome' })
  .option('noExit', { type: 'boolean' })
  .option('headless', { type: 'boolean', default: false })
  .help().argv;

// some async code here

cypress.run({
  browser: argv.browser,
  env: argv.env,
  spec: argv.spec,
  headless: argv.headless,
  exit: !argv.noExit,
})
  .then(res => {
  // some actions with res object
  })
  .catch(err => {
    console.error(err);
    process.exit(1);
  });

Use Module API because need to execute some async code before run cypress.
Run command example:
node cypress/support/runner.js -b chrome --headless

Versions

Cypress version: 4.4.0 (the latest one);
Browser: Chrome in headless mode. Version 81.0.4044.113 (Official Build) (64-bit);
OS: Ubuntu 18.04.

@jennifer-shehane
Copy link
Member

We'd really need a fully reproducible example in order to verify why this performance issue is happening. May be something within the login() function.

May be duplicate of #6881

Unfortunately we have to close this issue as there is not enough information to reproduce the problem. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.

Please comment in this issue with a reproducible example and we will consider reopening the issue.

@RomanShmandrovskyi
Copy link
Author

@jennifer-shehane okey, when I have enough time, I'll write some test framework to test this.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants