3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Jest】テストのスキップ

Posted at

はじめに

Jestを使っていて、処理が重い処理のテストを一時的にスキップしたい場合、skipを追加することで回避することができます。
公式ドキュメント

検証

  • describetestit関数に.skip追加するとテストの実行をスキップすることができます。
sum.js
export const sum = (a,b)=> a + b;
sum.test.js
import { sum } from "./sum";

//skipを追加した。
test.skip(`add 10 + 20 to equal 30`, () => {
  expect(sum(10, 20)).toBe(30);
});

実際にテストを実行すると、テストがスキップされていることが確認できます。

yarn test /Users/jest-basic/src/sum.test.js
yarn run v1.22.11
$ jest /Users/jest-basic/src/sum.test.js
Test Suites: 1 skipped, 0 of 1 total
Tests:       1 skipped, 1 total
Snapshots:   0 total
Time:        0.514 s, estimated 4 s

✨  Done in 1.86s.
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?