badeball / cypress-cucumber-preprocessor

Run cucumber/gherkin-syntaxed specs with Cypress
MIT License
1.32k stars 149 forks source link

BeforeAll Wrong! #1250

Closed LeohsPaixao closed 4 weeks ago

LeohsPaixao commented 4 weeks ago

Current behavior

image image

'BeforeAll' of all other specs is running on a specific spec, where it contains only one 'BeforeAll'.

Desired behavior

Only the 'BeforeAll' of the specified spec runs in the tests.

Test code to reproduce

BeforeAll(() => {
  cy.login('######@####.com.br', '######');
  createProject().then((data) => {
    projectIdentifier = data.identificador;
  });
});

Given('[atividade] entrar na rota {string}', (route: string) => {
  cy.visitAndwait(`${route}/${projectIdentifier}`);
  cy.checkDomLoaded();
  atividades.validateVisibleAtividades();
});

Versions

Checklist

badeball commented 4 weeks ago

This could very well be intended behavior, depending on your configuration and file hierarchy, like if each feature is paired with every file containing hooks & step definitions.

In any case, you need to provide a complete & runnable example illustrating the issue.

LeohsPaixao commented 4 weeks ago

Unfortunately, I can't show you the code anymore as it's from a company project. Regarding the file hierarchy, the specs are separated by modules and each one has its own 'BeforeAll', i.e. there is no dependency between them. But basically, all the BeforeAlls for each spec are the same, doing practically the same thing, as in the code I sent above.

  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": false,
    "stepDefinitions": "./e2e/specs/**/**/step_definitions/**/*.spec.ts",
    "html": {
      "enabled": true
    }
LeohsPaixao commented 4 weeks ago

This could very well be intended behavior, depending on your configuration and file hierarchy, like if each feature is paired with every file containing hooks & step definitions.

In any case, you need to provide a complete & runnable example illustrating the issue.

Oooooh, I understood.