wip: more tests
This commit is contained in:
parent
7e2f5d0a18
commit
b0630a25e1
7 changed files with 114 additions and 10 deletions
37
e2e/custom-expects.ts
Normal file
37
e2e/custom-expects.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { expect, type Locator } from '@playwright/test';
|
||||
expect.extend({
|
||||
async toBeAbove(self: Locator, other: Locator) {
|
||||
const name = 'toBeAbove';
|
||||
let pass: boolean;
|
||||
let matcherResult: any;
|
||||
let selfY: number | null = null;
|
||||
let otherY: number | null = null;
|
||||
try {
|
||||
selfY = (await self.boundingBox())?.y ?? null;
|
||||
otherY = (await self.boundingBox())?.y ?? null;
|
||||
pass = selfY !== null && otherY !== null && (selfY < otherY);
|
||||
} catch (e: any) {
|
||||
matcherResult = e.matcherResult;
|
||||
pass = false;
|
||||
}
|
||||
|
||||
if (this.isNot) {
|
||||
pass =!pass;
|
||||
}
|
||||
|
||||
const message = () => this.utils.matcherHint(name, undefined, undefined, { isNot: this.isNot }) +
|
||||
'\n\n' +
|
||||
`Locator: ${self}\n` +
|
||||
`Expected: above ${other} (y=${this.utils.printExpected(otherY)})\n` +
|
||||
(matcherResult ? `Received: y=${this.utils.printReceived(selfY)}` : '');
|
||||
|
||||
return {
|
||||
message,
|
||||
pass,
|
||||
name,
|
||||
expected: (this.isNot ? '>=' : '<') + otherY,
|
||||
actual: selfY,
|
||||
};
|
||||
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue