fix: await plugin.configure (#13834)
This commit is contained in:
parent
f486ce8c06
commit
4984878411
|
|
@ -150,7 +150,7 @@ async function runTests(args: string[], opts: { [key: string]: any }) {
|
|||
return;
|
||||
|
||||
const runner = new Runner(overrides, { defaultConfig });
|
||||
const config = resolvedConfigFile ? await runner.loadConfigFromResolvedFile(resolvedConfigFile) : runner.loadEmptyConfig(configFileOrDirectory);
|
||||
const config = resolvedConfigFile ? await runner.loadConfigFromResolvedFile(resolvedConfigFile) : await runner.loadEmptyConfig(configFileOrDirectory);
|
||||
if (('projects' in config) && opts.browser)
|
||||
throw new Error(`Cannot use --browser option when configuration file defines projects. Specify browserName in the projects instead.`);
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export class Loader {
|
|||
if ('file' in data.configFile)
|
||||
await loader.loadConfigFile(data.configFile.file);
|
||||
else
|
||||
loader.loadEmptyConfig(data.configFile.configDir);
|
||||
await loader.loadEmptyConfig(data.configFile.configDir);
|
||||
return loader;
|
||||
}
|
||||
|
||||
|
|
@ -67,23 +67,23 @@ export class Loader {
|
|||
config = config['default'];
|
||||
this._configFile = file;
|
||||
const rawConfig = { ...config };
|
||||
this._processConfigObject(config, path.dirname(file));
|
||||
await this._processConfigObject(config, path.dirname(file));
|
||||
return rawConfig;
|
||||
}
|
||||
|
||||
loadEmptyConfig(configDir: string): Config {
|
||||
this._processConfigObject({}, configDir);
|
||||
async loadEmptyConfig(configDir: string): Promise<Config> {
|
||||
await this._processConfigObject({}, configDir);
|
||||
return {};
|
||||
}
|
||||
|
||||
private _processConfigObject(config: Config, configDir: string) {
|
||||
private async _processConfigObject(config: Config, configDir: string) {
|
||||
if (config.webServer) {
|
||||
config.plugins = config.plugins || [];
|
||||
config.plugins.push(_legacyWebServer(config.webServer));
|
||||
}
|
||||
|
||||
for (const plugin of config.plugins || [])
|
||||
plugin.configure?.(config, configDir);
|
||||
await plugin.configure?.(config, configDir);
|
||||
|
||||
this._configDir = configDir;
|
||||
const packageJsonPath = getPackageJsonPath(configDir);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ export class Runner {
|
|||
return await this._loader.loadConfigFile(resolvedConfigFile);
|
||||
}
|
||||
|
||||
loadEmptyConfig(configFileOrDirectory: string): Config {
|
||||
loadEmptyConfig(configFileOrDirectory: string): Promise<Config> {
|
||||
return this._loader.loadEmptyConfig(configFileOrDirectory);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,24 +44,37 @@ test('event order', async ({ runInlineTest }, testInfo) => {
|
|||
`,
|
||||
'globalSetup.ts': `
|
||||
import log from './log';
|
||||
const setup = () => log('globalSetup');
|
||||
const setup = async () => {
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
log('globalSetup');
|
||||
}
|
||||
export default setup;
|
||||
`,
|
||||
'globalTeardown.ts': `
|
||||
import log from './log';
|
||||
const teardown = () => log('globalTeardown');
|
||||
const teardown = async () => {
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
log('globalTeardown');
|
||||
}
|
||||
export default teardown;
|
||||
`,
|
||||
'plugin.ts': `
|
||||
import log from './log';
|
||||
export const myPlugin = (name: string) => ({
|
||||
configure: async (config) => {
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
log(name, 'configure');
|
||||
config.use = (config.use || {});
|
||||
config.use.baseURL = (config.use.baseURL || '') + name + ' | ';
|
||||
},
|
||||
setup: async () => log(name, 'setup'),
|
||||
teardown: async () => log(name, 'teardown'),
|
||||
setup: async () => {
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
log(name, 'setup');
|
||||
},
|
||||
teardown: async () => {
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
log(name, 'teardown');
|
||||
},
|
||||
});
|
||||
`,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue