Adding functionality to skip specific stories to skip DOM parsing

This commit is contained in:
Vinod Kumar Sharma 2023-08-18 11:41:49 +05:30
Родитель 58c5df0f9d
Коммит 55240b832e
3 изменённых файлов: 19 добавлений и 2 удалений

Просмотреть файл

@ -275,7 +275,10 @@ export class PlayWrightExecutor {
path: screenshotPath,
});
console.log(`saving snapshot`);
if(this.options.parseDom){
console.log(`this.options.skipDomParsing: ${this.options.skipDomParsing}`);
console.log(`testName: ${this.ssNamePrefix.split(" ")[0]}`);
if(this.options.parseDom && !this.options.skipDomParsing.includes(this.ssNamePrefix.split(" ")[0])){
await parseWebPage(this.page, screenshotPath.replace(".png", "") + ".txt", "html", this.options.compressDom);
}
} catch (err) {
@ -294,7 +297,9 @@ export class PlayWrightExecutor {
await element.screenshot({
path: screenshotPath,
});
if(this.options.parseDom){
console.log(`this.options.skipDomParsing: ${this.options.skipDomParsing}`);
console.log(`testName: ${this.ssNamePrefix.split(" ")[0]}`);
if(this.options.parseDom && !this.options.skipDomParsing.includes(this.ssNamePrefix.split(" ")[0])){
await parseWebPage(this.page, screenshotPath.replace(".png", "") + ".txt" , selector, this.options.compressDom);
}
} else {

Просмотреть файл

@ -5,6 +5,7 @@ export interface StoryWrightOptions {
url: string;
screenShotDestPath: string;
browsers: Array<string>;
skipDomParsing: Array<string>;
parseDom: boolean;
compressDom: boolean;
headless: boolean;

Просмотреть файл

@ -36,6 +36,16 @@ const args = argv
},
choices: [BrowserName.Chromium, BrowserName.Firefox, BrowserName.Webkit],
})
.option("skipDomParsing", {
alias: "skipDomParsing",
default: [],
describe: "Comma seperated list of Story names to skip DOM parsing",
nargs: 1,
type: "array",
coerce: (array) => {
return array.flatMap((v) => v.split(","));
},
})
.option("parseDom", {
alias: "parseDom",
default: false,
@ -129,6 +139,7 @@ const storyWrightOptions: StoryWrightOptions = {
url: url,
screenShotDestPath: args.destpath,
browsers: args.browsers,
skipDomParsing: args.skipDomParsing,
parseDom: args.parseDom,
compressDom: args.compressDom,
headless: args.headless,