Jest の「it」と「test」の違いは何ですか? 質問する

Jest の「it」と「test」の違いは何ですか? 質問する

私のテスト グループには 2 つのテストがあります。 1 つのテストでは を使用しit、もう 1 つのテストでは を使用しますtest。 どちらも非常によく似た動作をしているようです。 これらの違いは何でしょうか。

describe('updateAll', () => {
  it('no force', () => {
    return updateAll(TableName, ["fileName"], {compandId: "test"})
        .then(updatedItems => {
          let undefinedCount = 0;
          for (let item of updatedItems) {
            undefinedCount += item === undefined ? 1 : 0;
          }
          // console.log("result", result);
          expect(undefinedCount).toBe(updatedItems.length);
        })
  });

  test('force update', () => {
    return updateAll(TableName, ["fileName"], {compandId: "test"}, true)
        .then(updatedItems => {
          let undefinedCount = 0;
          for (let item of updatedItems) {
            undefinedCount += item === undefined ? 1 : 0;
          }
          // console.log("result", result);
          expect(undefinedCount).toBe(0);
        })
  });
});

更新 - 2022年11月:

testは、itJestの公式API@gwilduが説明したようにここ読みやすさを考慮して、どちらか一方を選択する必要があります。

ベストアンサー1

Jest ドキュメントitの別名ですtestしたがって、機能的な観点から見ると、これらはまったく同じです。どちらも、テストから読みやすい英語の文章を作成できるようにするために存在します。

おすすめ記事