{ // your test code here }..."/>
溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Jest中如何跳過特定測(cè)試

發(fā)布時(shí)間:2024-08-28 09:55:37 來源:億速云 閱讀:85 作者:小樊 欄目:編程語言

在 Jest 中,要跳過特定測(cè)試,可以使用 test.skip() 方法

例如,假設(shè)您有以下測(cè)試:

test('this test will run', () => {
  // your test code here
});

test('this test will be skipped', () => {
  // your test code here
});

要跳過第二個(gè)測(cè)試,只需將其更改為:

test('this test will run', () => {
  // your test code here
});

test.skip('this test will be skipped', () => {
  // your test code here
});

現(xiàn)在,當(dāng)您運(yùn)行測(cè)試時(shí),第二個(gè)測(cè)試將被跳過。請(qǐng)注意,test.skip() 也可以與 describe 結(jié)構(gòu)一起使用,以跳過整個(gè)測(cè)試套件。

describe('skipped suite', () => {
  test('this test will be skipped', () => {
    // your test code here
  });

  test('this test will also be skipped', () => {
    // your test code here
  });
}).skip();

這將跳過整個(gè)“skipped suite”中的所有測(cè)試。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI