This PR cherry-picks the following commits:
- fd2fbe9d2f
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Родитель
a115439b47
Коммит
0594783ed6
|
@ -28,4 +28,6 @@ export const _android = playwright._android;
|
|||
export const test = playwright.test;
|
||||
export const expect = playwright.expect;
|
||||
export const defineConfig = playwright.defineConfig;
|
||||
export const mergeTests = playwright.mergeTests;
|
||||
export const mergeExpects = playwright.mergeExpects;
|
||||
export default playwright.test;
|
||||
|
|
|
@ -632,3 +632,43 @@ test('should be able to use use execSync with a Node.js file inside a spec', asy
|
|||
'fork: hello from hellofork.js',
|
||||
]);
|
||||
});
|
||||
|
||||
test('should be able to use mergeTests/mergeExpect', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.mjs': `
|
||||
import { test as base, expect as baseExpect, mergeTests, mergeExpects } from '@playwright/test';
|
||||
const test = mergeTests(
|
||||
base.extend({
|
||||
myFixture1: '1',
|
||||
}),
|
||||
base.extend({
|
||||
myFixture2: '2',
|
||||
}),
|
||||
);
|
||||
|
||||
const expect = mergeExpects(
|
||||
baseExpect.extend({
|
||||
async toBeFoo1(page, x) {
|
||||
return { pass: true, message: () => '' };
|
||||
}
|
||||
}),
|
||||
baseExpect.extend({
|
||||
async toBeFoo2(page, x) {
|
||||
return { pass: true, message: () => '' };
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
test('merged', async ({ myFixture1, myFixture2 }) => {
|
||||
console.log('%%myFixture1: ' + myFixture1);
|
||||
console.log('%%myFixture2: ' + myFixture2);
|
||||
await expect(1).toBeFoo1();
|
||||
await expect(1).toBeFoo2();
|
||||
});
|
||||
`,
|
||||
});
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.passed).toBe(1);
|
||||
expect(result.outputLines).toContain('myFixture1: 1');
|
||||
expect(result.outputLines).toContain('myFixture2: 2');
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче