Skip to main content

Cypress.currentTest

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

caution

Note that Cypress.currentTest may only be used inside tests and test hooks, and will be null outside of tests and test hooks.

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​

VersionChanges
8.2.0Cypress.currentTest added