api: Fix so we can handle scripting in the API (#3840)
* handle multi in api * fix page summary URL
This commit is contained in:
parent
b923d4a2b4
commit
97c9a7ff5d
|
|
@ -30,6 +30,14 @@ async function api(options) {
|
|||
// a forever loop
|
||||
delete apiOptions.api.hostname;
|
||||
|
||||
// Add support for running multi tests
|
||||
if (options.multi) {
|
||||
const scripting = await readFileSync(
|
||||
new URL(resolve(process.cwd(), options._[0]), import.meta.url)
|
||||
);
|
||||
apiOptions.api.scripting = scripting.toString();
|
||||
}
|
||||
|
||||
if (apiOptions.mobile) {
|
||||
apiOptions.api.testType = 'emulatedMobile';
|
||||
} else if (apiOptions.android) {
|
||||
|
|
@ -40,15 +48,6 @@ async function api(options) {
|
|||
apiOptions.api.testType = 'desktop';
|
||||
}
|
||||
|
||||
/*
|
||||
// Add support for running multi tests
|
||||
if (options.multi) {
|
||||
const scripting = await readFileSync(
|
||||
new URL(resolve(process.cwd(), options._[0]), import.meta.url)
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
if (options.config) {
|
||||
const config = JSON.parse(
|
||||
await readFileSync(
|
||||
|
|
|
|||
|
|
@ -161,16 +161,20 @@ export async function run(options) {
|
|||
console.log(options.summary.out); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
let pageSummaryUrl = '';
|
||||
if (resultUrls.hasBaseUrl() && options.multi) {
|
||||
pageSummaryUrl = resultUrls.reportSummaryUrl() + '/index.html';
|
||||
} else if (resultUrls.hasBaseUrl() && url) {
|
||||
pageSummaryUrl = resultUrls.absoluteSummaryPageUrl(url) + 'index.html';
|
||||
}
|
||||
|
||||
return {
|
||||
errors,
|
||||
budgetResult,
|
||||
resultUrl: resultUrls.hasBaseUrl()
|
||||
? resultUrls.reportSummaryUrl() + '/index.html'
|
||||
: '',
|
||||
pageSummaryUrl:
|
||||
url && resultUrls.hasBaseUrl() && !options.multi
|
||||
? resultUrls.absoluteSummaryPageUrl(url) + 'index.html'
|
||||
: '',
|
||||
pageSummaryUrl,
|
||||
localPath: storageManager.getBaseDir()
|
||||
};
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue