0

is there any way to find the Current running cypress command when it reaches the first time to the cypress config.ts file?

actually, I need to do something based on the command used by a user
example
if the cypress command is executed to run specific test cases
I need to do some operation
if the cypress command has some key in command I need to perform some operation

so is there any way to determine which cypress command the user entered while running the cypress

ksk
  • 165
  • 14

1 Answers1

0

No, not directly. The cypress.config.ts file is loaded and executed when Cypress starts, and any configuration values set there will not be available until after the configuration file has been processed.

You can include the operation inside the before \ beforeEach hook of the test spec files. If you need to run it every time (regardless of the test spec used), you can include the before \ beforeEach hook inside the support/index.ts file.

If the operation (sorry you didn't specify) is a non-Cypress command, then you can use cy.task.

Sample code:

before(() => { // run this to generate data for the entire suite
    cy.readFile('cypress/fixtures/data.json');
    cy.task('log', 'This will be output to the terminal');
});
ebanster
  • 886
  • 1
  • 12
  • 29