Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jerone/assert-includes
Assert string includes
https://github.com/jerone/assert-includes
assert testing
Last synced: about 2 months ago
JSON representation
Assert string includes
- Host: GitHub
- URL: https://github.com/jerone/assert-includes
- Owner: jerone
- License: mit
- Created: 2022-10-02T18:52:09.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-03T15:28:23.000Z (over 1 year ago)
- Last Synced: 2024-11-22T21:50:11.102Z (about 2 months ago)
- Topics: assert, testing
- Language: JavaScript
- Homepage:
- Size: 520 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# assert-includes
> Assert string includes
Assert that an value is included in a string.
## Installation
Most likely you want to use this package as development dependency.
```sh
npm install @jerone/assert-includes --save-dev
```Or with Yarn:
```sh
yarn add @jerone/assert-includes --dev
```## Usage
```js
import assertIncludes from '@jerone/assert-includes';test("value contains string", () => {
assertIncludes("abc", "a");
});
```If the test fails, it will throw an `AssertionError`,
which can be picked up by your testing library.For example with Jest, it will produce the following log:
![Jest log](https://raw.githubusercontent.com/jerone/assert-includes/master/docs/failing-test.png)
## API
### assertIncludes(value, includes)
Returns `true` when valid or throws `AssertionError` when invalid.
#### value
Type: `string`
Actual value expected to contain the included text.
#### includes
Type: `string`
The text that is expected to be part of the `value`.
[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://stand-with-ukraine.pp.ua)