You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A type-safe fluent assertion library inspired by [Jest](https://jestjs.io/docs/expect) assertions and the popular [AssertJ](https://assertj.github.io/doc/).
5
+
# AssertiveTS
6
+
7
+
A type-safe fluent assertion library written in TypeScript and inspired by [Jest](https://jestjs.io/docs/expect) assertions and the popular [AssertJ](https://assertj.github.io/doc/).
8
+
9
+
This library is designed to work in the browser and in Node.js. It ships with a rich set of expressive and flexible matchers that allows chaining multiple assertions. AssertiveTS is framework agnostic and should be used with a test framework such as [Jest](/docs/jest-tutorial.md), [Mocha](/docs/mocha-tutorial.md), or Ava.
10
+
11
+
## Type-safe library
12
+
13
+
A distinctive feature of AssertiveTS with other assertion libraries is that it leverages the TypeScript compiler to avoid type coercions and mismatches. It also infers the static type of the value you want to assert and provides you with intelligent matcher completion and signature help so that you can write code more quickly and correctly.
14
+
15
+
### Features
16
+
17
+
- Type safety and intelligent matcher completion
18
+
- Rich set of expressive and flexible matchers
19
+
- Concise, chainable interface inspired by AssertJ
20
+
- Works with any test runner and framework such as [Jest](/docs/jest-tutorial.md), [Mocha](/docs/mocha-tutorial.md), or Ava
Use the `expect` function along with a "matcher" function on the value you want to assert:
25
-
```typescript
44
+
45
+
```ts
26
46
expect(sum(1, 2)).toBeEqual(3);
27
47
```
28
48
29
49
To assert the opposite, just add `.not` before a matcher:
30
-
```typescript
50
+
51
+
```ts
31
52
expect(sum(1, 2)).not.toBeNull();
32
53
```
33
54
34
55
With `assertive-ts` you can use **fluent assertions**, which means you can chain multiple matcher functions to the same value under test:
35
-
```typescript
56
+
57
+
```ts
36
58
expect("assertive-ts is awesome!")
37
59
.toStartWith("assertive-ts")
38
60
.not.toContain("unsafe")
39
61
.toEndWith("awesome!");
40
62
```
41
63
42
64
The matcher functions depend on the type of the value on the `expect`. If you're using TypeScript, the compiler will let you know if something is not available for that assertion:
For a list of all matchers and extended documentation, please refer to the API documentation.
80
+
For a list of all matchers and extended documentation, please refer to the [API documentation](https://stackbuilders.github.io/assertive-ts/docs/build/).
58
81
59
82
## Test Runner Integration
60
83
61
84
-[Jest Integration](docs/jest-tutorial.md)
62
85
-[Mocha Integration](docs/mocha-tutorial.md)
63
86
64
87
## API Reference
65
-
You can find the full API reference [here](/docs/pages/index.html)
88
+
89
+
You can find the full API reference [here](https://stackbuilders.github.io/assertive-ts/docs/build/)
66
90
67
91
## Contributors ✨
68
92
@@ -91,4 +115,13 @@ This project follows the [all-contributors](https://github.com/all-contributors/
Do you want to contribute to this project? Please take a look at our [contributing guideline](/docs/CONTRIBUTING.md) to know how you can help us build it.
The primary goal of this Code of Conduct is to enable an open and welcoming environment. We pledge to making participation in our project a harassment-free experience for everyone, regardless of gender, sexual
5
+
orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof).
6
+
7
+
## General recommendations
8
+
Examples of behavior that contributes to creating a positive environment include:
9
+
10
+
- Using welcoming and inclusive language
11
+
- Being respectful of differing viewpoints and experiences
12
+
- Gracefully accepting constructive criticism
13
+
- Focusing on what is best for the community
14
+
- Showing empathy towards other community members
15
+
16
+
Examples of unacceptable behavior by participants include:
17
+
18
+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
19
+
- Trolling, insulting/derogatory comments, and personal or political attacks
20
+
- Public or private harassment
21
+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
22
+
- Other conduct which could reasonably be considered inappropriate in a professional setting
23
+
24
+
## Maintainer responsibilities
25
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
26
+
27
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
28
+
29
+
## Scope
30
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
31
+
32
+
## Enforcement
33
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [[email protected]](mailto:[email protected]). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
34
+
35
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
Thank you for your interest in contributing to this Stack Builders' library. To contribute, please take our [Code of Conduct](CODE_OF_CONDUCT.md) into account, along with the following recommendations:
2
+
3
+
- When submitting contributions to this repository, please make sure to discuss with the maintainer(s) the change you want to make. You can do this through an issue, or by sending an email to [[email protected]](mailto:[email protected])
4
+
5
+
- Once the change has been discussed with the maintainer(s), feel free to open a Pull Request. Please include a link to the issue you're trying to solve, or a quick summary of the discussed changes.
6
+
7
+
- If adding any new features that you think should be considered in the README file, please add that information in your Pull Request.
8
+
9
+
- Once you get an approval from any of the maintainers, please merge your Pull Request. Keep in mind that some of our Stack Builders repositories use CI/CD pipelines, so you will need to pass all of the required checks before merging.
10
+
11
+
## Getting help
12
+
Contact any of our current maintainers, or send us an email at [[email protected]](mailto:[email protected]) for more information. Thank you for contributing!
0 commit comments