Search code examples
javascriptautomationcypress

Run a specific function in cypress


I want to run a certain function in cypress , even though they're all in the same file for example I have the below functions and want to run the create project one not all of them

or do they have to be in separate files

it('Create Project', ()=>{}
it('Create Customer', ()=>{}
it('Create Property', ()=>{}
it('Create Object', ()=>{}

Solution

  • If I understand your question, you want to be able to run only one test at a time. You can achieve this by using the .only function.

    it.only('Create Project', ()=>{})
    it('Create Customer', ()=>{})
    it('Create Property', ()=>{})
    it('Create Object', ()=>{})
    

    see a better answer here: Cypress: run only one test

    check cypress documentation here: https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#Excluding-and-Including-Tests