freeCodeCamp/guide/arabic/miscellaneous/testing-with-chaijs/index.md

41 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Testing with Chaijs
localeTitle: اختبار مع Chaijs
---
[تشاي](http://chaijs.com) هي مكتبة اختبار لـ Node.js.
### التركيب
يمكنك تثبيت Chai في مشروعك من خلال npm.
`npm install chai
`
##### المؤيدة للطرف
إضافة Chai في devDependencies of _package.json_ ، باستخدام \* كعلامة إصدار. بهذه الطريقة ، لديك دائمًا أحدث إصدار.
`"devDependencies": {
"chai": "*"
}
`
### كيف تستعمل
#### يجزم
يمكنك استخدام _التأكيد_ للتأكد من أداء اختباراتك جيدًا.
``var assert = require('chai').assert, foo = 'bar', beverages = { tea: [ 'chai', 'matcha', 'oolong' ] };
assert.typeOf(foo, 'string'); // without optional message
assert.typeOf(foo, 'string', 'foo is a string'); // with optional message
assert.equal(foo, 'bar', 'foo equal `bar`');
assert.lengthOf(foo, 3, 'foo`s value has a length of 3');
assert.lengthOf(beverages.tea, 3, 'beverages has 3 types of tea');
``
### مزيد من المعلومات:
* `help chai assert`
* `help chai expectations`