Cypress.currentTest
Cypress.currentTest — это объект, представляющий текущий выполняемый тест, с свойствами для доступа к заголовку теста.
Обратите внимание, что
Cypress.currentTestможно использовать только внутри тестов и тестовых хуков, и он будетnullвне тестов и тестовых хуков.
Синтаксис
// 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
Примеры
Получение заголовка текущего теста
describe('app layout and responsiveness', () => {
it('toggles the nav', () => {
expect(Cypress.currentTest.title).to.eq('toggles the nav')
})
})
Получение полного пути заголовка текущего теста
describe('app layout and responsiveness', () => {
it('toggles the nav', () => {
expect(Cypress.currentTest.titlePath).to.deep.eq([
'app layout and responsiveness',
'toggles the nav',
])
})
})
История
| Версия | Изменения |
|---|---|
| 8.2.0 |
Cypress.currentTest добавлено |
© 2017 Cypress.io
Licensed under the MIT License.
https://docs.cypress.io/api/cypress-api/currenttest