@auxcode/auxta 0.3.9 → 0.4.3
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
|
@@ -43,11 +43,7 @@ export async function onTestEnd(body: any, featureName: string, scenarioName: st
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
if (isFinal) await afterComplete(body);
|
|
46
|
-
else if (body && body.nextSuites
|
|
47
|
-
try {
|
|
48
|
-
await startSuite(body.nextSuites, body.reportId);
|
|
49
|
-
} catch {
|
|
50
|
-
}
|
|
46
|
+
else if (body && body.nextSuites) await startSuite(body.nextSuites, body.reportId);
|
|
51
47
|
}
|
|
52
48
|
|
|
53
49
|
export async function afterComplete(body: UploadModel) {
|
|
@@ -29,6 +29,12 @@ export class LogSteps {
|
|
|
29
29
|
|
|
30
30
|
public clear() {
|
|
31
31
|
this.stepLog = [];
|
|
32
|
+
this.statusCounter = {
|
|
33
|
+
[StatusOfStep.PASSED]: 0,
|
|
34
|
+
[StatusOfStep.FAILED]: 0,
|
|
35
|
+
[StatusOfStep.SKIPPED]: 0,
|
|
36
|
+
[StatusOfStep.SUGGESTION]: 0,
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
public push(keyword: string, name: string, status: StatusOfStep) {
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { config } from "../configs/config";
|
|
3
3
|
|
|
4
|
-
export function startSuite(suites: string[], reportId?: string) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
export async function startSuite(suites: string[], reportId?: string) {
|
|
5
|
+
if (suites.length === 0) return;
|
|
6
|
+
const next = suites.shift();
|
|
7
|
+
console.log('Starting next suite: ' + next);
|
|
8
|
+
try{
|
|
9
|
+
await axios.post(
|
|
10
|
+
`${config.netlifyPath}.netlify/functions/${next}?token=${config.token}`,
|
|
11
|
+
{nextSuites: suites, reportId: reportId})
|
|
12
|
+
} catch (e){
|
|
13
|
+
// skip the suite if not found
|
|
14
|
+
await startSuite(suites, reportId);
|
|
15
|
+
}
|
|
11
16
|
}
|
|
@@ -27,6 +27,7 @@ export class Puppeteer {
|
|
|
27
27
|
this.browser = await chromium.puppeteer.launch({
|
|
28
28
|
executablePath: process.env.ENVIRONMENT === 'LOCAL' ? undefined : await chromium.executablePath,
|
|
29
29
|
args,
|
|
30
|
+
ignoreDefaultArgs: ["--enable-automation"],
|
|
30
31
|
defaultViewport: process.env.ENVIRONMENT === 'LOCAL' ? null : {
|
|
31
32
|
width: config.screenWidth,
|
|
32
33
|
height: config.screenHeight
|
|
@@ -48,42 +49,47 @@ export class Puppeteer {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
public async run(event: any, callback: any, featureName = 'Test feature', scenarioName = 'Test scenario', uploadModel?: UploadModel, close?: boolean) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
try{
|
|
53
|
+
if (uploadModel === undefined) uploadModel = auxta.getUploadModel();
|
|
54
|
+
if (close === undefined) close = Puppeteer.setupHeader(event, uploadModel)
|
|
55
|
+
let screenshotBuffer: Buffer | undefined;
|
|
56
|
+
let errMessage: any;
|
|
57
|
+
let statusCode: number = 200;
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
let consoleStack: any[] = [];
|
|
60
|
+
try {
|
|
61
|
+
await log.push('When', `Starting puppeteer process`, StatusOfStep.PASSED);
|
|
62
|
+
await this.startBrowser()
|
|
63
|
+
this.defaultPage.on('console', message =>
|
|
64
|
+
consoleStack.push(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`))
|
|
65
|
+
.on('pageerror', ({message}) => consoleStack.push(message))
|
|
66
|
+
.on('response', response =>
|
|
67
|
+
consoleStack.push(`${response.status()} ${response.url()}`))
|
|
68
|
+
.on('requestfailed', request =>
|
|
69
|
+
consoleStack.push(`${request.failure() !== null ? request.failure()?.errorText : ""} ${request.url()}`))
|
|
70
|
+
await callback(event)
|
|
71
|
+
log.push('When', `Finished puppeteer process`, StatusOfStep.PASSED);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
console.log("Error", err);
|
|
74
|
+
errMessage = err;
|
|
75
|
+
statusCode = 500;
|
|
76
|
+
screenshotBuffer = await captureScreenshot();
|
|
77
|
+
log.push('When', `Finished puppeteer process`, StatusOfStep.FAILED);
|
|
78
|
+
await postNotificationsOnFail(uploadModel)
|
|
79
|
+
}
|
|
80
|
+
let url = this.defaultPage.url();
|
|
81
|
+
if (close) await this.close();
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
await onTestEnd(uploadModel, featureName, scenarioName, statusCode, screenshotBuffer, !errMessage ? undefined : {
|
|
84
|
+
currentPageUrl: url,
|
|
85
|
+
console: consoleStack,
|
|
86
|
+
error: errMessage
|
|
87
|
+
});
|
|
88
|
+
} catch (e){
|
|
89
|
+
console.log("Lib error:", e);
|
|
90
|
+
} finally {
|
|
91
|
+
log.clear();
|
|
92
|
+
}
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
private static setupHeader(event: any, uploadModel: UploadModel) {
|