如何在 Cypress 中實現標籤?
我們可以在 Cypress 中實現標籤。Cypress 有兩個標籤 - .only 和 .skip。.only 標籤用於執行帶有該標籤的 it 塊,.skip 標籤用於排除帶有該標籤的 it 塊。
示例
.only 實現
describe('Tutorialspoint', function()
//it block with tag .only
it.only('First Test', function() {
cy.log("First Test")
})
//it block with tag .only
It.only('Second Test', function() {
cy.log("Second Test")
})
it('Third Test', function() {
cy.log("Third Test")
})
})執行結果

輸出日誌顯示,帶有 .only 標籤的 it 塊(第一個和第二個測試)得到了執行。
示例
.skip 實現
describe('Tutorialspoint', function()
it('First Test', function() {
cy.log("First Test")
})
it('Second Test', function() {
cy.log("Second Test")
})
//it block with tag .skip
it.skip('Third Test', function() {
cy.log("Third Test")
})
})執行結果

輸出日誌顯示,帶有 .skip 標籤的 it 塊(第三個測試)被跳過了,沒有執行。
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP