معرفی شرکت ها


assert-rejects-1.0.0


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

Assert that a promise eventually rejects
ویژگی مقدار
سیستم عامل -
نام فایل assert-rejects-1.0.0
نام assert-rejects
نسخه کتابخانه 1.0.0
نگهدارنده ['linusu']
ایمیل نگهدارنده ['linus@folkdatorn.se']
نویسنده -
ایمیل نویسنده -
آدرس صفحه اصلی git+https://github.com/LinusU/assert-rejects.git
آدرس اینترنتی https://github.com/LinusU/assert-rejects#readme
مجوز MIT
# Assert Rejects Assert that a promise eventually rejects ## Installation ```sh npm install --save assert-rejects ``` ## Usage ```js const assertRejects = require('assert-rejects') describe('Something', () => { it('rejects', () => { const promise = doSomethingThatShouldReject() return assertRejects(promise) }) it('rejects with specific code', () => { const promise = readFileThatDoesntExists() return assertRejects(promise, err => err.code === 'ENOENT') }) }) ``` ## API ### `assertRejects(promise[, error][, message])` Expects the `promise` to reject. Returns a new promise that will resolve once the provided promise is resolved. If specified, `error` can be a constructor, [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or validation function. If specified, `message` will be the message provided by the `AssertionError` if the promise fails to reject. Validate instanceof using constructor: ```js assertRejects( Promise.reject(new Error('Wrong value')), Error ) ``` Validate error message using [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions): ```js assertRejects( Promise.reject(new Error('Wrong value')), /value/ ) ``` Custom error validation: ```js assertRejects( Promise.reject(new Error('Wrong value')), (err) => ((err instanceof Error) && /value/.test(err)), 'unexpected rejection' ) ``` Note that `error` can not be a string. If a string is provided as the second argument, then `error` is assumed to be omitted and the string will be used for `message` instead. This can lead to easy-to-miss mistakes: ```js // THIS IS A MISTAKE! DO NOT DO THIS! assertRejects(myPromise, 'missing foo', 'did not reject with expected message') // Do this instead. assertRejects(myPromise, /missing foo/, 'did not reject with expected message') ```


نیازمندی

مقدار نام
^1.0.0 is-regexp


زبان مورد نیاز

مقدار نام
10.5.0 Npm


نحوه نصب


نصب پکیج tgz assert-rejects-1.0.0:

    npm install assert-rejects-1.0.0.tgz