fix: setup plugins and provide proper config options
This commit is contained in:
parent
2d8c3d6800
commit
a237dfbf43
|
|
@ -48,6 +48,10 @@ export function createPlugin(): TestRunnerPlugin {
|
|||
configDir = configDirectory;
|
||||
},
|
||||
|
||||
populateDependencies: async (config: FullConfig, configDir: string) => {
|
||||
await buildBundle(config, configDir);
|
||||
},
|
||||
|
||||
begin: async (suite: Suite) => {
|
||||
const result = await buildBundle(config, configDir);
|
||||
if (!result)
|
||||
|
|
@ -69,10 +73,6 @@ export function createPlugin(): TestRunnerPlugin {
|
|||
if (stoppableServer)
|
||||
await new Promise(f => stoppableServer.stop(f));
|
||||
},
|
||||
|
||||
populateDependencies: async () => {
|
||||
await buildBundle(config, configDir);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import type { ReporterV2 } from '../reporters/reporterV2';
|
|||
export interface TestRunnerPlugin {
|
||||
name: string;
|
||||
setup?(config: FullConfig, configDir: string, reporter: ReporterV2): Promise<void>;
|
||||
populateDependencies?(): Promise<void>;
|
||||
populateDependencies?(config: FullConfig, configDir: string): Promise<void>;
|
||||
begin?(suite: Suite): Promise<void>;
|
||||
end?(): Promise<void>;
|
||||
teardown?(): Promise<void>;
|
||||
|
|
|
|||
|
|
@ -143,8 +143,13 @@ export class Runner {
|
|||
return { errors: result.errors, testFiles: [] };
|
||||
|
||||
const resolvedFiles = (files as string[]).map(file => path.resolve(process.cwd(), file));
|
||||
for (const plugin of this._config.plugins)
|
||||
await plugin.instance?.populateDependencies?.();
|
||||
|
||||
for (const plugin of this._config.plugins) {
|
||||
if (!plugin.instance)
|
||||
plugin.instance = typeof plugin.factory === 'function' ? await plugin.factory() : plugin.factory;
|
||||
|
||||
await plugin.instance.populateDependencies?.(this._config.config, this._config.configDir);
|
||||
}
|
||||
return { testFiles: affectedTestFiles(resolvedFiles) };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue