question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

before() from support/index.js called twice

See original GitHub issue

Current behavior:

before() used in support/index.js being called twice.

Screenshot 2020-08-03 18 44 55

Desired behavior:

Test code to reproduce

support/index.js

// Import commands.js using ES2015 syntax:
import './commands';
import faker from 'faker';

export const nameSeed = faker.random.words(3);

before('define nameSeed', () => {
  cy.log(`Name seed for this run is: ${nameSeed}`);
});

after('log out', () => {
  cy.log(nameSeed);
});

Versions

4.11.0, MacOS, Chrome

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Aug 12, 2020

Yeah, maybe you are requiring the index file twice somehow?

We recommend questions relating to how to use Cypress be asked in our community chat. Also try searching our existing GitHub issues, reading through our documentation, or searching Stack Overflow for relevant answers.

0reactions
jennifer-shehanecommented, Oct 19, 2020

@sagenicky Please provide a full reproducible example so we can see if the behavior is expected or not for ourselves.

Read more comments on GitHub >

github_iconTop Results From Across the Web

callback being called twice when my unit test fails
js ? chai?) is using exceptions. So my answer is based on that assumption. It seems that node-neo4j is recalling the callback function...
Read more >
Cypress basics: before(), beforeEach(), after() and afterEach()
I like to think of all hooks as being "squashed" together before executing a test or a describe() block. Using beforeEach block in...
Read more >
Writing and Organizing Tests - Cypress Documentation
The order of hook and test execution is as follows: All before() hooks run (once); Any beforeEach() hooks run; Tests run; Any afterEach() ......
Read more >
Be careful when running all specs together - Gleb Bahmutov
The support file runs in the browser, right before the spec file runs. We can see the support file and the spec file...
Read more >
The Most Common Cypress Mistakes - Christian Lüdemann
Before you start reading, I want to you know that this post comes with a fee… ... For that reason, you risk flakiness...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found