fix(expect): expect.not types (#15487)
This commit is contained in:
Родитель
67a2f948fd
Коммит
98ea418124
|
@ -327,7 +327,7 @@ Playwright Trace Viewer is now **available online** at https://trace.playwright.
|
|||
|
||||
![image](https://user-images.githubusercontent.com/746130/141877402-e486643d-72c7-4db3-8844-ed2072c5d676.png)
|
||||
|
||||
## Ubuntu ARM64 support + more
|
||||
### Ubuntu ARM64 support + more
|
||||
|
||||
- Playwright now supports **Ubuntu 20.04 ARM64**. You can now run Playwright tests inside Docker on Apple M1 and on Raspberry Pi.
|
||||
- You can now use Playwright to install stable version of Edge on Linux:
|
||||
|
|
|
@ -3029,6 +3029,23 @@ import type { Suite } from '@playwright/test/types/testReporter';
|
|||
|
||||
type AsymmetricMatcher = Record<string, any>;
|
||||
|
||||
type AsymmetricMatchers = {
|
||||
any(sample: unknown): AsymmetricMatcher;
|
||||
anything(): AsymmetricMatcher;
|
||||
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;
|
||||
closeTo(sample: number, precision?: number): AsymmetricMatcher;
|
||||
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher;
|
||||
stringContaining(sample: string): AsymmetricMatcher;
|
||||
stringMatching(sample: string | RegExp): AsymmetricMatcher;
|
||||
}
|
||||
|
||||
type Inverse<Matchers> = {
|
||||
/**
|
||||
* Inverse next matcher. If you know how to test something, `.not` lets you test its opposite.
|
||||
*/
|
||||
not: Matchers;
|
||||
};
|
||||
|
||||
type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N;
|
||||
type ExtraMatchers<T, Type, Matchers> = T extends Type ? Matchers : IfAny<T, Matchers, {}>;
|
||||
|
||||
|
@ -3054,6 +3071,16 @@ type MakeMatchers<R, T> = BaseMatchers<R, T> & {
|
|||
ExtraMatchers<T, Locator, LocatorAssertions> &
|
||||
ExtraMatchers<T, APIResponse, APIResponseAssertions>;
|
||||
|
||||
type BaseExpect = {
|
||||
// Removed following methods because they rely on a test-runner integration from Jest which we don't support:
|
||||
// assertions(numberOfAssertions: number): void;
|
||||
// extractExpectedAssertionsErrors(): ExpectedAssertionsErrors;
|
||||
// hasAssertions(): void;
|
||||
extend(matchers: any): void;
|
||||
getState(): expectType.MatcherState;
|
||||
setState(state: Partial<expectType.MatcherState>): void;
|
||||
}
|
||||
|
||||
export type Expect = {
|
||||
<T = unknown>(actual: T, messageOrOptions?: string | { message?: string }): MakeMatchers<void, T>;
|
||||
soft: <T = unknown>(actual: T, messageOrOptions?: string | { message?: string }) => MakeMatchers<void, T>;
|
||||
|
@ -3063,23 +3090,9 @@ export type Expect = {
|
|||
*/
|
||||
not: BaseMatchers<Promise<void>, T>;
|
||||
};
|
||||
|
||||
extend(arg0: any): void;
|
||||
getState(): expectType.MatcherState;
|
||||
setState(state: Partial<expectType.MatcherState>): void;
|
||||
any(expectedObject: any): AsymmetricMatcher;
|
||||
anything(): AsymmetricMatcher;
|
||||
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;
|
||||
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher;
|
||||
stringContaining(expected: string): AsymmetricMatcher;
|
||||
stringMatching(expected: string | RegExp): AsymmetricMatcher;
|
||||
/**
|
||||
* Removed following methods because they rely on a test-runner integration from Jest which we don't support:
|
||||
* - assertions()
|
||||
* - extractExpectedAssertionsErrors()
|
||||
* – hasAssertions()
|
||||
*/
|
||||
};
|
||||
} & BaseExpect &
|
||||
AsymmetricMatchers &
|
||||
Inverse<Omit<AsymmetricMatchers, 'any' | 'anything'>>;
|
||||
|
||||
type Awaited<T> = T extends PromiseLike<infer U> ? U : T;
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ test('should work with default expect prototype functions', async ({ runTSC, run
|
|||
);
|
||||
expect('foo').toEqual(expect.any(String));
|
||||
expect('foo').toEqual(expect.anything());
|
||||
expect('hello world').toEqual(expect.not.stringContaining('text'));
|
||||
});
|
||||
`;
|
||||
{
|
||||
|
|
|
@ -99,7 +99,6 @@ class TypesGenerator {
|
|||
return this.writeComment(docClass.comment) + '\n';
|
||||
}, (className, methodName, overloadIndex) => {
|
||||
if (className === 'SuiteFunction' && methodName === '__call') {
|
||||
console.log(className, methodName, overloadIndex);
|
||||
const cls = this.documentation.classes.get('Test');
|
||||
const method = cls.membersArray.find(m => m.alias === 'describe' && m.overloadIndex === overloadIndex);
|
||||
return this.memberJSDOC(method, ' ').trimLeft();
|
||||
|
|
|
@ -256,6 +256,23 @@ import type { Suite } from '@playwright/test/types/testReporter';
|
|||
|
||||
type AsymmetricMatcher = Record<string, any>;
|
||||
|
||||
type AsymmetricMatchers = {
|
||||
any(sample: unknown): AsymmetricMatcher;
|
||||
anything(): AsymmetricMatcher;
|
||||
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;
|
||||
closeTo(sample: number, precision?: number): AsymmetricMatcher;
|
||||
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher;
|
||||
stringContaining(sample: string): AsymmetricMatcher;
|
||||
stringMatching(sample: string | RegExp): AsymmetricMatcher;
|
||||
}
|
||||
|
||||
type Inverse<Matchers> = {
|
||||
/**
|
||||
* Inverse next matcher. If you know how to test something, `.not` lets you test its opposite.
|
||||
*/
|
||||
not: Matchers;
|
||||
};
|
||||
|
||||
type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N;
|
||||
type ExtraMatchers<T, Type, Matchers> = T extends Type ? Matchers : IfAny<T, Matchers, {}>;
|
||||
|
||||
|
@ -281,6 +298,16 @@ type MakeMatchers<R, T> = BaseMatchers<R, T> & {
|
|||
ExtraMatchers<T, Locator, LocatorAssertions> &
|
||||
ExtraMatchers<T, APIResponse, APIResponseAssertions>;
|
||||
|
||||
type BaseExpect = {
|
||||
// Removed following methods because they rely on a test-runner integration from Jest which we don't support:
|
||||
// assertions(numberOfAssertions: number): void;
|
||||
// extractExpectedAssertionsErrors(): ExpectedAssertionsErrors;
|
||||
// hasAssertions(): void;
|
||||
extend(matchers: any): void;
|
||||
getState(): expectType.MatcherState;
|
||||
setState(state: Partial<expectType.MatcherState>): void;
|
||||
}
|
||||
|
||||
export type Expect = {
|
||||
<T = unknown>(actual: T, messageOrOptions?: string | { message?: string }): MakeMatchers<void, T>;
|
||||
soft: <T = unknown>(actual: T, messageOrOptions?: string | { message?: string }) => MakeMatchers<void, T>;
|
||||
|
@ -290,23 +317,9 @@ export type Expect = {
|
|||
*/
|
||||
not: BaseMatchers<Promise<void>, T>;
|
||||
};
|
||||
|
||||
extend(arg0: any): void;
|
||||
getState(): expectType.MatcherState;
|
||||
setState(state: Partial<expectType.MatcherState>): void;
|
||||
any(expectedObject: any): AsymmetricMatcher;
|
||||
anything(): AsymmetricMatcher;
|
||||
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;
|
||||
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher;
|
||||
stringContaining(expected: string): AsymmetricMatcher;
|
||||
stringMatching(expected: string | RegExp): AsymmetricMatcher;
|
||||
/**
|
||||
* Removed following methods because they rely on a test-runner integration from Jest which we don't support:
|
||||
* - assertions()
|
||||
* - extractExpectedAssertionsErrors()
|
||||
* – hasAssertions()
|
||||
*/
|
||||
};
|
||||
} & BaseExpect &
|
||||
AsymmetricMatchers &
|
||||
Inverse<Omit<AsymmetricMatchers, 'any' | 'anything'>>;
|
||||
|
||||
type Awaited<T> = T extends PromiseLike<infer U> ? U : T;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче