docs: add GenericAssertions.toBeOneOf
This commit is contained in:
parent
2c49231568
commit
ba140b1b83
|
|
@ -227,6 +227,30 @@ expect(value).toBeNull();
|
|||
```
|
||||
|
||||
|
||||
## method: GenericAssertions.toBeOneOf
|
||||
* since: v1.49.1
|
||||
|
||||
Ensures that value is deeply equal to one of the elements in the expected array.
|
||||
|
||||
**Usage**
|
||||
|
||||
```js
|
||||
const value = 2;
|
||||
expect(value).toBeOneOf([1, 2, 3]);
|
||||
expect(value).not.toBeOneOf([4, 5, 6]);
|
||||
|
||||
const obj = { a: 1 };
|
||||
expect(obj).toBeOneOf([{ a: 1 }, { b: 2 }]);
|
||||
expect(obj).not.toBeOneOf([{ a: 2 }, { b: 3 }]);
|
||||
```
|
||||
|
||||
### param: GenericAssertions.toBeOneOf.expected
|
||||
* since: v1.49.1
|
||||
- `expected` <[Array]<[any]>>
|
||||
|
||||
Expected array to match against.
|
||||
|
||||
|
||||
|
||||
## method: GenericAssertions.toBeTruthy
|
||||
* since: v1.9
|
||||
|
|
|
|||
|
|
@ -222,6 +222,11 @@ export interface Matchers<R extends void | Promise<void>, T = unknown> {
|
|||
* So use `.toBeNull()` when you want to check that something is null.
|
||||
*/
|
||||
toBeNull(): R;
|
||||
/**
|
||||
* Use when you don't care what a value is, you just want to ensure a value
|
||||
* is not null. You will often see it in tests for checking that a callback
|
||||
*/
|
||||
toBeOneOf(expected: Array<unknown>): R;
|
||||
/**
|
||||
* Use when you don't care what a value is, you just want to ensure a value
|
||||
* is true in a boolean context. In JavaScript, there are six falsy values:
|
||||
|
|
|
|||
18
packages/playwright/types/test.d.ts
vendored
18
packages/playwright/types/test.d.ts
vendored
|
|
@ -7040,6 +7040,24 @@ interface GenericAssertions<R> {
|
|||
*
|
||||
*/
|
||||
toBeNull(): R;
|
||||
/**
|
||||
* Ensures that value is deeply equal to one of the elements in the expected array.
|
||||
*
|
||||
* **Usage**
|
||||
*
|
||||
* ```js
|
||||
* const value = 2;
|
||||
* expect(value).toBeOneOf([1, 2, 3]);
|
||||
* expect(value).not.toBeOneOf([4, 5, 6]);
|
||||
*
|
||||
* const obj = { a: 1 };
|
||||
* expect(obj).toBeOneOf([{ a: 1 }, { b: 2 }]);
|
||||
* expect(obj).not.toBeOneOf([{ a: 2 }, { b: 3 }]);
|
||||
* ```
|
||||
*
|
||||
* @param expected Expected array to match against.
|
||||
*/
|
||||
toBeOneOf(expected: unknown[]): R;
|
||||
/**
|
||||
* Ensures that value is true in a boolean context, **anything but** `false`, `0`, `''`, `null`, `undefined` or `NaN`.
|
||||
* Use this method when you don't care about the specific value.
|
||||
|
|
|
|||
1
utils/generate_types/overrides-test.d.ts
vendored
1
utils/generate_types/overrides-test.d.ts
vendored
|
|
@ -314,6 +314,7 @@ interface GenericAssertions<R> {
|
|||
toBeLessThanOrEqual(expected: number | bigint): R;
|
||||
toBeNaN(): R;
|
||||
toBeNull(): R;
|
||||
toBeOneOf(expected: unknown[]): R;
|
||||
toBeTruthy(): R;
|
||||
toBeUndefined(): R;
|
||||
toContain(expected: string): R;
|
||||
|
|
|
|||
Loading…
Reference in a new issue