mirror of
https://github.com/microsoft/playwright.git
synced 2024-10-27 05:46:28 +03:00
fix(codegen): comment-out generated expects for library scripts (#28118)
- reverts "fix(codegen): generate expect import for library (https://github.com/microsoft/playwright/pull/28107)"; - comments-out generated expects.
This commit is contained in:
parent
36b99c3437
commit
16aee8b5d0
@ -126,12 +126,12 @@ export class JavaScriptLanguageGenerator implements LanguageGenerator {
|
||||
case 'select':
|
||||
return `await ${subject}.${this._asLocator(action.selector)}.selectOption(${formatObject(action.options.length > 1 ? action.options : action.options[0])});`;
|
||||
case 'assertText':
|
||||
return `await expect(${subject}.${this._asLocator(action.selector)}).${action.substring ? 'toContainText' : 'toHaveText'}(${quote(action.text)});`;
|
||||
return `${this._isTest ? '' : '// '}await expect(${subject}.${this._asLocator(action.selector)}).${action.substring ? 'toContainText' : 'toHaveText'}(${quote(action.text)});`;
|
||||
case 'assertChecked':
|
||||
return `await expect(${subject}.${this._asLocator(action.selector)})${action.checked ? '' : '.not'}.toBeChecked();`;
|
||||
return `${this._isTest ? '' : '// '}await expect(${subject}.${this._asLocator(action.selector)})${action.checked ? '' : '.not'}.toBeChecked();`;
|
||||
case 'assertValue': {
|
||||
const assertion = action.value ? `toHaveValue(${quote(action.value)})` : `toBeEmpty()`;
|
||||
return `await expect(${subject}.${this._asLocator(action.selector)}).${assertion};`;
|
||||
return `${this._isTest ? '' : '// '}await expect(${subject}.${this._asLocator(action.selector)}).${assertion};`;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,7 +169,7 @@ ${useText ? '\ntest.use(' + useText + ');\n' : ''}
|
||||
generateStandaloneHeader(options: LanguageGeneratorOptions): string {
|
||||
const formatter = new JavaScriptFormatter();
|
||||
formatter.add(`
|
||||
const { expect, ${options.browserName}${options.deviceName ? ', devices' : ''} } = require('@playwright/test');
|
||||
const { ${options.browserName}${options.deviceName ? ', devices' : ''} } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await ${options.browserName}.launch(${formatObjectOrVoid(options.launchOptions)});
|
||||
|
@ -26,7 +26,7 @@ const launchOptions = (channel: string) => {
|
||||
|
||||
test('should print the correct imports and context options', async ({ browserName, channel, runCLI }) => {
|
||||
const cli = runCLI(['--target=javascript', emptyHTML]);
|
||||
const expectedResult = `const { expect, ${browserName} } = require('@playwright/test');
|
||||
const expectedResult = `const { ${browserName} } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await ${browserName}.launch({
|
||||
@ -38,7 +38,7 @@ test('should print the correct imports and context options', async ({ browserNam
|
||||
|
||||
test('should print the correct context options for custom settings', async ({ browserName, channel, runCLI }) => {
|
||||
const cli = runCLI(['--color-scheme=light', '--target=javascript', emptyHTML]);
|
||||
const expectedResult = `const { expect, ${browserName} } = require('@playwright/test');
|
||||
const expectedResult = `const { ${browserName} } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await ${browserName}.launch({
|
||||
@ -55,7 +55,7 @@ test('should print the correct context options when using a device', async ({ br
|
||||
test.skip(browserName !== 'chromium');
|
||||
|
||||
const cli = runCLI(['--device=Pixel 2', '--target=javascript', emptyHTML]);
|
||||
const expectedResult = `const { expect, chromium, devices } = require('@playwright/test');
|
||||
const expectedResult = `const { chromium, devices } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({
|
||||
@ -71,7 +71,7 @@ test('should print the correct context options when using a device and additiona
|
||||
test.skip(browserName !== 'webkit');
|
||||
|
||||
const cli = runCLI(['--color-scheme=light', '--device=iPhone 11', '--target=javascript', emptyHTML]);
|
||||
const expectedResult = `const { expect, webkit, devices } = require('@playwright/test');
|
||||
const expectedResult = `const { webkit, devices } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await webkit.launch({
|
||||
@ -91,7 +91,7 @@ test('should save the codegen output to a file if specified', async ({ browserNa
|
||||
});
|
||||
await cli.waitForCleanExit();
|
||||
const content = fs.readFileSync(tmpFile);
|
||||
expect(content.toString()).toBe(`const { expect, ${browserName} } = require('@playwright/test');
|
||||
expect(content.toString()).toBe(`const { ${browserName} } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await ${browserName}.launch({
|
||||
@ -113,7 +113,7 @@ test('should print load/save storageState', async ({ browserName, channel, runCL
|
||||
const saveFileName = testInfo.outputPath('save.json');
|
||||
await fs.promises.writeFile(loadFileName, JSON.stringify({ cookies: [], origins: [] }), 'utf8');
|
||||
const cli = runCLI([`--load-storage=${loadFileName}`, `--save-storage=${saveFileName}`, '--target=javascript', emptyHTML]);
|
||||
const expectedResult1 = `const { expect, ${browserName} } = require('@playwright/test');
|
||||
const expectedResult1 = `const { ${browserName} } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await ${browserName}.launch({
|
||||
|
Loading…
Reference in New Issue
Block a user