* Returns the sorted result map with fileName and pixel difference percentage * * @remarks * This is the main method called to use the tool * * @returns Map
()
| 232 | * @returns Map<fileName, percentageDifference> |
| 233 | */ |
| 234 | async result() { |
| 235 | try { |
| 236 | await this.puppeteer_browser_open(); |
| 237 | this.log("Browser opened"); |
| 238 | const urls = this.pathnames.map((pathname: any) => { |
| 239 | return { |
| 240 | url1: this.url1 + pathname, |
| 241 | url2: this.url2 + pathname, |
| 242 | fileName: this.getFileName(this.url1 + pathname), |
| 243 | }; |
| 244 | }); |
| 245 | const promises = urls.map((compareObj: any) => this.compare(compareObj)); |
| 246 | const results = await Promise.allSettled(promises); |
| 247 | results.forEach((result) => { |
| 248 | if (result.status === "rejected") { |
| 249 | // this will still continue to run for other pathnames, but will throw the error for specific pathname |
| 250 | throw new Error(result.reason.message); |
| 251 | } |
| 252 | }); |
| 253 | |
| 254 | await this.puppeteer_browser_close(); |
| 255 | const resultMap = await this.sortFilesBasedOnDifference(); |
| 256 | this.log("Browser closed"); |
| 257 | // Output resultMap in output file only if configured |
| 258 | if (this.outputFile) infoLogger.info(resultMap); |
| 259 | return resultMap; |
| 260 | } catch (e: any) { |
| 261 | this.log(e.message); |
| 262 | throw new Error("Error while getting result: " + e.message); |
| 263 | } |
| 264 | } |
| 265 | } |
no test coverage detected