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.

【chai】chaiのassertメモ

Posted at

chaiassertを自分が使用したものを中心にメモしておく。
今回紹介しなかったものは、次のサイトを参照。【参考:https://www.chaijs.com/api/assert/

assert.equal()

実際の値と期待値が等しい(==)かチェックする。これの否定(!=)の場合は、.notEqual()になる。

assert.equal(<実際の値>,<期待する値>)

また、JavaScriptでの===としてチェックしたい場合は.strictEqual()で、これの否定(!==)が.notStrictEqualとなる。

assert.isTrue() / .isFalse()

値がtureまたはfalseであるかチェックする。この否定がそれぞれ.isNotTrue() / .isNotFalse

assert.isTrue(<>)

assert.instanceOf()

値がコンストラクタのインスタンスであるかチェックする。これの否定が.notInstanceOfとなる。

assert.isTrue(<>,<コンストラクタ>)

assert.isfail()

テストの失敗を投げる。下記サンプルのメッセージは省略することもできる。

assert.isfail(<メッセージ>)

assert.isNull()

値がnullであるかチェックする。これの否定が.isNotNullとなる。

assert.isNull(<>)

assert.exists()

値がnullまたはundefinedではないことをチェックする。これの否定が.notExistsとなる。

assert.exists(<>)
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?