chore: split context.ts into files (#284)
This commit is contained in:
parent
26779ceb20
commit
6e76d5e550
10 changed files with 344 additions and 289 deletions
|
|
@ -19,6 +19,7 @@ import path from 'path';
|
|||
|
||||
import { z } from 'zod';
|
||||
import { defineTool } from './tool';
|
||||
import { toBrowserOptions } from '../config';
|
||||
|
||||
const install = defineTool({
|
||||
capability: 'install',
|
||||
|
|
@ -29,7 +30,8 @@ const install = defineTool({
|
|||
},
|
||||
|
||||
handle: async context => {
|
||||
const channel = context.options.launchOptions?.channel ?? context.options.browserName ?? 'chrome';
|
||||
const browserOptions = await toBrowserOptions(context.config);
|
||||
const channel = browserOptions.launchOptions?.channel ?? browserOptions.browserName ?? 'chrome';
|
||||
const cli = path.join(require.resolve('playwright/package.json'), '..', 'cli.js');
|
||||
const child = fork(cli, ['install', channel], {
|
||||
stdio: 'pipe',
|
||||
|
|
|
|||
|
|
@ -20,11 +20,10 @@ import os from 'os';
|
|||
import { z } from 'zod';
|
||||
|
||||
import { sanitizeForFilePath } from './utils';
|
||||
import { generateLocator } from '../context';
|
||||
import { defineTool } from './tool';
|
||||
import * as javascript from '../javascript';
|
||||
|
||||
import type * as playwright from 'playwright';
|
||||
import { defineTool } from './tool';
|
||||
|
||||
const snapshot = defineTool({
|
||||
capability: 'core',
|
||||
|
|
@ -268,6 +267,9 @@ const screenshot = defineTool({
|
|||
}
|
||||
});
|
||||
|
||||
export async function generateLocator(locator: playwright.Locator): Promise<string> {
|
||||
return (locator as any)._generateLocatorString();
|
||||
}
|
||||
|
||||
export default [
|
||||
snapshot,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue