remove dev-server hook
This commit is contained in:
parent
c4da68d7ce
commit
92b6b52c14
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
const { test: baseTest, expect, devices, defineConfig: originalDefineConfig } = require('playwright/test');
|
||||
const { fixtures } = require('./lib/mount');
|
||||
const { runDevServerCommand } = require('./lib/cliOverrides');
|
||||
const { createPlugin } = require('./lib/vitePlugin');
|
||||
|
||||
const defineConfig = (...configs) => {
|
||||
|
|
@ -29,9 +28,6 @@ const defineConfig = (...configs) => {
|
|||
babelPlugins: [
|
||||
[require.resolve('./lib/tsxTransform')]
|
||||
],
|
||||
cli: {
|
||||
'dev-server': runDevServerCommand,
|
||||
},
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import type { ComponentRegistry } from './viteUtils';
|
|||
import { createConfig, frameworkConfig, hasJSComponents, populateComponentsFromTests, resolveDirs, resolveEndpoint, transformIndexFile } from './viteUtils';
|
||||
import { resolveHook } from 'playwright/lib/transform/transform';
|
||||
import { removeFolderAndLogToConsole } from 'playwright/lib/runner/testServer';
|
||||
import { runDevServer } from './devServer';
|
||||
import type { FullConfigInternal } from 'playwright/lib/common/config';
|
||||
|
||||
const log = debug('pw:vite');
|
||||
|
||||
|
|
@ -79,6 +81,10 @@ export function createPlugin(): TestRunnerPlugin {
|
|||
const dirs = await resolveDirs(configDir, config);
|
||||
if (dirs)
|
||||
await removeFolderAndLogToConsole(dirs.outDir);
|
||||
},
|
||||
|
||||
runDevServer: async (config: FullConfigInternal) => {
|
||||
await runDevServer(config);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
import type { FullConfig, Suite } from '../../types/testReporter';
|
||||
import type { FullConfigInternal } from '../common/config';
|
||||
import type { ReporterV2 } from '../reporters/reporterV2';
|
||||
|
||||
export interface TestRunnerPlugin {
|
||||
|
|
@ -26,7 +27,7 @@ export interface TestRunnerPlugin {
|
|||
teardown?(): Promise<void>;
|
||||
|
||||
clearCache?(): Promise<void>;
|
||||
runDevServer?(): Promise<void>;
|
||||
runDevServer?(config: FullConfigInternal): Promise<() => Promise<void>>;
|
||||
}
|
||||
|
||||
export type TestRunnerPluginRegistration = {
|
||||
|
|
|
|||
|
|
@ -97,8 +97,10 @@ function addDevServerCommand(program: Command) {
|
|||
const configInternal = await loadConfigFromFileRestartIfNeeded(options.config);
|
||||
if (!configInternal)
|
||||
return;
|
||||
const { config } = configInternal;
|
||||
const implementation = (config as any)['@playwright/test']?.['cli']?.['dev-server'];
|
||||
|
||||
await testServer.setupPlugins(configInternal);
|
||||
|
||||
const implementation = configInternal.plugins.map(p => p.instance!).find(p => p.runDevServer)?.runDevServer;
|
||||
if (implementation) {
|
||||
await implementation(configInternal);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,10 @@ class TestServerDispatcher implements TestServerInterface {
|
|||
reporter.onError(error!);
|
||||
return { status: 'failed', report };
|
||||
}
|
||||
const devServerCommand = (config.config as any)['@playwright/test']?.['cli']?.['dev-server'];
|
||||
|
||||
await setupPlugins(config);
|
||||
|
||||
const devServerCommand = config.plugins.map(p => p.instance!).find(p => p.runDevServer)?.runDevServer;
|
||||
if (!devServerCommand) {
|
||||
reporter.onError({ message: 'No dev-server command found in the configuration' });
|
||||
return { status: 'failed', report };
|
||||
|
|
@ -515,7 +518,7 @@ export async function resolveCtDirs(config: FullConfigInternal) {
|
|||
};
|
||||
}
|
||||
|
||||
export async function clearCacheAndLogToConsole(config: FullConfigInternal) {
|
||||
export async function setupPlugins(config: FullConfigInternal) {
|
||||
const errors: reporterTypes.TestError[] = [];
|
||||
const errorReporter = wrapReporterAsV2({
|
||||
onError(error: reporterTypes.TestError) {
|
||||
|
|
@ -526,6 +529,10 @@ export async function clearCacheAndLogToConsole(config: FullConfigInternal) {
|
|||
await taskRunner.run(new TestRun(config), 0);
|
||||
if (errors.length > 0)
|
||||
throw new Error('Failed to clear cache: ' + errors);
|
||||
}
|
||||
|
||||
export async function clearCacheAndLogToConsole(config: FullConfigInternal) {
|
||||
await setupPlugins(config);
|
||||
|
||||
for (const plugin of config.plugins) {
|
||||
if (!plugin.instance)
|
||||
|
|
|
|||
Loading…
Reference in a new issue