fix(matchers): make isNot required in protocol (#9436)

This commit is contained in:
Yury Semikhatsky 2021-10-12 09:01:46 -07:00 committed by GitHub
parent ded1e718b5
commit 82ff85b106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 9 deletions

View File

@ -21,7 +21,7 @@ import * as util from 'util';
import { monotonicTime } from '../utils/utils';
import { ElementHandle } from './elementHandle';
import { Frame } from './frame';
import { FilePayload, Rect, SelectOption, SelectOptionOptions, TimeoutOptions } from './types';
import { FilePayload, FrameExpectOptions, Rect, SelectOption, SelectOptionOptions, TimeoutOptions } from './types';
import { parseResult, serializeArgument } from './jsHandle';
export class Locator implements api.Locator {
@ -221,9 +221,9 @@ export class Locator implements api.Locator {
});
}
async _expect(expression: string, options: channels.FrameExpectOptions): Promise<{ pass: boolean, received?: any, log?: string[] }> {
async _expect(expression: string, options: FrameExpectOptions): Promise<{ pass: boolean, received?: any, log?: string[] }> {
return this._frame._wrapApiCall(async (channel: channels.FrameChannel) => {
const params: any = { selector: this._selector, expression, ...options };
const params: channels.FrameExpectParams = { selector: this._selector, expression, ...options, isNot: !!options.isNot };
if (options.expectedValue)
params.expectedValue = serializeArgument(options.expectedValue);
const result = (await channel.expect(params));

View File

@ -118,3 +118,5 @@ export type SelectorEngine = {
export type RemoteAddr = channels.RemoteAddr;
export type SecurityDetails = channels.SecurityDetails;
export type FrameExpectOptions = channels.FrameExpectOptions & { isNot?: boolean };

View File

@ -2221,7 +2221,7 @@ export type FrameExpectParams = {
expectedNumber?: number,
expectedValue?: SerializedArgument,
useInnerText?: boolean,
isNot?: boolean,
isNot: boolean,
timeout?: number,
};
export type FrameExpectOptions = {
@ -2230,7 +2230,6 @@ export type FrameExpectOptions = {
expectedNumber?: number,
expectedValue?: SerializedArgument,
useInnerText?: boolean,
isNot?: boolean,
timeout?: number,
};
export type FrameExpectResult = {

View File

@ -1799,7 +1799,7 @@ Frame:
expectedNumber: number?
expectedValue: SerializedArgument?
useInnerText: boolean?
isNot: boolean?
isNot: boolean
timeout: number?
returns:
pass: boolean

View File

@ -908,7 +908,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
expectedNumber: tOptional(tNumber),
expectedValue: tOptional(tType('SerializedArgument')),
useInnerText: tOptional(tBoolean),
isNot: tOptional(tBoolean),
isNot: tBoolean,
timeout: tOptional(tNumber),
});
scheme.WorkerEvaluateExpressionParams = tObject({

View File

@ -14,8 +14,8 @@
* limitations under the License.
*/
import * as channels from 'playwright-core/src/protocol/channels';
import { Locator, Page } from 'playwright-core';
import { FrameExpectOptions } from 'playwright-core/src/client/types';
import { constructURLBasedOnBaseURL } from 'playwright-core/src/utils/utils';
import type { Expect } from '../types';
import { toBeTruthy } from './toBeTruthy';
@ -23,7 +23,7 @@ import { toEqual } from './toEqual';
import { toExpectedTextValues, toMatchText } from './toMatchText';
interface LocatorEx extends Locator {
_expect(expression: string, options: channels.FrameExpectOptions): Promise<{ pass: boolean, received?: any, log?: string[] }>;
_expect(expression: string, options: FrameExpectOptions): Promise<{ pass: boolean, received?: any, log?: string[] }>;
}
export function toBeChecked(