@auxcode/auxta 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auxcode/auxta",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "",
5
5
  "main": "src/AuxTA.ts",
6
6
  "scripts": {
@@ -12,7 +12,7 @@ import { startSuite } from '../utilities/start-suite.helper';
12
12
  import { StepStatusEnum } from "../enums/step-status.enum";
13
13
  import { UploadModel } from "../models/upload.model";
14
14
 
15
- export async function AfterEach(body: any, featureName: string, scenarioName: string, statusCode: number, screenshotBuffer: Buffer, errMessage?: string) {
15
+ export async function onTestEnd(body: any, featureName: string, scenarioName: string, statusCode: number, screenshotBuffer: Buffer, errMessage?: object) {
16
16
  let isFinal: boolean = false;
17
17
  if (process.env.ENVIRONMENT == "LIVE") {
18
18
  console.log('asc ' + errMessage);
@@ -66,7 +66,7 @@ export async function createEmptyReport(body: any): Promise<string> {
66
66
  )).data.reportId;
67
67
  }
68
68
 
69
- export async function uploadScenario(stepLog: Step[], scenarioName: string, screenshot?: Buffer, errMessage?: string) {
69
+ export async function uploadScenario(stepLog: Step[], scenarioName: string, screenshot?: Buffer, errMessage?: object) {
70
70
  let scenarios = [];
71
71
  let token = await auth();
72
72
  let lastStep = stepLog[stepLog.length - 1];
@@ -58,7 +58,14 @@ export class FunctionHelper {
58
58
  }
59
59
 
60
60
  public async waitForNetwork() {
61
- await puppeteer.defaultPage.waitForNetworkIdle();
61
+ let message = 'I wait for the page to load'
62
+ try{
63
+ await puppeteer.defaultPage.waitForNetworkIdle();
64
+ log.push('Then', message, StepStatusEnum.PASSED);
65
+ } catch (e){
66
+ log.push('Then', message, StepStatusEnum.FAILED);
67
+ throw new Error(message)
68
+ }
62
69
  }
63
70
 
64
71
  public async timeout(timeout = this.defaultTimeout) {
@@ -1,7 +1,7 @@
1
1
  import chromium from 'chrome-aws-lambda';
2
2
  import log from "../auxta/services/log.service";
3
3
  import { captureScreenshot } from "../auxta/utilities/screenshot.helper";
4
- import { AfterEach } from "../auxta/hooks/report.hook";
4
+ import { onTestEnd } from "../auxta/hooks/report.hook";
5
5
  import auxta from "../AuxTA";
6
6
  import { StepStatusEnum } from "../auxta/enums/step-status.enum";
7
7
  import { UploadModel } from "../auxta/models/upload.model";
@@ -53,9 +53,17 @@ export class Puppeteer {
53
53
  let errMessage: string | undefined;
54
54
  let statusCode: number = 200;
55
55
 
56
+ let consoleStack = [];
56
57
  try {
57
58
  await log.push('When', `Starting puppeteer process`, StepStatusEnum.PASSED);
58
59
  await this.startBrowser()
60
+ await this.defaultPage.on('console', message =>
61
+ consoleStack.push(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`))
62
+ .on('pageerror', ({ message }) => consoleStack.push(message))
63
+ .on('response', response =>
64
+ consoleStack.push(`${response.status()} ${response.url()}`))
65
+ .on('requestfailed', request =>
66
+ consoleStack.push(`${request.failure().errorText} ${request.url()}`))
59
67
  await callback(event)
60
68
  screenshotBuffer = await captureScreenshot();
61
69
  await log.push('When', `Finished puppeteer process`, StepStatusEnum.PASSED);
@@ -66,9 +74,14 @@ export class Puppeteer {
66
74
  screenshotBuffer = await captureScreenshot();
67
75
  await log.push('When', `Finished puppeteer process`, StepStatusEnum.FAILED);
68
76
  }
77
+ let url = this.defaultPage.url();
69
78
  if (close) await this.close();
79
+ log.clear();
70
80
 
71
- await AfterEach(uploadModel, featureName, scenarioName, statusCode, screenshotBuffer, errMessage);
81
+ await onTestEnd(uploadModel, featureName, scenarioName, statusCode, screenshotBuffer, !errMessage ? undefined : {
82
+ currentPageUrl: url,
83
+ error: errMessage
84
+ });
72
85
  }
73
86
 
74
87
  private static setupHeader(event: any, uploadModel: UploadModel) {