File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,35 @@ export default scenario("Assertion Example")
3636 .build ();
3737```
3838
39+ ## Negation with ` .not `
40+
41+ All expectation types support the ` .not ` modifier to negate assertions. The
42+ ` .not ` modifier only affects the immediately following assertion, then resets to
43+ non-negated state:
44+
45+ ``` typescript
46+ import { client , expect } from " jsr:@probitas/probitas" ;
47+
48+ const http = client .http .createHttpClient ({ url: " http://localhost:8080" });
49+ const res = await http .get (" /users/1" );
50+
51+ // .not only affects the next assertion
52+ expect (res )
53+ .not .toHaveStatus (404 ) // Negated: status is NOT 404
54+ .not .toHaveStatus (500 ) // Negated: status is NOT 500
55+ .toHaveStatus (200 ); // Not negated: status IS 200
56+
57+ // Works with generic expectations too
58+ expect (42 )
59+ .not .toBe (43 ) // Negated
60+ .toBeGreaterThan (40 ); // Not negated
61+
62+ expect (" hello world" )
63+ .not .toBe (" goodbye" )
64+ .not .toBeNull ()
65+ .toContain (" world" );
66+ ```
67+
3968## Unified expect Function
4069
4170The [ ` expect() ` ] ( /api/expect/#expect ) function automatically dispatches to the
You can’t perform that action at this time.
0 commit comments