Broken out of https://github.com/microsoft/playwright/pull/31727 as per
@dgozman's
[request](https://github.com/microsoft/playwright/pull/31727#discussion_r1685793229).
The PR goal is to remove the `suite` argument from the Component
testing's Vite Plugin. `suite` is used to enrich Vite's dependency graph
with information about dependencies between test suites and helper
files. It essentially merges the Vite graph with the
`compilationCache.ts > fileDependencies` graph, and then writes the
result back into `compilationCache.ts > externalDependencies`.
By refactoring this to make the connection on the reading end in
`collectAffectedTestFiles`, we can drop the `suite` parameter.
We didn't yet have a test that depended on the dependency graph being
connected correctly between `fileDependencies` and
`externalDepedencies`, so I've [extended an existing
test](53a539938b)
to capture that.
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
|
|
/**
|
|
* Copyright (c) Microsoft Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import { affectedTestFiles, cacheDir } from 'playwright/lib/transform/compilationCache';
|
|
import { buildBundle } from './vitePlugin';
|
|
import { resolveDirs } from './viteUtils';
|
|
import { runDevServer } from './devServer';
|
|
import type { FullConfigInternal } from 'playwright/lib/common/config';
|
|
import { removeFolderAndLogToConsole } from 'playwright/lib/runner/testServer';
|
|
|
|
export async function clearCacheCommand(config: FullConfigInternal) {
|
|
const dirs = await resolveDirs(config.configDir, config.config);
|
|
if (dirs)
|
|
await removeFolderAndLogToConsole(dirs.outDir);
|
|
await removeFolderAndLogToConsole(cacheDir);
|
|
}
|
|
|
|
export async function findRelatedTestFilesCommand(files: string[], config: FullConfigInternal) {
|
|
await buildBundle(config.config, config.configDir);
|
|
return { testFiles: affectedTestFiles(files) };
|
|
}
|
|
|
|
export async function runDevServerCommand(config: FullConfigInternal) {
|
|
return await runDevServer(config);
|
|
}
|