@wdio/browserstack-service 8.16.5 → 8.16.6
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/build/constants.d.ts +1 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +1 -0
- package/build/cucumber-types.d.ts +17 -0
- package/build/cucumber-types.d.ts.map +1 -1
- package/build/cucumber-types.js +0 -1
- package/build/index.d.ts +5 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -0
- package/build/insights-handler.d.ts +19 -3
- package/build/insights-handler.d.ts.map +1 -1
- package/build/insights-handler.js +274 -18
- package/build/log4jsAppender.d.ts +2 -0
- package/build/log4jsAppender.d.ts.map +1 -0
- package/build/log4jsAppender.js +19 -0
- package/build/logPatcher.d.ts +13 -0
- package/build/logPatcher.d.ts.map +1 -0
- package/build/logPatcher.js +38 -0
- package/build/logReportingAPI.d.ts +12 -0
- package/build/logReportingAPI.d.ts.map +1 -0
- package/build/logReportingAPI.js +56 -0
- package/build/reporter.d.ts +6 -0
- package/build/reporter.d.ts.map +1 -1
- package/build/reporter.js +42 -2
- package/build/service.d.ts +3 -3
- package/build/service.d.ts.map +1 -1
- package/build/service.js +3 -1
- package/build/types.d.ts +17 -1
- package/build/types.d.ts.map +1 -1
- package/build/util.d.ts +10 -0
- package/build/util.d.ts.map +1 -1
- package/build/util.js +34 -1
- package/package.json +4 -3
package/build/constants.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { BrowserstackConfig } from './types.js';
|
|
|
2
2
|
export declare const BROWSER_DESCRIPTION: readonly ["device", "os", "osVersion", "os_version", "browserName", "browser", "browserVersion", "browser_version"];
|
|
3
3
|
export declare const VALID_APP_EXTENSION: string[];
|
|
4
4
|
export declare const DEFAULT_OPTIONS: Partial<BrowserstackConfig>;
|
|
5
|
+
export declare const consoleHolder: typeof console;
|
|
5
6
|
export declare const DATA_ENDPOINT = "https://collector-observability.browserstack.com";
|
|
6
7
|
export declare const DATA_EVENT_ENDPOINT = "api/v1/event";
|
|
7
8
|
export declare const DATA_BATCH_ENDPOINT = "api/v1/batch";
|
package/build/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAKpD,eAAO,MAAM,mBAAmB,qHAStB,CAAA;AAEV,eAAO,MAAM,mBAAmB,UAI/B,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,kBAAkB,CAIvD,CAAA;AAED,eAAO,MAAM,aAAa,qDAAqD,CAAA;AAC/E,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AACjD,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AACjD,eAAO,MAAM,wBAAwB,uBAAuB,CAAA;AAC5D,eAAO,MAAM,eAAe,OAAO,CAAA;AACnC,eAAO,MAAM,mBAAmB,OAAO,CAAA;AACvC,eAAO,MAAM,iBAAiB,UAAgH,CAAA;AAC9I,eAAO,MAAM,wCAAwC,OAAO,CAAA;AAC5D,eAAO,MAAM,yCAAyC,MAAM,CAAA;AAC5D,eAAO,MAAM,sBAAsB,KAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAKpD,eAAO,MAAM,mBAAmB,qHAStB,CAAA;AAEV,eAAO,MAAM,mBAAmB,UAI/B,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,kBAAkB,CAIvD,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,OAAO,OAAoC,CAAA;AAEvE,eAAO,MAAM,aAAa,qDAAqD,CAAA;AAC/E,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AACjD,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AACjD,eAAO,MAAM,wBAAwB,uBAAuB,CAAA;AAC5D,eAAO,MAAM,eAAe,OAAO,CAAA;AACnC,eAAO,MAAM,mBAAmB,OAAO,CAAA;AACvC,eAAO,MAAM,iBAAiB,UAAgH,CAAA;AAC9I,eAAO,MAAM,wCAAwC,OAAO,CAAA;AAC5D,eAAO,MAAM,yCAAyC,MAAM,CAAA;AAC5D,eAAO,MAAM,sBAAsB,KAAuB,CAAA"}
|
package/build/constants.js
CHANGED
|
@@ -21,6 +21,7 @@ export const DEFAULT_OPTIONS = {
|
|
|
21
21
|
setSessionStatus: true,
|
|
22
22
|
testObservability: true
|
|
23
23
|
};
|
|
24
|
+
export const consoleHolder = Object.assign({}, console);
|
|
24
25
|
export const DATA_ENDPOINT = 'https://collector-observability.browserstack.com';
|
|
25
26
|
export const DATA_EVENT_ENDPOINT = 'api/v1/event';
|
|
26
27
|
export const DATA_BATCH_ENDPOINT = 'api/v1/batch';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Frameworks } from '@wdio/types';
|
|
1
2
|
export interface ITestCaseHookParameter {
|
|
2
3
|
gherkinDocument: GherkinDocument;
|
|
3
4
|
pickle: Pickle;
|
|
@@ -174,4 +175,20 @@ export declare class Comment {
|
|
|
174
175
|
location: Location;
|
|
175
176
|
text: string;
|
|
176
177
|
}
|
|
178
|
+
export interface CucumberStore {
|
|
179
|
+
feature?: Feature;
|
|
180
|
+
scenario?: Pickle;
|
|
181
|
+
uri?: string;
|
|
182
|
+
stepsStarted: boolean;
|
|
183
|
+
scenariosStarted: boolean;
|
|
184
|
+
steps: Frameworks.PickleStep[];
|
|
185
|
+
}
|
|
186
|
+
export interface CucumberHook {
|
|
187
|
+
id: string;
|
|
188
|
+
hookId: string;
|
|
189
|
+
}
|
|
190
|
+
export interface CucumberHookParams {
|
|
191
|
+
event: 'before' | 'after';
|
|
192
|
+
hookUUID?: string;
|
|
193
|
+
}
|
|
177
194
|
//# sourceMappingURL=cucumber-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cucumber-types.d.ts","sourceRoot":"","sources":["../src/cucumber-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cucumber-types.d.ts","sourceRoot":"","sources":["../src/cucumber-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,MAAM,WAAW,sBAAsB;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,CAAC,OAAO,OAAO,eAAe;IAChC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAA;CAC/B;AAED,MAAM,CAAC,OAAO,OAAO,UAAU;IAC3B,QAAQ,EAAE,QAAQ,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,SAAS,IAAI,EAAE,CAAA;IACtB,EAAE,EAAE,MAAM,CAAA;CACb;AAED,MAAM,CAAC,OAAO,OAAO,SAAS;IAC1B,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAA;CAC5B;AAED,MAAM,CAAC,OAAO,OAAO,SAAS;IAC1B,QAAQ,EAAE,QAAQ,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CACpB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AY;IACnB,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,MAAM,WAAW;CACpB;AAED,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,CAAC,OAAO,OAAO,OAAO;IACxB,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAA;IACzB,KAAK,EAAE,UAAU,CAAC,UAAU,EAAE,CAAA;CACjC;AAED,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,kBAAkB;IAC/B,KAAK,EAAE,QAAQ,GAAC,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB"}
|
package/build/cucumber-types.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import BrowserstackLauncher from './launcher.js';
|
|
2
2
|
import BrowserstackService from './service.js';
|
|
3
3
|
import type { BrowserstackConfig } from './types.js';
|
|
4
|
+
import logReportingAPI from './logReportingAPI.js';
|
|
4
5
|
export default BrowserstackService;
|
|
5
6
|
export declare const launcher: typeof BrowserstackLauncher;
|
|
7
|
+
export declare const log4jsAppender: {
|
|
8
|
+
configure: (config: any, layouts: any) => Function;
|
|
9
|
+
};
|
|
10
|
+
export declare const BStackTestOpsLogger: typeof logReportingAPI;
|
|
6
11
|
export * from './types.js';
|
|
7
12
|
declare global {
|
|
8
13
|
namespace WebdriverIO {
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,MAAM,eAAe,CAAA;AAChD,OAAO,mBAAmB,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,eAAe,mBAAmB,CAAA;AAClC,eAAO,MAAM,QAAQ,6BAAuB,CAAA;AAC5C,cAAc,YAAY,CAAA;AAE1B,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,aAAc,SAAQ,kBAAkB;SAAG;KACxD;CACJ"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,MAAM,eAAe,CAAA;AAChD,OAAO,mBAAmB,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,OAAO,eAAe,MAAM,sBAAsB,CAAA;AAElD,eAAe,mBAAmB,CAAA;AAClC,eAAO,MAAM,QAAQ,6BAAuB,CAAA;AAC5C,eAAO,MAAM,cAAc;;CAAgB,CAAA;AAC3C,eAAO,MAAM,mBAAmB,wBAAkB,CAAA;AAElD,cAAc,YAAY,CAAA;AAE1B,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,aAAc,SAAQ,kBAAkB;SAAG;KACxD;CACJ"}
|
package/build/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/* istanbul ignore file */
|
|
2
2
|
import BrowserstackLauncher from './launcher.js';
|
|
3
3
|
import BrowserstackService from './service.js';
|
|
4
|
+
import { configure } from './log4jsAppender.js';
|
|
5
|
+
import logReportingAPI from './logReportingAPI.js';
|
|
4
6
|
export default BrowserstackService;
|
|
5
7
|
export const launcher = BrowserstackLauncher;
|
|
8
|
+
export const log4jsAppender = { configure };
|
|
9
|
+
export const BStackTestOpsLogger = logReportingAPI;
|
|
6
10
|
export * from './types.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Frameworks } from '@wdio/types';
|
|
2
2
|
import type { BeforeCommandArgs, AfterCommandArgs } from '@wdio/reporter';
|
|
3
|
-
import type { Pickle, ITestCaseHookParameter } from './cucumber-types.js';
|
|
3
|
+
import type { Feature, Scenario, CucumberHook, CucumberHookParams, Pickle, ITestCaseHookParameter } from './cucumber-types.js';
|
|
4
|
+
import type { TestMeta, UploadType, CurrentRunInfo, StdLog } from './types.js';
|
|
4
5
|
declare class _InsightsHandler {
|
|
5
6
|
private _browser;
|
|
6
7
|
private _framework?;
|
|
@@ -11,16 +12,29 @@ declare class _InsightsHandler {
|
|
|
11
12
|
private _gitConfigPath?;
|
|
12
13
|
private _suiteFile?;
|
|
13
14
|
private _requestQueueHandler;
|
|
15
|
+
private _currentTest;
|
|
16
|
+
private _currentHook;
|
|
17
|
+
private _cucumberData;
|
|
14
18
|
constructor(_browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, isAppAutomate?: boolean, _framework?: string | undefined);
|
|
19
|
+
registerListeners(): void;
|
|
15
20
|
setSuiteFile(filename: string): void;
|
|
16
21
|
before(): Promise<void>;
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
getCucumberHookType(test: CucumberHook | undefined): string | null;
|
|
23
|
+
getCucumberHookName(hookType: string | undefined): string;
|
|
24
|
+
getCucumberHookUniqueId(hookType: string, hook: CucumberHook | undefined): string | null;
|
|
25
|
+
getCucumberFeatureUniqueId(): string;
|
|
26
|
+
setCurrentHook(hookDetails: CurrentRunInfo): void;
|
|
27
|
+
sendScenarioObjectSkipped(scenario: Scenario, feature: Feature, uri: string): Promise<void>;
|
|
28
|
+
processCucumberHook(test: CucumberHook | undefined, params: CucumberHookParams, result?: Frameworks.TestResult): Promise<void>;
|
|
29
|
+
beforeHook(test: Frameworks.Test | CucumberHook | undefined, context: any): Promise<void>;
|
|
30
|
+
afterHook(test: Frameworks.Test | CucumberHook | undefined, result: Frameworks.TestResult): Promise<void>;
|
|
31
|
+
sendHookRunEvent(hookData: TestMeta, eventType: string, result?: Frameworks.TestResult): Promise<void>;
|
|
19
32
|
beforeTest(test: Frameworks.Test): Promise<void>;
|
|
20
33
|
afterTest(test: Frameworks.Test, result: Frameworks.TestResult): Promise<void>;
|
|
21
34
|
/**
|
|
22
35
|
* Cucumber Only
|
|
23
36
|
*/
|
|
37
|
+
beforeFeature(uri: string, feature: Feature): Promise<void>;
|
|
24
38
|
beforeScenario(world: ITestCaseHookParameter): Promise<void>;
|
|
25
39
|
afterScenario(world: ITestCaseHookParameter): Promise<void>;
|
|
26
40
|
beforeStep(step: Frameworks.PickleStep, scenario: Pickle): Promise<void>;
|
|
@@ -30,6 +44,8 @@ declare class _InsightsHandler {
|
|
|
30
44
|
/**
|
|
31
45
|
* misc methods
|
|
32
46
|
*/
|
|
47
|
+
appendTestItemLog: (stdLog: StdLog) => Promise<void>;
|
|
48
|
+
sendData(data: UploadType): Promise<void>;
|
|
33
49
|
browserCommand(commandType: string, args: BeforeCommandArgs & AfterCommandArgs, test?: Frameworks.Test | ITestCaseHookParameter): Promise<void>;
|
|
34
50
|
private attachHookData;
|
|
35
51
|
private setHooksFromSuite;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insights-handler.d.ts","sourceRoot":"","sources":["../src/insights-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"insights-handler.d.ts","sourceRoot":"","sources":["../src/insights-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE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OAAO,CAAC,iBAAiB;IA0BzB,OAAO,CAAC,YAAY;YAiBN,gBAAgB;IA8E9B,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,qBAAqB;YAoBf,2BAA2B;IA8FzC,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,aAAa;CAMxB;AAGD,QAAA,MAAM,eAAe,EAAE,OAAO,gBAA0D,CAAA;AACxF,KAAK,eAAe,GAAG,gBAAgB,CAAA;AAEvC,eAAe,eAAe,CAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import logger from '@wdio/logger';
|
|
2
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
4
|
import TestReporter from './reporter.js';
|
|
4
|
-
import { frameworkSupportsHook, getCloudProvider, getGitMetaData, getHookType, getScenarioExamples, getUniqueIdentifier, getUniqueIdentifierForCucumber, isBrowserstackSession, isScreenshotCommand, o11yClassErrorHandler, removeAnsiColors, sleep, uploadEventData } from './util.js';
|
|
5
|
+
import { frameworkSupportsHook, getCloudProvider, getFailureObject, getGitMetaData, getHookType, getScenarioExamples, getUniqueIdentifier, getUniqueIdentifierForCucumber, isBrowserstackSession, isScreenshotCommand, o11yClassErrorHandler, pushDataToQueue, removeAnsiColors, sleep, uploadEventData } from './util.js';
|
|
5
6
|
import RequestQueueHandler from './request-handler.js';
|
|
6
7
|
import { DATA_SCREENSHOT_ENDPOINT, DEFAULT_WAIT_INTERVAL_FOR_PENDING_UPLOADS, DEFAULT_WAIT_TIMEOUT_FOR_PENDING_UPLOADS } from './constants.js';
|
|
8
|
+
const log = logger('@wdio/browserstack-service');
|
|
7
9
|
class _InsightsHandler {
|
|
8
10
|
_browser;
|
|
9
11
|
_framework;
|
|
@@ -14,6 +16,13 @@ class _InsightsHandler {
|
|
|
14
16
|
_gitConfigPath;
|
|
15
17
|
_suiteFile;
|
|
16
18
|
_requestQueueHandler = RequestQueueHandler.getInstance();
|
|
19
|
+
_currentTest = {};
|
|
20
|
+
_currentHook = {};
|
|
21
|
+
_cucumberData = {
|
|
22
|
+
stepsStarted: false,
|
|
23
|
+
scenariosStarted: false,
|
|
24
|
+
steps: []
|
|
25
|
+
};
|
|
17
26
|
constructor(_browser, isAppAutomate, _framework) {
|
|
18
27
|
this._browser = _browser;
|
|
19
28
|
this._framework = _framework;
|
|
@@ -28,6 +37,14 @@ class _InsightsHandler {
|
|
|
28
37
|
sessionId,
|
|
29
38
|
product: isAppAutomate ? 'app-automate' : 'automate'
|
|
30
39
|
};
|
|
40
|
+
this.registerListeners();
|
|
41
|
+
}
|
|
42
|
+
registerListeners() {
|
|
43
|
+
if (!(this._framework === 'mocha' || this._framework === 'cucumber')) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
process.removeAllListeners(`bs:addLog:${process.pid}`);
|
|
47
|
+
process.on(`bs:addLog:${process.pid}`, this.appendTestItemLog.bind(this));
|
|
31
48
|
}
|
|
32
49
|
setSuiteFile(filename) {
|
|
33
50
|
this._suiteFile = filename;
|
|
@@ -47,23 +64,159 @@ class _InsightsHandler {
|
|
|
47
64
|
this._gitConfigPath = gitMeta.root;
|
|
48
65
|
}
|
|
49
66
|
}
|
|
67
|
+
getCucumberHookType(test) {
|
|
68
|
+
let hookType = null;
|
|
69
|
+
if (!test) {
|
|
70
|
+
hookType = this._cucumberData.scenariosStarted ? 'AFTER_ALL' : 'BEFORE_ALL';
|
|
71
|
+
}
|
|
72
|
+
else if (!this._cucumberData.stepsStarted) {
|
|
73
|
+
hookType = 'BEFORE_EACH';
|
|
74
|
+
}
|
|
75
|
+
else if (this._cucumberData.steps?.length > 0) {
|
|
76
|
+
// beforeStep or afterStep
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
hookType = 'AFTER_EACH';
|
|
80
|
+
}
|
|
81
|
+
return hookType;
|
|
82
|
+
}
|
|
83
|
+
getCucumberHookName(hookType) {
|
|
84
|
+
switch (hookType) {
|
|
85
|
+
case 'BEFORE_EACH':
|
|
86
|
+
case 'AFTER_EACH':
|
|
87
|
+
return `${hookType} for ${this._cucumberData.scenario?.name}`;
|
|
88
|
+
case 'BEFORE_ALL':
|
|
89
|
+
case 'AFTER_ALL':
|
|
90
|
+
return `${hookType} for ${this._cucumberData.feature?.name}`;
|
|
91
|
+
}
|
|
92
|
+
return '';
|
|
93
|
+
}
|
|
94
|
+
getCucumberHookUniqueId(hookType, hook) {
|
|
95
|
+
switch (hookType) {
|
|
96
|
+
case 'BEFORE_EACH':
|
|
97
|
+
case 'AFTER_EACH':
|
|
98
|
+
return hook.hookId;
|
|
99
|
+
case 'BEFORE_ALL':
|
|
100
|
+
case 'AFTER_ALL':
|
|
101
|
+
// Can only work for single beforeAll or afterAll
|
|
102
|
+
return `${hookType} for ${this.getCucumberFeatureUniqueId()}`;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
getCucumberFeatureUniqueId() {
|
|
107
|
+
const { uri, feature } = this._cucumberData;
|
|
108
|
+
return `${uri}:${feature?.name}`;
|
|
109
|
+
}
|
|
110
|
+
setCurrentHook(hookDetails) {
|
|
111
|
+
if (hookDetails.finished) {
|
|
112
|
+
if (this._currentHook.uuid === hookDetails.uuid) {
|
|
113
|
+
this._currentHook.finished = true;
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
this._currentHook = {
|
|
118
|
+
uuid: hookDetails.uuid,
|
|
119
|
+
finished: false
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async sendScenarioObjectSkipped(scenario, feature, uri) {
|
|
123
|
+
const testMetaData = {
|
|
124
|
+
uuid: uuidv4(),
|
|
125
|
+
startedAt: (new Date()).toISOString(),
|
|
126
|
+
finishedAt: (new Date()).toISOString(),
|
|
127
|
+
scenario: {
|
|
128
|
+
name: scenario.name
|
|
129
|
+
},
|
|
130
|
+
feature: {
|
|
131
|
+
path: uri,
|
|
132
|
+
name: feature.name,
|
|
133
|
+
description: feature.description
|
|
134
|
+
},
|
|
135
|
+
steps: scenario.steps.map((step) => {
|
|
136
|
+
return {
|
|
137
|
+
id: step.id,
|
|
138
|
+
text: step.text,
|
|
139
|
+
keyword: step.keyword,
|
|
140
|
+
result: 'skipped',
|
|
141
|
+
};
|
|
142
|
+
}),
|
|
143
|
+
};
|
|
144
|
+
await this.sendTestRunEventForCucumber(null, 'TestRunSkipped', testMetaData);
|
|
145
|
+
}
|
|
146
|
+
async processCucumberHook(test, params, result) {
|
|
147
|
+
const hookType = this.getCucumberHookType(test);
|
|
148
|
+
if (!hookType) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const { event, hookUUID } = params;
|
|
152
|
+
const hookId = this.getCucumberHookUniqueId(hookType, test);
|
|
153
|
+
if (!hookId) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (event === 'before') {
|
|
157
|
+
this.setCurrentHook({ uuid: hookUUID });
|
|
158
|
+
const hookMetaData = {
|
|
159
|
+
uuid: hookUUID,
|
|
160
|
+
startedAt: (new Date()).toISOString(),
|
|
161
|
+
testRunId: this._currentTest.uuid,
|
|
162
|
+
hookType: hookType
|
|
163
|
+
};
|
|
164
|
+
this._tests[hookId] = hookMetaData;
|
|
165
|
+
await this.sendHookRunEvent(hookMetaData, 'HookRunStarted');
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
this._tests[hookId].finishedAt = (new Date()).toISOString();
|
|
169
|
+
this.setCurrentHook({ uuid: this._tests[hookId].uuid, finished: true });
|
|
170
|
+
await this.sendHookRunEvent(this._tests[hookId], 'HookRunFinished', result);
|
|
171
|
+
if (hookType === 'BEFORE_ALL' && result && !result.passed) {
|
|
172
|
+
const { feature, uri } = this._cucumberData;
|
|
173
|
+
if (!feature) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
feature.children.map(async (childObj) => {
|
|
177
|
+
if (childObj.rule) {
|
|
178
|
+
childObj.rule.children.map(async (scenarioObj) => {
|
|
179
|
+
if (scenarioObj.scenario) {
|
|
180
|
+
await this.sendScenarioObjectSkipped(scenarioObj.scenario, feature, uri);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else if (childObj.scenario) {
|
|
185
|
+
await this.sendScenarioObjectSkipped(childObj.scenario, feature, uri);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
50
191
|
async beforeHook(test, context) {
|
|
51
192
|
if (!frameworkSupportsHook('before', this._framework)) {
|
|
52
193
|
return;
|
|
53
194
|
}
|
|
195
|
+
const hookUUID = uuidv4();
|
|
196
|
+
if (this._framework === 'cucumber') {
|
|
197
|
+
test = test;
|
|
198
|
+
await this.processCucumberHook(test, { event: 'before', hookUUID });
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
test = test;
|
|
54
202
|
const fullTitle = getUniqueIdentifier(test, this._framework);
|
|
55
|
-
const hookId = uuidv4();
|
|
56
203
|
this._tests[fullTitle] = {
|
|
57
|
-
uuid:
|
|
204
|
+
uuid: hookUUID,
|
|
58
205
|
startedAt: (new Date()).toISOString()
|
|
59
206
|
};
|
|
60
|
-
this.
|
|
207
|
+
this.setCurrentHook({ uuid: hookUUID });
|
|
208
|
+
this.attachHookData(context, hookUUID);
|
|
61
209
|
await this.sendTestRunEvent(test, 'HookRunStarted');
|
|
62
210
|
}
|
|
63
211
|
async afterHook(test, result) {
|
|
64
212
|
if (!frameworkSupportsHook('after', this._framework)) {
|
|
65
213
|
return;
|
|
66
214
|
}
|
|
215
|
+
if (this._framework === 'cucumber') {
|
|
216
|
+
await this.processCucumberHook(test, { event: 'after' }, result);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
test = test;
|
|
67
220
|
const fullTitle = getUniqueIdentifier(test, this._framework);
|
|
68
221
|
if (this._tests[fullTitle]) {
|
|
69
222
|
this._tests[fullTitle].finishedAt = (new Date()).toISOString();
|
|
@@ -73,6 +226,7 @@ class _InsightsHandler {
|
|
|
73
226
|
finishedAt: (new Date()).toISOString()
|
|
74
227
|
};
|
|
75
228
|
}
|
|
229
|
+
this.setCurrentHook({ uuid: this._tests[fullTitle].uuid, finished: true });
|
|
76
230
|
await this.sendTestRunEvent(test, 'HookRunFinished', result);
|
|
77
231
|
const hookType = getHookType(test.title);
|
|
78
232
|
/*
|
|
@@ -107,13 +261,63 @@ class _InsightsHandler {
|
|
|
107
261
|
await sendSuiteSkipped(test.ctx.test.parent);
|
|
108
262
|
}
|
|
109
263
|
}
|
|
264
|
+
async sendHookRunEvent(hookData, eventType, result) {
|
|
265
|
+
const { uri, feature } = this._cucumberData;
|
|
266
|
+
const testData = {
|
|
267
|
+
uuid: hookData.uuid,
|
|
268
|
+
type: 'hook',
|
|
269
|
+
name: this.getCucumberHookName(hookData.hookType),
|
|
270
|
+
body: {
|
|
271
|
+
lang: 'webdriverio',
|
|
272
|
+
code: null
|
|
273
|
+
},
|
|
274
|
+
started_at: hookData.startedAt,
|
|
275
|
+
finished_at: hookData.finishedAt,
|
|
276
|
+
hook_type: hookData.hookType,
|
|
277
|
+
test_run_id: hookData.testRunId,
|
|
278
|
+
scope: feature?.name,
|
|
279
|
+
scopes: [feature?.name || ''],
|
|
280
|
+
file_name: uri ? path.relative(process.cwd(), uri) : undefined,
|
|
281
|
+
location: uri ? path.relative(process.cwd(), uri) : undefined,
|
|
282
|
+
vc_filepath: (this._gitConfigPath && uri) ? path.relative(this._gitConfigPath, uri) : undefined,
|
|
283
|
+
result: 'pending',
|
|
284
|
+
framework: this._framework
|
|
285
|
+
};
|
|
286
|
+
if (eventType === 'HookRunFinished' && result) {
|
|
287
|
+
testData.result = result.passed ? 'passed' : 'failed';
|
|
288
|
+
testData.retries = result.retries;
|
|
289
|
+
testData.duration_in_ms = result.duration;
|
|
290
|
+
if (!result.passed) {
|
|
291
|
+
Object.assign(testData, getFailureObject(result.error));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (eventType === 'HookRunStarted') {
|
|
295
|
+
testData.integrations = {};
|
|
296
|
+
if (this._browser && this._platformMeta) {
|
|
297
|
+
const provider = getCloudProvider(this._browser);
|
|
298
|
+
testData.integrations[provider] = this.getIntegrationsObject();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const uploadData = {
|
|
302
|
+
event_type: eventType,
|
|
303
|
+
hook_run: testData
|
|
304
|
+
};
|
|
305
|
+
const req = this._requestQueueHandler.add(uploadData);
|
|
306
|
+
if (req.proceed && req.data) {
|
|
307
|
+
await uploadEventData(req.data, req.url);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
110
310
|
async beforeTest(test) {
|
|
311
|
+
const uuid = uuidv4();
|
|
312
|
+
this._currentTest = {
|
|
313
|
+
test, uuid
|
|
314
|
+
};
|
|
111
315
|
if (this._framework !== 'mocha') {
|
|
112
316
|
return;
|
|
113
317
|
}
|
|
114
318
|
const fullTitle = getUniqueIdentifier(test, this._framework);
|
|
115
319
|
this._tests[fullTitle] = {
|
|
116
|
-
uuid
|
|
320
|
+
uuid,
|
|
117
321
|
startedAt: (new Date()).toISOString()
|
|
118
322
|
};
|
|
119
323
|
await this.sendTestRunEvent(test, 'TestRunStarted');
|
|
@@ -132,13 +336,25 @@ class _InsightsHandler {
|
|
|
132
336
|
/**
|
|
133
337
|
* Cucumber Only
|
|
134
338
|
*/
|
|
339
|
+
async beforeFeature(uri, feature) {
|
|
340
|
+
this._cucumberData.scenariosStarted = false;
|
|
341
|
+
this._cucumberData.feature = feature;
|
|
342
|
+
this._cucumberData.uri = uri;
|
|
343
|
+
}
|
|
135
344
|
async beforeScenario(world) {
|
|
345
|
+
const uuid = uuidv4();
|
|
346
|
+
this._currentTest = {
|
|
347
|
+
uuid
|
|
348
|
+
};
|
|
349
|
+
this._cucumberData.scenario = world.pickle;
|
|
350
|
+
this._cucumberData.scenariosStarted = true;
|
|
351
|
+
this._cucumberData.stepsStarted = false;
|
|
136
352
|
const pickleData = world.pickle;
|
|
137
353
|
const gherkinDocument = world.gherkinDocument;
|
|
138
354
|
const featureData = gherkinDocument.feature;
|
|
139
355
|
const uniqueId = getUniqueIdentifierForCucumber(world);
|
|
140
356
|
const testMetaData = {
|
|
141
|
-
uuid:
|
|
357
|
+
uuid: uuid,
|
|
142
358
|
startedAt: (new Date()).toISOString()
|
|
143
359
|
};
|
|
144
360
|
if (pickleData) {
|
|
@@ -157,9 +373,12 @@ class _InsightsHandler {
|
|
|
157
373
|
await this.sendTestRunEventForCucumber(world, 'TestRunStarted');
|
|
158
374
|
}
|
|
159
375
|
async afterScenario(world) {
|
|
376
|
+
this._cucumberData.scenario = undefined;
|
|
160
377
|
await this.sendTestRunEventForCucumber(world, 'TestRunFinished');
|
|
161
378
|
}
|
|
162
379
|
async beforeStep(step, scenario) {
|
|
380
|
+
this._cucumberData.stepsStarted = true;
|
|
381
|
+
this._cucumberData.steps.push(step);
|
|
163
382
|
const uniqueId = getUniqueIdentifierForCucumber({ pickle: scenario });
|
|
164
383
|
const testMetaData = this._tests[uniqueId] || { steps: [] };
|
|
165
384
|
if (testMetaData && !testMetaData.steps) {
|
|
@@ -174,6 +393,7 @@ class _InsightsHandler {
|
|
|
174
393
|
this._tests[uniqueId] = testMetaData;
|
|
175
394
|
}
|
|
176
395
|
async afterStep(step, scenario, result) {
|
|
396
|
+
this._cucumberData.steps.pop();
|
|
177
397
|
const uniqueId = getUniqueIdentifierForCucumber({ pickle: scenario });
|
|
178
398
|
const testMetaData = this._tests[uniqueId] || { steps: [] };
|
|
179
399
|
if (!testMetaData.steps) {
|
|
@@ -209,6 +429,31 @@ class _InsightsHandler {
|
|
|
209
429
|
/**
|
|
210
430
|
* misc methods
|
|
211
431
|
*/
|
|
432
|
+
appendTestItemLog = async (stdLog) => {
|
|
433
|
+
try {
|
|
434
|
+
if (this._currentHook.uuid && !this._currentHook.finished && (this._framework === 'mocha' || this._framework === 'cucumber')) {
|
|
435
|
+
stdLog.hook_run_uuid = this._currentHook.uuid;
|
|
436
|
+
}
|
|
437
|
+
else if (this._currentTest.uuid && (this._framework === 'mocha' || this._framework === 'cucumber')) {
|
|
438
|
+
stdLog.test_run_uuid = this._currentTest.uuid;
|
|
439
|
+
}
|
|
440
|
+
if (stdLog.hook_run_uuid || stdLog.test_run_uuid) {
|
|
441
|
+
await pushDataToQueue({
|
|
442
|
+
event_type: 'LogCreated',
|
|
443
|
+
logs: [stdLog]
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
catch (error) {
|
|
448
|
+
log.debug(`Exception in uploading log data to Observability with error : ${error}`);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
async sendData(data) {
|
|
452
|
+
const req = this._requestQueueHandler.add(data);
|
|
453
|
+
if (req.proceed && req.data) {
|
|
454
|
+
await uploadEventData(req.data, req.url);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
212
457
|
async browserCommand(commandType, args, test) {
|
|
213
458
|
const dataKey = `${args.sessionId}_${args.method}_${args.endpoint}`;
|
|
214
459
|
if (commandType === 'client:beforeCommand') {
|
|
@@ -415,13 +660,20 @@ class _InsightsHandler {
|
|
|
415
660
|
}
|
|
416
661
|
return;
|
|
417
662
|
}
|
|
418
|
-
async sendTestRunEventForCucumber(
|
|
419
|
-
const
|
|
420
|
-
const
|
|
421
|
-
const
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
663
|
+
async sendTestRunEventForCucumber(worldObj, eventType, testMetaData = null) {
|
|
664
|
+
const world = worldObj;
|
|
665
|
+
const dataHub = testMetaData ? testMetaData : (this._tests[getUniqueIdentifierForCucumber(world)] || {});
|
|
666
|
+
const { feature, scenario, steps, uuid, startedAt, finishedAt } = dataHub;
|
|
667
|
+
const examples = !testMetaData ? getScenarioExamples(world) : undefined;
|
|
668
|
+
let fullNameWithExamples;
|
|
669
|
+
if (!testMetaData) {
|
|
670
|
+
fullNameWithExamples = examples
|
|
671
|
+
? world.pickle.name + ' (' + examples.join(', ') + ')'
|
|
672
|
+
: world.pickle.name;
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
fullNameWithExamples = scenario?.name || '';
|
|
676
|
+
}
|
|
425
677
|
const testData = {
|
|
426
678
|
uuid: uuid,
|
|
427
679
|
started_at: startedAt,
|
|
@@ -447,7 +699,7 @@ class _InsightsHandler {
|
|
|
447
699
|
examples: examples
|
|
448
700
|
}
|
|
449
701
|
};
|
|
450
|
-
if (eventType === 'TestRunStarted') {
|
|
702
|
+
if (eventType === 'TestRunStarted' || eventType === 'TestRunSkipped') {
|
|
451
703
|
testData.integrations = {};
|
|
452
704
|
if (this._browser && this._platformMeta) {
|
|
453
705
|
const provider = getCloudProvider(this._browser);
|
|
@@ -455,7 +707,7 @@ class _InsightsHandler {
|
|
|
455
707
|
}
|
|
456
708
|
}
|
|
457
709
|
/* istanbul ignore if */
|
|
458
|
-
if (world
|
|
710
|
+
if (world?.result) {
|
|
459
711
|
let result = world.result.status.toLowerCase();
|
|
460
712
|
if (result !== 'passed' && result !== 'failed') {
|
|
461
713
|
result = 'skipped'; // mark UNKNOWN/UNDEFINED/AMBIGUOUS/PENDING as skipped
|
|
@@ -468,8 +720,8 @@ class _InsightsHandler {
|
|
|
468
720
|
{
|
|
469
721
|
'backtrace': [world.result.message ? removeAnsiColors(world.result.message) : 'unknown']
|
|
470
722
|
}
|
|
471
|
-
]
|
|
472
|
-
|
|
723
|
+
];
|
|
724
|
+
testData.failure_reason = world.result.message ? removeAnsiColors(world.result.message) : world.result.message;
|
|
473
725
|
if (world.result.message) {
|
|
474
726
|
testData.failure_type = world.result.message.match(/AssertionError/)
|
|
475
727
|
? 'AssertionError'
|
|
@@ -477,9 +729,13 @@ class _InsightsHandler {
|
|
|
477
729
|
}
|
|
478
730
|
}
|
|
479
731
|
}
|
|
480
|
-
if (world
|
|
732
|
+
if (world?.pickle) {
|
|
481
733
|
testData.tags = world.pickle.tags.map(({ name }) => (name));
|
|
482
734
|
}
|
|
735
|
+
if (eventType === 'TestRunSkipped') {
|
|
736
|
+
testData.result = 'skipped';
|
|
737
|
+
eventType = 'TestRunFinished';
|
|
738
|
+
}
|
|
483
739
|
const uploadData = {
|
|
484
740
|
event_type: eventType,
|
|
485
741
|
test_run: testData
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log4jsAppender.d.ts","sourceRoot":"","sources":["../src/log4jsAppender.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,SAAS,WAAY,GAAG,WAAW,GAAG,KAAG,QAMrD,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import logReportingAPI from './logReportingAPI.js';
|
|
2
|
+
const BSTestOpsLogger = new logReportingAPI({});
|
|
3
|
+
//Disabling eslint here as there params can be used later
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
function BSTestOpsLog4JSAppender(layout, timezoneOffset) {
|
|
6
|
+
return (loggingEvent) => {
|
|
7
|
+
BSTestOpsLogger.log({
|
|
8
|
+
level: loggingEvent.level ? loggingEvent.level.levelStr : null,
|
|
9
|
+
message: loggingEvent.data ? loggingEvent.data.join(' ') : null
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export const configure = (config, layouts) => {
|
|
14
|
+
let layout = layouts.colouredLayout;
|
|
15
|
+
if (config.layout) {
|
|
16
|
+
layout = layouts.layout(config.layout.type, config.layout);
|
|
17
|
+
}
|
|
18
|
+
return BSTestOpsLog4JSAppender(layout, config.timezoneOffset);
|
|
19
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Transport from 'winston-transport';
|
|
2
|
+
declare class logPatcher extends Transport {
|
|
3
|
+
constructor(opts: any);
|
|
4
|
+
logToTestOps: (level?: string, message?: string[]) => void;
|
|
5
|
+
trace: (...message: any) => void;
|
|
6
|
+
debug: (...message: any) => void;
|
|
7
|
+
info: (...message: any) => void;
|
|
8
|
+
warn: (...message: any) => void;
|
|
9
|
+
error: (...message: any) => void;
|
|
10
|
+
log: (...message: any) => void;
|
|
11
|
+
}
|
|
12
|
+
export default logPatcher;
|
|
13
|
+
//# sourceMappingURL=logPatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logPatcher.d.ts","sourceRoot":"","sources":["../src/logPatcher.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAA;AAMzC,cAAM,UAAW,SAAQ,SAAS;gBAClB,IAAI,EAAE,GAAG;IAIrB,YAAY,+CAQX;IAGD,KAAK,eAAgB,GAAG,UAEvB;IAED,KAAK,eAAe,GAAG,UAEtB;IAED,IAAI,eAAgB,GAAG,UAEtB;IAED,IAAI,eAAgB,GAAG,UAEtB;IAED,KAAK,eAAgB,GAAG,UAEvB;IAED,GAAG,eAAe,GAAG,UAEpB;CACJ;AACD,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Transport from 'winston-transport';
|
|
2
|
+
const LOG_LEVELS = {
|
|
3
|
+
INFO: 'INFO', ERROR: 'ERROR', DEBUG: 'DEBUG', TRACE: 'TRACE', WARN: 'WARN',
|
|
4
|
+
};
|
|
5
|
+
class logPatcher extends Transport {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
super(opts);
|
|
8
|
+
}
|
|
9
|
+
logToTestOps = (level = LOG_LEVELS.INFO, message = ['']) => {
|
|
10
|
+
process.emit(`bs:addLog:${process.pid}`, {
|
|
11
|
+
timestamp: new Date().toISOString(),
|
|
12
|
+
level: level.toUpperCase(),
|
|
13
|
+
message: `"${message.join(', ')}"`,
|
|
14
|
+
kind: 'TEST_LOG',
|
|
15
|
+
http_response: {}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
/* Patching this would show user an extended trace on their cli */
|
|
19
|
+
trace = (...message) => {
|
|
20
|
+
this.logToTestOps(LOG_LEVELS.TRACE, message);
|
|
21
|
+
};
|
|
22
|
+
debug = (...message) => {
|
|
23
|
+
this.logToTestOps(LOG_LEVELS.DEBUG, message);
|
|
24
|
+
};
|
|
25
|
+
info = (...message) => {
|
|
26
|
+
this.logToTestOps(LOG_LEVELS.INFO, message);
|
|
27
|
+
};
|
|
28
|
+
warn = (...message) => {
|
|
29
|
+
this.logToTestOps(LOG_LEVELS.WARN, message);
|
|
30
|
+
};
|
|
31
|
+
error = (...message) => {
|
|
32
|
+
this.logToTestOps(LOG_LEVELS.ERROR, message);
|
|
33
|
+
};
|
|
34
|
+
log = (...message) => {
|
|
35
|
+
this.logToTestOps(LOG_LEVELS.INFO, message);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export default logPatcher;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Transport from 'winston-transport';
|
|
2
|
+
declare class logReportingAPI extends Transport {
|
|
3
|
+
log(info: any, callback?: undefined | Function): void;
|
|
4
|
+
logToTestOps: (level?: string, message?: string, consoleLog?: boolean) => void;
|
|
5
|
+
trace: (message: any) => void;
|
|
6
|
+
debug: (message: any) => void;
|
|
7
|
+
info: (message: any) => void;
|
|
8
|
+
warn: (message: any) => void;
|
|
9
|
+
error: (message: any) => void;
|
|
10
|
+
}
|
|
11
|
+
export default logReportingAPI;
|
|
12
|
+
//# sourceMappingURL=logReportingAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logReportingAPI.d.ts","sourceRoot":"","sources":["../src/logReportingAPI.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAA;AAWzC,cAAM,eAAgB,SAAQ,SAAS;IACnC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAE,SAAS,GAAC,QAAoB;IAkBvD,YAAY,mEAWX;IAGD,KAAK,YAAa,GAAG,UAEpB;IAED,KAAK,YAAa,GAAG,UAEpB;IAED,IAAI,YAAa,GAAG,UAEnB;IAED,IAAI,YAAa,GAAG,UAEnB;IAED,KAAK,YAAa,GAAG,UAEpB;CACJ;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import Transport from 'winston-transport';
|
|
2
|
+
import { consoleHolder } from './constants.js';
|
|
3
|
+
const LOG_LEVELS = {
|
|
4
|
+
INFO: 'INFO',
|
|
5
|
+
ERROR: 'ERROR',
|
|
6
|
+
DEBUG: 'DEBUG',
|
|
7
|
+
TRACE: 'TRACE',
|
|
8
|
+
WARN: 'WARN',
|
|
9
|
+
};
|
|
10
|
+
class logReportingAPI extends Transport {
|
|
11
|
+
log(info, callback = undefined) {
|
|
12
|
+
setImmediate(() => {
|
|
13
|
+
this.emit('logged', info);
|
|
14
|
+
});
|
|
15
|
+
if (typeof (info) === 'object') {
|
|
16
|
+
/* From log appender */
|
|
17
|
+
this.logToTestOps(info.level || LOG_LEVELS.INFO, info.message, false);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
/* From default console */
|
|
21
|
+
this.logToTestOps(LOG_LEVELS.INFO, info);
|
|
22
|
+
}
|
|
23
|
+
if (callback && typeof callback === 'function') {
|
|
24
|
+
callback();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
logToTestOps = (level = LOG_LEVELS.INFO, message = '', consoleLog = true) => {
|
|
28
|
+
if (consoleLog) {
|
|
29
|
+
consoleHolder[level.toLowerCase()](message);
|
|
30
|
+
}
|
|
31
|
+
process.emit(`bs:addLog:${process.pid}`, {
|
|
32
|
+
timestamp: new Date().toISOString(),
|
|
33
|
+
level: level.toUpperCase(),
|
|
34
|
+
message: message,
|
|
35
|
+
kind: 'TEST_LOG',
|
|
36
|
+
http_response: {}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
/* Patching this would show user an extended trace on their cli */
|
|
40
|
+
trace = (message) => {
|
|
41
|
+
this.logToTestOps(LOG_LEVELS.TRACE, message);
|
|
42
|
+
};
|
|
43
|
+
debug = (message) => {
|
|
44
|
+
this.logToTestOps(LOG_LEVELS.DEBUG, message);
|
|
45
|
+
};
|
|
46
|
+
info = (message) => {
|
|
47
|
+
this.logToTestOps(LOG_LEVELS.INFO, message);
|
|
48
|
+
};
|
|
49
|
+
warn = (message) => {
|
|
50
|
+
this.logToTestOps(LOG_LEVELS.WARN, message);
|
|
51
|
+
};
|
|
52
|
+
error = (message) => {
|
|
53
|
+
this.logToTestOps(LOG_LEVELS.ERROR, message);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export default logReportingAPI;
|
package/build/reporter.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SuiteStats, TestStats, RunnerStats, HookStats } from '@wdio/reporter';
|
|
2
2
|
import WDIOReporter from '@wdio/reporter';
|
|
3
|
+
import type { CurrentRunInfo, StdLog } from './types.js';
|
|
3
4
|
import type { TestMeta } from './types.js';
|
|
4
5
|
declare class _TestReporter extends WDIOReporter {
|
|
5
6
|
private _capabilities;
|
|
@@ -12,7 +13,12 @@ declare class _TestReporter extends WDIOReporter {
|
|
|
12
13
|
private static _tests;
|
|
13
14
|
private _gitConfigPath?;
|
|
14
15
|
private _gitConfigured;
|
|
16
|
+
private _currentHook;
|
|
17
|
+
private _currentTest;
|
|
15
18
|
onRunnerStart(runnerStats: RunnerStats): Promise<void>;
|
|
19
|
+
registerListeners(): void;
|
|
20
|
+
appendTestItemLog(stdLog: StdLog): Promise<void>;
|
|
21
|
+
setCurrentHook(hookDetails: CurrentRunInfo): void;
|
|
16
22
|
configureGit(): Promise<void>;
|
|
17
23
|
static getTests(): Record<string, TestMeta>;
|
|
18
24
|
onSuiteStart(suiteStats: SuiteStats): void;
|
package/build/reporter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACnF,OAAO,YAAY,MAAM,gBAAgB,CAAA;
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iBAAiB,CAAC,SAAS,EAAE,SAAS;IAIhC,UAAU,CAAE,SAAS,EAAE,SAAS;IAWhC,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM;CA+E7E;AAED,QAAA,MAAM,YAAY,EAAE,OAAO,aAAoD,CAAA;AAC/E,KAAK,YAAY,GAAG,aAAa,CAAA;AACjC,eAAe,YAAY,CAAA"}
|
package/build/reporter.js
CHANGED
|
@@ -3,7 +3,7 @@ import logger from '@wdio/logger';
|
|
|
3
3
|
import WDIOReporter from '@wdio/reporter';
|
|
4
4
|
import * as url from 'node:url';
|
|
5
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
-
import { getCloudProvider, uploadEventData, o11yClassErrorHandler, getGitMetaData, removeAnsiColors, getHookType } from './util.js';
|
|
6
|
+
import { getCloudProvider, uploadEventData, o11yClassErrorHandler, getGitMetaData, removeAnsiColors, getHookType, pushDataToQueue } from './util.js';
|
|
7
7
|
import RequestQueueHandler from './request-handler.js';
|
|
8
8
|
const log = logger('@wdio/browserstack-service');
|
|
9
9
|
class _TestReporter extends WDIOReporter {
|
|
@@ -17,6 +17,8 @@ class _TestReporter extends WDIOReporter {
|
|
|
17
17
|
static _tests = {};
|
|
18
18
|
_gitConfigPath;
|
|
19
19
|
_gitConfigured = false;
|
|
20
|
+
_currentHook = {};
|
|
21
|
+
_currentTest = {};
|
|
20
22
|
async onRunnerStart(runnerStats) {
|
|
21
23
|
this._capabilities = runnerStats.capabilities;
|
|
22
24
|
this._config = runnerStats.config;
|
|
@@ -25,6 +27,40 @@ class _TestReporter extends WDIOReporter {
|
|
|
25
27
|
this._observability = this._config.testObservability;
|
|
26
28
|
}
|
|
27
29
|
await this.configureGit();
|
|
30
|
+
this.registerListeners();
|
|
31
|
+
}
|
|
32
|
+
registerListeners() {
|
|
33
|
+
if (this._config?.framework !== 'jasmine') {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
process.removeAllListeners(`bs:addLog:${process.pid}`);
|
|
37
|
+
process.on(`bs:addLog:${process.pid}`, this.appendTestItemLog.bind(this));
|
|
38
|
+
}
|
|
39
|
+
async appendTestItemLog(stdLog) {
|
|
40
|
+
if (this._currentHook.uuid && !this._currentHook.finished) {
|
|
41
|
+
stdLog.hook_run_uuid = this._currentHook.uuid;
|
|
42
|
+
}
|
|
43
|
+
else if (this._currentTest.uuid) {
|
|
44
|
+
stdLog.test_run_uuid = this._currentTest.uuid;
|
|
45
|
+
}
|
|
46
|
+
if (stdLog.hook_run_uuid || stdLog.test_run_uuid) {
|
|
47
|
+
await pushDataToQueue({
|
|
48
|
+
event_type: 'LogCreated',
|
|
49
|
+
logs: [stdLog]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
setCurrentHook(hookDetails) {
|
|
54
|
+
if (hookDetails.finished) {
|
|
55
|
+
if (this._currentHook.uuid === hookDetails.uuid) {
|
|
56
|
+
this._currentHook.finished = true;
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this._currentHook = {
|
|
61
|
+
uuid: hookDetails.uuid,
|
|
62
|
+
finished: false
|
|
63
|
+
};
|
|
28
64
|
}
|
|
29
65
|
async configureGit() {
|
|
30
66
|
if (this._gitConfigured) {
|
|
@@ -93,8 +129,10 @@ class _TestReporter extends WDIOReporter {
|
|
|
93
129
|
if (testStats.fullTitle === '<unknown test>') {
|
|
94
130
|
return;
|
|
95
131
|
}
|
|
132
|
+
const uuid = uuidv4();
|
|
133
|
+
this._currentTest.uuid = uuid;
|
|
96
134
|
_TestReporter._tests[testStats.fullTitle] = {
|
|
97
|
-
uuid:
|
|
135
|
+
uuid: uuid,
|
|
98
136
|
};
|
|
99
137
|
await this.sendTestRunEvent(testStats, 'TestRunStarted');
|
|
100
138
|
}
|
|
@@ -104,6 +142,7 @@ class _TestReporter extends WDIOReporter {
|
|
|
104
142
|
}
|
|
105
143
|
const identifier = this.getHookIdentifier(hookStats);
|
|
106
144
|
const hookId = uuidv4();
|
|
145
|
+
this.setCurrentHook({ uuid: hookId });
|
|
107
146
|
_TestReporter._tests[identifier] = {
|
|
108
147
|
uuid: hookId,
|
|
109
148
|
startedAt: (new Date()).toISOString()
|
|
@@ -123,6 +162,7 @@ class _TestReporter extends WDIOReporter {
|
|
|
123
162
|
finishedAt: (new Date()).toISOString()
|
|
124
163
|
};
|
|
125
164
|
}
|
|
165
|
+
this.setCurrentHook({ uuid: _TestReporter._tests[identifier].uuid, finished: true });
|
|
126
166
|
if (!hookStats.state && !hookStats.error) {
|
|
127
167
|
hookStats.state = 'passed';
|
|
128
168
|
}
|
package/build/service.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Services, Capabilities, Options, Frameworks } from '@wdio/types';
|
|
2
2
|
import type { BrowserstackConfig, MultiRemoteAction } from './types.js';
|
|
3
|
-
import type { Pickle, Feature, ITestCaseHookParameter } from './cucumber-types.js';
|
|
3
|
+
import type { Pickle, Feature, ITestCaseHookParameter, CucumberHook } from './cucumber-types.js';
|
|
4
4
|
export default class BrowserstackService implements Services.ServiceInstance {
|
|
5
5
|
private _caps;
|
|
6
6
|
private _config;
|
|
@@ -29,8 +29,8 @@ export default class BrowserstackService implements Services.ServiceInstance {
|
|
|
29
29
|
* and `suite.fullTitle` is `undefined`, so no alternative to use for the job name.
|
|
30
30
|
*/
|
|
31
31
|
beforeSuite(suite: Frameworks.Suite): Promise<void>;
|
|
32
|
-
beforeHook(test: Frameworks.Test, context: any): Promise<void>;
|
|
33
|
-
afterHook(test: Frameworks.Test, context: unknown, result: Frameworks.TestResult): Promise<void>;
|
|
32
|
+
beforeHook(test: Frameworks.Test | CucumberHook, context: any): Promise<void>;
|
|
33
|
+
afterHook(test: Frameworks.Test | CucumberHook, context: unknown, result: Frameworks.TestResult): Promise<void>;
|
|
34
34
|
beforeTest(test: Frameworks.Test): Promise<void>;
|
|
35
35
|
afterTest(test: Frameworks.Test, context: never, results: Frameworks.TestResult): Promise<void>;
|
|
36
36
|
after(result: number): Promise<void>;
|
package/build/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAW9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAmB,MAAM,YAAY,CAAA;AACxF,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAQhG,MAAM,CAAC,OAAO,OAAO,mBAAoB,YAAW,QAAQ,CAAC,eAAe;IAiBpE,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,OAAO;IAjBnB,OAAO,CAAC,eAAe,CAAmD;IAC1E,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,iBAAiB,CAAe;IACxC,OAAO,CAAC,gBAAgB,CAA4D;IACpF,OAAO,CAAC,QAAQ,CAAC,CAAqB;IACtC,OAAO,CAAC,WAAW,CAAC,CAAQ;IAC5B,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,cAAc,CAAA;IACtB,OAAO,CAAC,YAAY,CAAC,CAA0C;IAC/D,OAAO,CAAC,gBAAgB,CAAC,CAAiB;gBAGtC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,EACxC,KAAK,EAAE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,YAAY,EAAE,MAAM;IAgCzD,cAAc,IAAI,OAAO;IAMzB,UAAU,CAAE,WAAW,EAAE,GAAG;IAU5B,kBAAkB,CAAE,MAAM,EAAE,iBAAiB;IAqB7C,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG;IAarC,gBAAgB;YAuBR,eAAe;IA0B7B,OAAO,CAAC,cAAc;YAIR,eAAe;CAqBhC"}
|
package/build/service.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import logger from '@wdio/logger';
|
|
2
2
|
import got from 'got';
|
|
3
3
|
import PerformanceTester from './performance-tester.js';
|
|
4
|
-
import { getBrowserDescription, getBrowserCapabilities, isBrowserstackCapability, getParentSuiteName, isBrowserstackSession, } from './util.js';
|
|
4
|
+
import { getBrowserDescription, getBrowserCapabilities, isBrowserstackCapability, getParentSuiteName, isBrowserstackSession, patchConsoleLogs, } from './util.js';
|
|
5
5
|
import InsightsHandler from './insights-handler.js';
|
|
6
6
|
import TestReporter from './reporter.js';
|
|
7
7
|
import { DEFAULT_OPTIONS } from './constants.js';
|
|
@@ -73,6 +73,7 @@ export default class BrowserstackService {
|
|
|
73
73
|
}
|
|
74
74
|
this._scenariosThatRan = [];
|
|
75
75
|
if (this._observability && this._browser) {
|
|
76
|
+
patchConsoleLogs();
|
|
76
77
|
try {
|
|
77
78
|
this._insightsHandler = new InsightsHandler(this._browser, this._isAppAutomate(), this._config.framework);
|
|
78
79
|
await this._insightsHandler.before();
|
|
@@ -175,6 +176,7 @@ export default class BrowserstackService {
|
|
|
175
176
|
this._suiteTitle = feature.name;
|
|
176
177
|
await this._setSessionName(feature.name);
|
|
177
178
|
await this._setAnnotation(`Feature: ${feature.name}`);
|
|
179
|
+
await this._insightsHandler?.beforeFeature(uri, feature);
|
|
178
180
|
}
|
|
179
181
|
/**
|
|
180
182
|
* Runs before a Cucumber Scenario.
|
package/build/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Capabilities, Options } from '@wdio/types';
|
|
1
|
+
import type { Capabilities, Options, Frameworks } from '@wdio/types';
|
|
2
2
|
import type { Options as BSOptions } from 'browserstack-local';
|
|
3
3
|
export interface SessionResponse {
|
|
4
4
|
automation_session: {
|
|
@@ -139,6 +139,13 @@ export interface TestMeta {
|
|
|
139
139
|
name: string;
|
|
140
140
|
};
|
|
141
141
|
examples?: string[];
|
|
142
|
+
hookType?: string;
|
|
143
|
+
testRunId?: string;
|
|
144
|
+
}
|
|
145
|
+
export interface CurrentRunInfo {
|
|
146
|
+
uuid?: string;
|
|
147
|
+
test?: Frameworks.Test;
|
|
148
|
+
finished?: boolean;
|
|
142
149
|
}
|
|
143
150
|
export interface TestData {
|
|
144
151
|
uuid?: string;
|
|
@@ -185,6 +192,15 @@ export interface UploadType {
|
|
|
185
192
|
test_run?: TestData;
|
|
186
193
|
logs?: any[];
|
|
187
194
|
}
|
|
195
|
+
export interface StdLog {
|
|
196
|
+
timestamp: string;
|
|
197
|
+
kind: string;
|
|
198
|
+
level?: string;
|
|
199
|
+
message?: string;
|
|
200
|
+
http_response?: any;
|
|
201
|
+
test_run_uuid?: string;
|
|
202
|
+
hook_run_uuid?: string;
|
|
203
|
+
}
|
|
188
204
|
export interface LaunchResponse {
|
|
189
205
|
jwt: string;
|
|
190
206
|
build_hashed_id: string;
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAA;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C,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,iBAAiB;IACvB,YAAY,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,UAAU,YAAY;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB;AAED,UAAU,QAAQ;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,UAAU,OAAO;IACb,SAAS,EAAE,MAAM,EAAE,CAAA;CACtB"}
|
package/build/util.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { Capabilities, Frameworks, Options } from '@wdio/types';
|
|
|
6
6
|
import type { BeforeCommandArgs, AfterCommandArgs } from '@wdio/reporter';
|
|
7
7
|
import type { UploadType, BrowserstackConfig } from './types.js';
|
|
8
8
|
import type { ITestCaseHookParameter } from './cucumber-types.js';
|
|
9
|
+
import RequestQueueHandler from './request-handler.js';
|
|
9
10
|
export declare const DEFAULT_REQUEST_CONFIG: {
|
|
10
11
|
agent: {
|
|
11
12
|
http: http.Agent;
|
|
@@ -101,6 +102,15 @@ export declare function getObservabilityProject(options: BrowserstackConfig & Op
|
|
|
101
102
|
export declare function getObservabilityBuild(options: BrowserstackConfig & Options.Testrunner, bstackBuildName?: string): string;
|
|
102
103
|
export declare function getObservabilityBuildTags(options: BrowserstackConfig & Options.Testrunner, bstackBuildTag?: string): string[];
|
|
103
104
|
export declare function frameworkSupportsHook(hook: string, framework?: string): boolean;
|
|
105
|
+
export declare function patchConsoleLogs(): void;
|
|
106
|
+
export declare function getFailureObject(error: string | Error): {
|
|
107
|
+
failure: {
|
|
108
|
+
backtrace: string[];
|
|
109
|
+
}[];
|
|
110
|
+
failure_reason: string;
|
|
111
|
+
failure_type: string | null;
|
|
112
|
+
};
|
|
113
|
+
export declare function pushDataToQueue(data: UploadType, requestQueueHandler?: RequestQueueHandler | undefined): Promise<void>;
|
|
104
114
|
export declare const sleep: (ms?: number) => Promise<unknown>;
|
|
105
115
|
export {};
|
|
106
116
|
//# sourceMappingURL=util.d.ts.map
|
package/build/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAEA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,MAAM,YAAY,CAAA;AAI9B,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAEA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,MAAM,YAAY,CAAA;AAI9B,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAUzE,OAAO,KAAK,EAAc,UAAU,EAAkB,kBAAkB,EAAE,MAAM,YAAY,CAAA;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,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC,EAAE,MAAM,sBAQnH;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,eAAe,CAAC,EAAE,MAAM,UAQ/G;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAW7H;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,WAUrE;AAED,wBAAgB,gBAAgB,SAU/B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAC,KAAK;;;;;;EAUnD;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,mBAAmB,GAAE,mBAAmB,GAAC,SAAqB,iBAQrH;AAED,eAAO,MAAM,KAAK,mCAAkE,CAAA"}
|
package/build/util.js
CHANGED
|
@@ -8,8 +8,9 @@ import logger from '@wdio/logger';
|
|
|
8
8
|
import got, { HTTPError } from 'got';
|
|
9
9
|
import gitRepoInfo from 'git-repo-info';
|
|
10
10
|
import gitconfig from 'gitconfiglocal';
|
|
11
|
+
import logPatcher from './logPatcher.js';
|
|
11
12
|
import PerformanceTester from './performance-tester.js';
|
|
12
|
-
import { BROWSER_DESCRIPTION, DATA_ENDPOINT, DATA_EVENT_ENDPOINT, DATA_SCREENSHOT_ENDPOINT } from './constants.js';
|
|
13
|
+
import { BROWSER_DESCRIPTION, DATA_ENDPOINT, DATA_EVENT_ENDPOINT, DATA_SCREENSHOT_ENDPOINT, consoleHolder } from './constants.js';
|
|
13
14
|
import RequestQueueHandler from './request-handler.js';
|
|
14
15
|
import CrashReporter from './crash-reporter.js';
|
|
15
16
|
const pGitconfig = promisify(gitconfig);
|
|
@@ -596,6 +597,38 @@ export function frameworkSupportsHook(hook, framework) {
|
|
|
596
597
|
if (framework === 'mocha' && (hook === 'before' || hook === 'after' || hook === 'beforeEach' || hook === 'afterEach')) {
|
|
597
598
|
return true;
|
|
598
599
|
}
|
|
600
|
+
if (framework === 'cucumber') {
|
|
601
|
+
return true;
|
|
602
|
+
}
|
|
599
603
|
return false;
|
|
600
604
|
}
|
|
605
|
+
export function patchConsoleLogs() {
|
|
606
|
+
const BSTestOpsPatcher = new logPatcher({});
|
|
607
|
+
Object.keys(consoleHolder).forEach((method) => {
|
|
608
|
+
const origMethod = console[method].bind(console);
|
|
609
|
+
console[method] = (...args) => {
|
|
610
|
+
origMethod(...args);
|
|
611
|
+
BSTestOpsPatcher[method](...args);
|
|
612
|
+
};
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
export function getFailureObject(error) {
|
|
616
|
+
const stack = error.stack;
|
|
617
|
+
const message = typeof error === 'string' ? error : error.message;
|
|
618
|
+
const backtrace = stack ? removeAnsiColors(stack.toString()) : '';
|
|
619
|
+
return {
|
|
620
|
+
failure: [{ backtrace: [backtrace] }],
|
|
621
|
+
failure_reason: removeAnsiColors(message.toString()),
|
|
622
|
+
failure_type: message ? (message.toString().match(/AssertionError/) ? 'AssertionError' : 'UnhandledError') : null
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
export async function pushDataToQueue(data, requestQueueHandler = undefined) {
|
|
626
|
+
if (!requestQueueHandler) {
|
|
627
|
+
requestQueueHandler = RequestQueueHandler.getInstance();
|
|
628
|
+
}
|
|
629
|
+
const req = requestQueueHandler.add(data);
|
|
630
|
+
if (req.proceed && req.data) {
|
|
631
|
+
await uploadEventData(req.data, req.url);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
601
634
|
export const sleep = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/browserstack-service",
|
|
3
|
-
"version": "8.16.
|
|
3
|
+
"version": "8.16.6",
|
|
4
4
|
"description": "WebdriverIO service for better Browserstack integration",
|
|
5
5
|
"author": "Adam Bjerstedt <abjerstedt@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-browserstack-service",
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"gitconfiglocal": "^2.1.0",
|
|
42
42
|
"got": "^ 12.6.1",
|
|
43
43
|
"uuid": "^9.0.0",
|
|
44
|
-
"webdriverio": "8.16.
|
|
44
|
+
"webdriverio": "8.16.6",
|
|
45
|
+
"winston-transport": "^4.5.0"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
48
|
"@wdio/cli": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
@@ -52,5 +53,5 @@
|
|
|
52
53
|
"publishConfig": {
|
|
53
54
|
"access": "public"
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "aa35c291fb496b80350766d674385ea7b4d1516a"
|
|
56
57
|
}
|