cypress / 9.4.1 / api / cypress-api / currenttest.html /

Cypress.currentTest

Cypress.currentTest is an object representing the currently executing test instance, with properties to access the title of the test.

Syntax

// an object with title and titlePath properties
Cypress.currentTest

// the title of the current test
Cypress.currentTest.title

// an array with the current test's title path
Cypress.currentTest.titlePath

Examples

Get current test title

describe('app layout and responsiveness', () => {
  it('toggles the nav', () => {
    expect(Cypress.currentTest.title).to.eq('toggles the nav')
  })
})

Get full path of current test title

describe('app layout and responsiveness', () => {
  it('toggles the nav', () => {
    expect(Cypress.currentTest.titlePath).to.deep.eq([
      'app layout and responsiveness',
      'toggles the nav',
    ])
  })
})

History

Version Changes
8.2.0 Cypress.currentTest added

© 2017 Cypress.io
Licensed under the MIT License.
https://docs.cypress.io/api/cypress-api/currenttest