test(test-runner): add test for hiding conditional expect matchers (#10703)
This commit is contained in:
parent
aef0444ff5
commit
4a96a75fe8
|
|
@ -50,6 +50,23 @@ test('should be able to call expect.extend in config', async ({ runInlineTest })
|
||||||
expect(result.passed).toBe(1);
|
expect(result.passed).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not expand huge arrays', async ({ runInlineTest }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'expect-test.spec.ts': `
|
||||||
|
const { test } = pwt;
|
||||||
|
test('numeric ranges', () => {
|
||||||
|
const a1 = Array(100000).fill(1);
|
||||||
|
const a2 = Array(100000).fill(1);
|
||||||
|
a2[500] = 2;
|
||||||
|
test.expect(a1).toEqual(a2);
|
||||||
|
});
|
||||||
|
`
|
||||||
|
});
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.passed).toBe(0);
|
||||||
|
expect(result.output.length).toBeLessThan(100000);
|
||||||
|
});
|
||||||
|
|
||||||
test('should work with default expect prototype functions', async ({ runTSC }) => {
|
test('should work with default expect prototype functions', async ({ runTSC }) => {
|
||||||
const result = await runTSC({
|
const result = await runTSC({
|
||||||
'a.spec.ts': `
|
'a.spec.ts': `
|
||||||
|
|
@ -126,19 +143,32 @@ test('should work with custom PlaywrightTest namespace', async ({ runTSC }) => {
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should not expand huge arrays', async ({ runInlineTest }) => {
|
test('should propose only the relevant matchers when custom expect matcher classes were passed', async ({ runTSC }) => {
|
||||||
const result = await runInlineTest({
|
test.fixme();
|
||||||
'expect-test.spec.ts': `
|
const result = await runTSC({
|
||||||
const { test } = pwt;
|
'a.spec.ts': `
|
||||||
test('numeric ranges', () => {
|
const { test } = pwt;
|
||||||
const a1 = Array(100000).fill(1);
|
test('custom matchers', async ({ page }) => {
|
||||||
const a2 = Array(100000).fill(1);
|
await test.expect(page).toHaveURL('https://example.com');
|
||||||
a2[500] = 2;
|
// @ts-expect-error
|
||||||
test.expect(a1).toEqual(a2);
|
await test.expect(page).toBe(true);
|
||||||
});
|
// @ts-expect-error
|
||||||
|
await test.expect(page).toBeEnabled();
|
||||||
|
|
||||||
|
await test.expect(page.locator('foo')).toBeEnabled();
|
||||||
|
// @ts-expect-error
|
||||||
|
await test.expect(page.locator('foo')).toBe(true);
|
||||||
|
// @ts-expect-error
|
||||||
|
await test.expect(page.locator('foo')).toHaveURL('https://example.com');
|
||||||
|
|
||||||
|
const res = await page.request.get('http://i-do-definitely-not-exist.com');
|
||||||
|
await test.expect(res).toBeOK();
|
||||||
|
// @ts-expect-error
|
||||||
|
await test.expect(res).toBe(true);
|
||||||
|
// @ts-expect-error
|
||||||
|
await test.expect(res).toHaveURL('https://example.com');
|
||||||
|
});
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
expect(result.exitCode).toBe(1);
|
expect(result.exitCode).toBe(0);
|
||||||
expect(result.passed).toBe(0);
|
});
|
||||||
expect(result.output.length).toBeLessThan(100000);
|
|
||||||
});
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue