fixes
This commit is contained in:
parent
0ce5d82f31
commit
7b05c4ebfc
|
|
@ -146,7 +146,7 @@ export class JavaScriptLanguageGenerator implements LanguageGenerator {
|
||||||
${useText ? '\ntest.use(' + useText + ');\n' : ''}
|
${useText ? '\ntest.use(' + useText + ');\n' : ''}
|
||||||
test('test', async ({ page }) => {`);
|
test('test', async ({ page }) => {`);
|
||||||
if (options.contextOptions.recordHar)
|
if (options.contextOptions.recordHar)
|
||||||
formatter.add(` await page.routeFromHAR('${options.contextOptions.recordHar.path}');`);
|
formatter.add(` await page.routeFromHAR(${quote(options.contextOptions.recordHar.path)});`);
|
||||||
return formatter.format();
|
return formatter.format();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ ${useText ? '\ntest.use(' + useText + ');\n' : ''}
|
||||||
const browser = await ${options.browserName}.launch(${formatObjectOrVoid(options.launchOptions)});
|
const browser = await ${options.browserName}.launch(${formatObjectOrVoid(options.launchOptions)});
|
||||||
const context = await browser.newContext(${formatContextOptions(options.contextOptions, options.deviceName, false)});`);
|
const context = await browser.newContext(${formatContextOptions(options.contextOptions, options.deviceName, false)});`);
|
||||||
if (options.contextOptions.recordHar)
|
if (options.contextOptions.recordHar)
|
||||||
formatter.add(` await context.routeFromHAR('${options.contextOptions.recordHar.path}');`);
|
formatter.add(` await context.routeFromHAR(${quote(options.contextOptions.recordHar.path)});`);
|
||||||
return formatter.format();
|
return formatter.format();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ export function toBeVisible(
|
||||||
const expected = visible ? 'visible' : 'hidden';
|
const expected = visible ? 'visible' : 'hidden';
|
||||||
const unexpected = visible ? 'hidden' : 'visible';
|
const unexpected = visible ? 'hidden' : 'visible';
|
||||||
const arg = visible ? '' : '{ visible: false }';
|
const arg = visible ? '' : '{ visible: false }';
|
||||||
return toBeTruthy.call(this, 'toBeVisibleFoo', locator, 'Locator', expected, unexpected, arg, async (isNot, timeout) => {
|
return toBeTruthy.call(this, 'toBeVisible', locator, 'Locator', expected, unexpected, arg, async (isNot, timeout) => {
|
||||||
return await locator._expect(visible ? 'to.be.visible' : 'to.be.hidden', { isNot, timeout });
|
return await locator._expect(visible ? 'to.be.visible' : 'to.be.hidden', { isNot, timeout });
|
||||||
}, options);
|
}, options);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ await context.StorageStateAsync(new BrowserContextStorageStateOptions
|
||||||
|
|
||||||
test('should work with --save-har', async ({ runCLI }, testInfo) => {
|
test('should work with --save-har', async ({ runCLI }, testInfo) => {
|
||||||
const harFileName = testInfo.outputPath('har.har');
|
const harFileName = testInfo.outputPath('har.har');
|
||||||
const expectedResult = `await context.RouteFromHARAsync("${harFileName}");`
|
const expectedResult = `await context.RouteFromHARAsync(${JSON.stringify(harFileName)});`;
|
||||||
const cli = runCLI(['--target=csharp', `--save-har=${harFileName}`], {
|
const cli = runCLI(['--target=csharp', `--save-har=${harFileName}`], {
|
||||||
autoExitWhen: expectedResult,
|
autoExitWhen: expectedResult,
|
||||||
});
|
});
|
||||||
|
|
@ -201,7 +201,7 @@ for (const testFramework of ['nunit', 'mstest'] as const) {
|
||||||
|
|
||||||
test(`should work with --save-har in ${testFramework}`, async ({ runCLI }, testInfo) => {
|
test(`should work with --save-har in ${testFramework}`, async ({ runCLI }, testInfo) => {
|
||||||
const harFileName = testInfo.outputPath('har.har');
|
const harFileName = testInfo.outputPath('har.har');
|
||||||
const expectedResult = `await context.RouteFromHARAsync("${harFileName}");`
|
const expectedResult = `await context.RouteFromHARAsync("${harFileName}");`;
|
||||||
const cli = runCLI([`--target=csharp-${testFramework}`, `--save-har=${harFileName}`], {
|
const cli = runCLI([`--target=csharp-${testFramework}`, `--save-har=${harFileName}`], {
|
||||||
autoExitWhen: expectedResult,
|
autoExitWhen: expectedResult,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ test('should print load/save storage_state', async ({ runCLI, browserName }, tes
|
||||||
|
|
||||||
test('should work with --save-har', async ({ runCLI }, testInfo) => {
|
test('should work with --save-har', async ({ runCLI }, testInfo) => {
|
||||||
const harFileName = testInfo.outputPath('har.har');
|
const harFileName = testInfo.outputPath('har.har');
|
||||||
const expectedResult = `context.routeFromHAR("${harFileName}");`;
|
const expectedResult = `context.routeFromHAR(${JSON.stringify(harFileName)});`;
|
||||||
const cli = runCLI(['--target=java', `--save-har=${harFileName}`], {
|
const cli = runCLI(['--target=java', `--save-har=${harFileName}`], {
|
||||||
autoExitWhen: expectedResult,
|
autoExitWhen: expectedResult,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ test('test', async ({ page }) => {`;
|
||||||
|
|
||||||
test('should not generate recordHAR with --save-har', async ({ runCLI }, testInfo) => {
|
test('should not generate recordHAR with --save-har', async ({ runCLI }, testInfo) => {
|
||||||
const harFileName = testInfo.outputPath('har.har');
|
const harFileName = testInfo.outputPath('har.har');
|
||||||
const expectedResult = ` await page.routeFromHAR('${harFileName}');`;
|
const expectedResult = ` await page.routeFromHAR('${harFileName.replace(/\\/g, '\\\\')}');`;
|
||||||
const cli = runCLI(['--target=playwright-test', `--save-har=${harFileName}`], {
|
const cli = runCLI(['--target=playwright-test', `--save-har=${harFileName}`], {
|
||||||
autoExitWhen: expectedResult,
|
autoExitWhen: expectedResult,
|
||||||
});
|
});
|
||||||
|
|
@ -99,7 +99,7 @@ test('should not generate recordHAR with --save-har', async ({ runCLI }, testInf
|
||||||
test('should generate routeFromHAR with --save-har', async ({ runCLI }, testInfo) => {
|
test('should generate routeFromHAR with --save-har', async ({ runCLI }, testInfo) => {
|
||||||
const harFileName = testInfo.outputPath('har.har');
|
const harFileName = testInfo.outputPath('har.har');
|
||||||
const expectedResult = `test('test', async ({ page }) => {
|
const expectedResult = `test('test', async ({ page }) => {
|
||||||
await page.routeFromHAR('${harFileName}');
|
await page.routeFromHAR('${harFileName.replace(/\\/g, '\\\\')}');
|
||||||
});`;
|
});`;
|
||||||
const cli = runCLI(['--target=playwright-test', `--save-har=${harFileName}`], {
|
const cli = runCLI(['--target=playwright-test', `--save-har=${harFileName}`], {
|
||||||
autoExitWhen: expectedResult,
|
autoExitWhen: expectedResult,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue