0
0

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, Frisby.js をTypeScriptで使う

Last updated at Posted at 2019-06-12

環境

  • typescript 3.5.1
  • jest 24.8.0
  • ts-jest 24.0.2
  • frisby 2.1.1

手順

Jestプロジェクト作成

$ yarn add --dev jest
package.json
{
・・・
  "scripts": {
    "test": "jest"
  },
・・・
}

JestのTypeScript対応

$ yarn add --dev typescript
$ yarn add --dev ts-jest @types/jest
$ yarn ts-jest config:init

これでjest.config.jsonがつくられる

Frisby.jsのTypeScript対応

$ yarn add --dev frisby @types/frisby
my.test.ts
import * as frisby from 'frisby';

it ('should be a teapot', () => {
  return frisby.get('http://httpbin.org/status/418').expect('status', 418);
});

テスト実行

$ yarn test
  yarn run v1.16.0
  $ jest
   PASS  ./my.test.ts
    ✓ should be a teapot (622ms)

  Test Suites: 1 passed, 1 total
  Tests:       1 passed, 1 total
  Snapshots:   0 total
  Time:        1.354s, estimated 3s
  Ran all test suites.
  ✨  Done in 2.16s.
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?