Cypress-cucumber-preprocessor: Tests are way too slow when this preprocessor is used

Created on 11 Mar 2020  路  11Comments  路  Source: TheBrainFamily/cypress-cucumber-preprocessor

Tried a simple button test

  1. button.spec.ts - finishes in 4s
  2. button.feature - finishes in 40s

button.spec.ts

describe('Button - vanilla', () => {
  it('should launch button page', () => {
    cy.visit('/components/ui/button');
    cy.contains('Examples').click();
    cy.contains('Secondary Buttons').click();
    cy.get('#button-secondary').should('be.visible');
  });
});

button.feature

Feature: Button

  TRQ-XXXXX

  Background:
    Given button page is open

  Scenario: Default Button
    When I click on examples tab
    And I click on secondary-buttons example
    Then I should see secondary button

button.steps.ts

import { Given, When, And, Then } from 'cypress-cucumber-preprocessor/steps';

Given(`button page is open`, () => {
  cy.visit('/components/ui/button');
});

When(`I click on examples tab`, () => {
  cy.contains('Examples').click();
});

And(`I click on secondary-buttons example`, () => {
  cy.contains('Secondary Buttons').click();
});

Then(`I should see secondary button`, () => {
  cy.get('#button-secondary').should('be.visible');
});

Most helpful comment

Hi! Are there any news on this? We recently migrated from stock Cypress Mocha to cucumber using the preprocessor and the Suite of 10 somewhat long tests we have currently is taking double the time it used to with Mocha.

We're using Cypress 7.5.0 and cypress-cucumber-preprocessor 4.1.2.

Things we already tried...

  1. Using or not using Data Tables
  2. Using global Steps or Feature Steps
  3. Going back versions of both Cypress and the Cucumber Preprocessor
  4. Turning the 'numTestsKeptInMemory' to 0

Thanks!!

All 11 comments

That's not what we see. Could you please make a reproduction so we could take a look at what's going on?

@lgandecki Sure, I will setup a repo with the issue today but in the meanwhile you can refer to below plugins setup which I have been using in order to run tests under @nrwl/cypress builder.

const wp = require('@cypress/webpack-preprocessor');
const { getWebpackConfig } = require('@nrwl/cypress/plugins/preprocessor');

function preprocessTypescript(config) {
  if (!config.env.tsConfig) {
    throw new Error('Please provide an absolute path to a tsconfig.json as cypressConfig.env.tsConfig');
  }

  const webpackConfig = getWebpackConfig(config);

  webpackConfig.node = { fs: 'empty', child_process: 'empty', readline: 'empty' };
  webpackConfig.module.rules.push(
    {
      test: /\.feature$/,
      use: [
        {
          loader: 'cypress-cucumber-preprocessor/loader'
        }
      ]
    },
    {
      test: /\.features$/,
      use: [
        {
          loader: 'cypress-cucumber-preprocessor/lib/featuresLoader'
        }
      ]
    }
  );

  return async (...args) =>
    wp({
      webpackOptions: webpackConfig
    })(...args);
}

module.exports = (on, config) => {
  on('file:preprocessor', preprocessTypescript(config));
};

@lgandecki Did you get a chance to look at this?

I even tried https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example and found the similar results.

One other observation: cypress run is relatively faster but the above numbers which I had posted were for cypress open.

I'm also finding similar results with our use of cypress-cucumber-preprocessor.

its absurdly slow for us too. do webpack builds happen for each test?

any updates on this? it is indeed very slow when using this plugin

Hey guys, a reproduction and more info (operating system, cypress version, is it performance of run/open, etc) would be great as this is not what we (and a significant amount of happy users) see.
Make it easy for us to help :)

@lgandecki As mentioned in my earlier comment, have found similar results with reference webpack example.
https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example.

Slowness is observed during open mode only.

"cypress": "3.8.3",
"cypress-cucumber-preprocessor": "^2.0.1"

Thanks.
I cloned https://github.com/TheBrainFamily/cypress-cucumber-webpack-typescript-example.

changed package.json:

    "cypress": "^4.8.0",
    "cypress-cucumber-preprocessor": "^2.5.0",

changed google.com to github.com in cypress/support/step_definitions/webpack.ts (google was taking forever to load, but that has nothing to do with this plugin)
run
npm install
npx cypress open

clicked WebPack.feature -

image

clicked All.features -

image

both worked in an instant. Took a few seconds.

Can you give me some more details? Can you try with the newest versions (for some reasons you had 2.0.1 and 3.8.3). When you saw "slow" how slow is it? 10 x as in the original comment?

Hi @lgandecki I will retest this with updated version and share their results. Thanks

Hi! Are there any news on this? We recently migrated from stock Cypress Mocha to cucumber using the preprocessor and the Suite of 10 somewhat long tests we have currently is taking double the time it used to with Mocha.

We're using Cypress 7.5.0 and cypress-cucumber-preprocessor 4.1.2.

Things we already tried...

  1. Using or not using Data Tables
  2. Using global Steps or Feature Steps
  3. Going back versions of both Cypress and the Cucumber Preprocessor
  4. Turning the 'numTestsKeptInMemory' to 0

Thanks!!

Was this page helpful?
0 / 5 - 0 ratings