@wdio/mocha-framework 7.16.13 → 7.17.0
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 +4 -4
- package/build/constants.d.ts +0 -24
- package/build/constants.d.ts.map +0 -1
- package/build/constants.js +0 -30
- package/build/index.d.ts +0 -62
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -316
- package/build/types.d.ts +0 -113
- package/build/types.d.ts.map +0 -1
- package/build/types.js +0 -2
- package/build/utils.d.ts +0 -3
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/mocha-framework",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.17.0",
|
|
4
4
|
"description": "A WebdriverIO plugin. Adapter for Mocha testing framework.",
|
|
5
5
|
"author": "Christian Bromann <christian@saucelabs.com>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-mocha-framework",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@types/mocha": "^9.0.0",
|
|
26
26
|
"@wdio/logger": "7.16.0",
|
|
27
|
-
"@wdio/types": "7.16.
|
|
28
|
-
"@wdio/utils": "7.
|
|
27
|
+
"@wdio/types": "7.16.14",
|
|
28
|
+
"@wdio/utils": "7.17.0",
|
|
29
29
|
"expect-webdriverio": "^3.0.0",
|
|
30
30
|
"mocha": "^9.0.0"
|
|
31
31
|
},
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"types": "./build/index.d.ts",
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "e18d2cde6ff979758830bdff4c3bc82ca9818b24"
|
|
40
40
|
}
|
package/build/constants.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare const INTERFACES: {
|
|
2
|
-
readonly bdd: readonly ["it", "before", "beforeEach", "after", "afterEach"];
|
|
3
|
-
readonly tdd: readonly ["test", "suiteSetup", "setup", "suiteTeardown", "teardown"];
|
|
4
|
-
readonly qunit: readonly ["test", "before", "beforeEach", "after", "afterEach"];
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* to map Mocha events to WDIO events
|
|
8
|
-
*/
|
|
9
|
-
export declare const EVENTS: {
|
|
10
|
-
readonly suite: "suite:start";
|
|
11
|
-
readonly 'suite end': "suite:end";
|
|
12
|
-
readonly test: "test:start";
|
|
13
|
-
readonly 'test end': "test:end";
|
|
14
|
-
readonly hook: "hook:start";
|
|
15
|
-
readonly 'hook end': "hook:end";
|
|
16
|
-
readonly pass: "test:pass";
|
|
17
|
-
readonly fail: "test:fail";
|
|
18
|
-
readonly retry: "test:retry";
|
|
19
|
-
readonly pending: "test:pending";
|
|
20
|
-
};
|
|
21
|
-
export declare const NOOP: () => void;
|
|
22
|
-
export declare const MOCHA_TIMEOUT_MESSAGE = "For async tests and hooks, ensure \"done()\" is called; if returning a Promise, ensure it resolves.";
|
|
23
|
-
export declare const MOCHA_TIMEOUT_MESSAGE_REPLACEMENT: string;
|
|
24
|
-
//# sourceMappingURL=constants.d.ts.map
|
package/build/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;CAIb,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;CAWT,CAAA;AAEV,eAAO,MAAM,IAAI,YAA6C,CAAA;AAC9D,eAAO,MAAM,qBAAqB,wGAAsG,CAAA;AACxI,eAAO,MAAM,iCAAiC,QAGnC,CAAA"}
|
package/build/constants.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MOCHA_TIMEOUT_MESSAGE_REPLACEMENT = exports.MOCHA_TIMEOUT_MESSAGE = exports.NOOP = exports.EVENTS = exports.INTERFACES = void 0;
|
|
4
|
-
exports.INTERFACES = {
|
|
5
|
-
bdd: ['it', 'before', 'beforeEach', 'after', 'afterEach'],
|
|
6
|
-
tdd: ['test', 'suiteSetup', 'setup', 'suiteTeardown', 'teardown'],
|
|
7
|
-
qunit: ['test', 'before', 'beforeEach', 'after', 'afterEach']
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* to map Mocha events to WDIO events
|
|
11
|
-
*/
|
|
12
|
-
exports.EVENTS = {
|
|
13
|
-
'suite': 'suite:start',
|
|
14
|
-
'suite end': 'suite:end',
|
|
15
|
-
'test': 'test:start',
|
|
16
|
-
'test end': 'test:end',
|
|
17
|
-
'hook': 'hook:start',
|
|
18
|
-
'hook end': 'hook:end',
|
|
19
|
-
'pass': 'test:pass',
|
|
20
|
-
'fail': 'test:fail',
|
|
21
|
-
'retry': 'test:retry',
|
|
22
|
-
'pending': 'test:pending'
|
|
23
|
-
};
|
|
24
|
-
const NOOP = function () { };
|
|
25
|
-
exports.NOOP = NOOP;
|
|
26
|
-
exports.MOCHA_TIMEOUT_MESSAGE = 'For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.';
|
|
27
|
-
exports.MOCHA_TIMEOUT_MESSAGE_REPLACEMENT = [
|
|
28
|
-
'The execution in the test "%s %s" took too long. Try to reduce the run time or',
|
|
29
|
-
'increase your timeout for test specs (https://webdriver.io/docs/timeouts).'
|
|
30
|
-
].join(' ');
|
package/build/index.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="expect-webdriverio/types/standalone" />
|
|
3
|
-
import Mocha from 'mocha';
|
|
4
|
-
import type { Capabilities, Services } from '@wdio/types';
|
|
5
|
-
import type { MochaConfig, MochaOpts as MochaOptsImport, FrameworkMessage, FormattedMessage, MochaContext, MochaError } from './types';
|
|
6
|
-
import type { EventEmitter } from 'events';
|
|
7
|
-
import type ExpectWebdriverIO from 'expect-webdriverio';
|
|
8
|
-
declare type EventTypes = 'hook' | 'test' | 'suite';
|
|
9
|
-
/**
|
|
10
|
-
* Mocha runner
|
|
11
|
-
*/
|
|
12
|
-
declare class MochaAdapter {
|
|
13
|
-
private _cid;
|
|
14
|
-
private _config;
|
|
15
|
-
private _specs;
|
|
16
|
-
private _capabilities;
|
|
17
|
-
private _reporter;
|
|
18
|
-
private _mocha?;
|
|
19
|
-
private _runner?;
|
|
20
|
-
private _specLoadError?;
|
|
21
|
-
private _level;
|
|
22
|
-
private _hasTests;
|
|
23
|
-
private _suiteIds;
|
|
24
|
-
private _suiteCnt;
|
|
25
|
-
private _hookCnt;
|
|
26
|
-
private _testCnt;
|
|
27
|
-
constructor(_cid: string, _config: MochaConfig, _specs: string[], _capabilities: Capabilities.RemoteCapability, _reporter: EventEmitter);
|
|
28
|
-
init(): Promise<this>;
|
|
29
|
-
_loadFiles(mochaOpts: MochaOptsImport): Promise<void>;
|
|
30
|
-
hasTests(): boolean;
|
|
31
|
-
run(): Promise<unknown>;
|
|
32
|
-
options(options: MochaOptsImport, context: MochaContext): void;
|
|
33
|
-
preRequire(context: Mocha.MochaGlobals, file: string, mocha: Mocha): void;
|
|
34
|
-
/**
|
|
35
|
-
* Hooks which are added as true Mocha hooks need to call done() to notify async
|
|
36
|
-
*/
|
|
37
|
-
wrapHook(hookName: keyof Services.HookFunctions): () => Promise<void | unknown[]>;
|
|
38
|
-
prepareMessage(hookName: keyof Services.HookFunctions): FormattedMessage;
|
|
39
|
-
formatMessage(params: FrameworkMessage): FormattedMessage;
|
|
40
|
-
requireExternalModules(modules: string[], context: MochaContext): void;
|
|
41
|
-
emit(event: string, payload: any, err?: MochaError): void;
|
|
42
|
-
getSyncEventIdStart(type: EventTypes): string;
|
|
43
|
-
getSyncEventIdEnd(type: EventTypes): string;
|
|
44
|
-
getUID(message: FrameworkMessage): string;
|
|
45
|
-
}
|
|
46
|
-
declare const adapterFactory: {
|
|
47
|
-
init?: Function;
|
|
48
|
-
};
|
|
49
|
-
export default adapterFactory;
|
|
50
|
-
export { MochaAdapter, adapterFactory };
|
|
51
|
-
declare global {
|
|
52
|
-
namespace WebdriverIO {
|
|
53
|
-
interface MochaOpts extends MochaOptsImport {
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
namespace NodeJS {
|
|
57
|
-
interface Global {
|
|
58
|
-
expect: ExpectWebdriverIO.Expect;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AACA,OAAO,KAAiB,MAAM,OAAO,CAAA;AAKrC,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAIzD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,IAAI,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACtI,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,KAAK,iBAAiB,MAAM,oBAAoB,CAAA;AAgBvD,aAAK,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAG3C;;GAEG;AACH,cAAM,YAAY;IAaV,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;IAhBrB,OAAO,CAAC,MAAM,CAAC,CAAO;IACtB,OAAO,CAAC,OAAO,CAAC,CAAQ;IACxB,OAAO,CAAC,cAAc,CAAC,CAAO;IAE9B,OAAO,CAAC,MAAM,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,SAAQ,eAAe;SAAG;KACjD;IACD,UAAU,MAAM,CAAC;QACb,UAAU,MAAM;YACZ,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAA;SACnC;KACJ;CACJ"}
|
package/build/index.js
DELETED
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.adapterFactory = exports.MochaAdapter = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const mocha_1 = __importDefault(require("mocha"));
|
|
9
|
-
const util_1 = require("util");
|
|
10
|
-
const logger_1 = __importDefault(require("@wdio/logger"));
|
|
11
|
-
const utils_1 = require("@wdio/utils");
|
|
12
|
-
const utils_2 = require("./utils");
|
|
13
|
-
const constants_1 = require("./constants");
|
|
14
|
-
const log = (0, logger_1.default)('@wdio/mocha-framework');
|
|
15
|
-
/**
|
|
16
|
-
* Extracts the mocha UI type following this convention:
|
|
17
|
-
* - If the mochaOpts.ui provided doesn't contain a '-' then the full name
|
|
18
|
-
* is taken as ui type (i.e. 'bdd','tdd','qunit')
|
|
19
|
-
* - If it contains a '-' then it asumes we are providing a custom ui for
|
|
20
|
-
* mocha. Then it extracts the text after the last '-' (ignoring .js if
|
|
21
|
-
* provided) as the interface type. (i.e. strong-bdd in
|
|
22
|
-
* https://github.com/strongloop/strong-mocha-interfaces)
|
|
23
|
-
*/
|
|
24
|
-
const MOCHA_UI_TYPE_EXTRACTOR = /^(?:.*-)?([^-.]+)(?:.js)?$/;
|
|
25
|
-
const DEFAULT_INTERFACE_TYPE = 'bdd';
|
|
26
|
-
/**
|
|
27
|
-
* Mocha runner
|
|
28
|
-
*/
|
|
29
|
-
class MochaAdapter {
|
|
30
|
-
constructor(_cid, _config, _specs, _capabilities, _reporter) {
|
|
31
|
-
this._cid = _cid;
|
|
32
|
-
this._config = _config;
|
|
33
|
-
this._specs = _specs;
|
|
34
|
-
this._capabilities = _capabilities;
|
|
35
|
-
this._reporter = _reporter;
|
|
36
|
-
this._level = 0;
|
|
37
|
-
this._hasTests = true;
|
|
38
|
-
this._suiteIds = ['0'];
|
|
39
|
-
this._suiteCnt = new Map();
|
|
40
|
-
this._hookCnt = new Map();
|
|
41
|
-
this._testCnt = new Map();
|
|
42
|
-
this._config = Object.assign({
|
|
43
|
-
mochaOpts: {}
|
|
44
|
-
}, _config);
|
|
45
|
-
}
|
|
46
|
-
async init() {
|
|
47
|
-
const { mochaOpts } = this._config;
|
|
48
|
-
const mocha = this._mocha = new mocha_1.default(mochaOpts);
|
|
49
|
-
await mocha.loadFilesAsync();
|
|
50
|
-
mocha.reporter(constants_1.NOOP);
|
|
51
|
-
mocha.fullTrace();
|
|
52
|
-
this._specs.forEach((spec) => mocha.addFile(spec));
|
|
53
|
-
mocha.suite.on('pre-require', this.preRequire.bind(this));
|
|
54
|
-
await this._loadFiles(mochaOpts);
|
|
55
|
-
/**
|
|
56
|
-
* import and set options for `expect-webdriverio` assertion lib once
|
|
57
|
-
* the framework was initiated so that it can detect the environment
|
|
58
|
-
*/
|
|
59
|
-
const { setOptions } = require('expect-webdriverio');
|
|
60
|
-
setOptions({
|
|
61
|
-
wait: this._config.waitforTimeout,
|
|
62
|
-
interval: this._config.waitforInterval, // interval between attempts
|
|
63
|
-
});
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
async _loadFiles(mochaOpts) {
|
|
67
|
-
try {
|
|
68
|
-
await this._mocha.loadFilesAsync();
|
|
69
|
-
/**
|
|
70
|
-
* grep
|
|
71
|
-
*/
|
|
72
|
-
const mochaRunner = new mocha_1.default.Runner(this._mocha.suite, { delay: false });
|
|
73
|
-
if (mochaOpts.grep) {
|
|
74
|
-
mochaRunner.grep(this._mocha.options.grep, mochaOpts.invert);
|
|
75
|
-
}
|
|
76
|
-
this._hasTests = mochaRunner.total > 0;
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
const error = '' +
|
|
80
|
-
'Unable to load spec files quite likely because they rely on `browser` object that is not fully initialised.\n' +
|
|
81
|
-
'`browser` object has only `capabilities` and some flags like `isMobile`.\n' +
|
|
82
|
-
'Helper files that use other `browser` commands have to be moved to `before` hook.\n' +
|
|
83
|
-
`Spec file(s): ${this._specs.join(',')}\n` +
|
|
84
|
-
`Error: ${err.stack}`;
|
|
85
|
-
this._specLoadError = new Error(error);
|
|
86
|
-
log.warn(error);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
hasTests() {
|
|
90
|
-
return this._hasTests;
|
|
91
|
-
}
|
|
92
|
-
async run() {
|
|
93
|
-
const mocha = this._mocha;
|
|
94
|
-
let runtimeError;
|
|
95
|
-
const result = await new Promise((resolve) => {
|
|
96
|
-
try {
|
|
97
|
-
this._runner = mocha.run(resolve);
|
|
98
|
-
}
|
|
99
|
-
catch (err) {
|
|
100
|
-
runtimeError = err;
|
|
101
|
-
return resolve(1);
|
|
102
|
-
}
|
|
103
|
-
Object.keys(constants_1.EVENTS).forEach((e) => this._runner.on(e, this.emit.bind(this, constants_1.EVENTS[e])));
|
|
104
|
-
this._runner.suite.beforeAll(this.wrapHook('beforeSuite'));
|
|
105
|
-
this._runner.suite.afterAll(this.wrapHook('afterSuite'));
|
|
106
|
-
});
|
|
107
|
-
await (0, utils_1.executeHooksWithArgs)('after', this._config.after, [runtimeError || result, this._capabilities, this._specs]);
|
|
108
|
-
/**
|
|
109
|
-
* in case the spec has a runtime error throw after the wdio hook
|
|
110
|
-
*/
|
|
111
|
-
if (runtimeError || this._specLoadError) {
|
|
112
|
-
throw runtimeError || this._specLoadError;
|
|
113
|
-
}
|
|
114
|
-
return result;
|
|
115
|
-
}
|
|
116
|
-
options(options, context) {
|
|
117
|
-
let { require = [], compilers = [] } = options;
|
|
118
|
-
if (typeof require === 'string') {
|
|
119
|
-
require = [require];
|
|
120
|
-
}
|
|
121
|
-
this.requireExternalModules([...compilers, ...require], context);
|
|
122
|
-
}
|
|
123
|
-
preRequire(context, file, mocha) {
|
|
124
|
-
const options = this._config.mochaOpts;
|
|
125
|
-
const match = MOCHA_UI_TYPE_EXTRACTOR.exec(options.ui);
|
|
126
|
-
const type = (match && constants_1.INTERFACES[match[1]] && match[1]) || DEFAULT_INTERFACE_TYPE;
|
|
127
|
-
const hookArgsFn = (context) => {
|
|
128
|
-
var _a, _b;
|
|
129
|
-
return [{ ...context.test, parent: (_b = (_a = context.test) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.title }, context];
|
|
130
|
-
};
|
|
131
|
-
constants_1.INTERFACES[type].forEach((fnName) => {
|
|
132
|
-
let testCommand = constants_1.INTERFACES[type][0];
|
|
133
|
-
const isTest = [testCommand, testCommand + '.only'].includes(fnName);
|
|
134
|
-
(0, utils_1.runTestInFiberContext)(isTest, isTest ? this._config.beforeTest : this._config.beforeHook,
|
|
135
|
-
// @ts-ignore
|
|
136
|
-
hookArgsFn, isTest ? this._config.afterTest : this._config.afterHook, hookArgsFn, fnName, this._cid);
|
|
137
|
-
});
|
|
138
|
-
this.options(options, { context, file, mocha, options });
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Hooks which are added as true Mocha hooks need to call done() to notify async
|
|
142
|
-
*/
|
|
143
|
-
wrapHook(hookName) {
|
|
144
|
-
return () => (0, utils_1.executeHooksWithArgs)(hookName, this._config[hookName], [this.prepareMessage(hookName)]).catch((e) => {
|
|
145
|
-
log.error(`Error in ${hookName} hook: ${e.stack.slice(7)}`);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
prepareMessage(hookName) {
|
|
149
|
-
var _a, _b;
|
|
150
|
-
const params = { type: hookName };
|
|
151
|
-
switch (hookName) {
|
|
152
|
-
case 'beforeSuite':
|
|
153
|
-
case 'afterSuite':
|
|
154
|
-
params.payload = (_a = this._runner) === null || _a === void 0 ? void 0 : _a.suite.suites[0];
|
|
155
|
-
break;
|
|
156
|
-
case 'beforeTest':
|
|
157
|
-
case 'afterTest':
|
|
158
|
-
params.payload = (_b = this._runner) === null || _b === void 0 ? void 0 : _b.test;
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
return this.formatMessage(params);
|
|
162
|
-
}
|
|
163
|
-
formatMessage(params) {
|
|
164
|
-
var _a, _b, _c;
|
|
165
|
-
let message = {
|
|
166
|
-
type: params.type
|
|
167
|
-
};
|
|
168
|
-
const mochaAllHooksIfPresent = (_b = (_a = params.payload) === null || _a === void 0 ? void 0 : _a.title) === null || _b === void 0 ? void 0 : _b.match(/^"(before|after)( all| each)?" hook/);
|
|
169
|
-
if (params.err) {
|
|
170
|
-
/**
|
|
171
|
-
* replace "Ensure the done() callback is being called in this test." with a more meaningful message
|
|
172
|
-
*/
|
|
173
|
-
if (params.err && params.err.message && params.err.message.includes(constants_1.MOCHA_TIMEOUT_MESSAGE)) {
|
|
174
|
-
const replacement = (0, util_1.format)(constants_1.MOCHA_TIMEOUT_MESSAGE_REPLACEMENT, params.payload.parent.title, params.payload.title);
|
|
175
|
-
params.err.message = params.err.message.replace(constants_1.MOCHA_TIMEOUT_MESSAGE, replacement);
|
|
176
|
-
params.err.stack = params.err.stack.replace(constants_1.MOCHA_TIMEOUT_MESSAGE, replacement);
|
|
177
|
-
}
|
|
178
|
-
message.error = {
|
|
179
|
-
name: params.err.name,
|
|
180
|
-
message: params.err.message,
|
|
181
|
-
stack: params.err.stack,
|
|
182
|
-
type: params.err.type || params.err.name,
|
|
183
|
-
expected: params.err.expected,
|
|
184
|
-
actual: params.err.actual
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* hook failures are emitted as "test:fail"
|
|
188
|
-
*/
|
|
189
|
-
if (mochaAllHooksIfPresent) {
|
|
190
|
-
message.type = 'hook:end';
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (params.payload) {
|
|
194
|
-
message.title = params.payload.title;
|
|
195
|
-
message.parent = params.payload.parent ? params.payload.parent.title : null;
|
|
196
|
-
let fullTitle = message.title;
|
|
197
|
-
if (params.payload.parent) {
|
|
198
|
-
let parent = params.payload.parent;
|
|
199
|
-
while (parent && parent.title) {
|
|
200
|
-
fullTitle = parent.title + '.' + fullTitle;
|
|
201
|
-
parent = parent.parent;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
message.fullTitle = fullTitle;
|
|
205
|
-
message.pending = params.payload.pending || false;
|
|
206
|
-
message.file = params.payload.file;
|
|
207
|
-
message.duration = params.payload.duration;
|
|
208
|
-
/**
|
|
209
|
-
* Add the current test title to the payload for cases where it helps to
|
|
210
|
-
* identify the test, e.g. when running inside a beforeEach hook
|
|
211
|
-
*/
|
|
212
|
-
if (params.payload.ctx && params.payload.ctx.currentTest) {
|
|
213
|
-
message.currentTest = params.payload.ctx.currentTest.title;
|
|
214
|
-
}
|
|
215
|
-
if (params.type.match(/Test/)) {
|
|
216
|
-
message.passed = (params.payload.state === 'passed');
|
|
217
|
-
}
|
|
218
|
-
if (((_c = params.payload.parent) === null || _c === void 0 ? void 0 : _c.title) && mochaAllHooksIfPresent) {
|
|
219
|
-
const hookName = mochaAllHooksIfPresent[0];
|
|
220
|
-
message.title = `${hookName} for ${params.payload.parent.title}`;
|
|
221
|
-
}
|
|
222
|
-
if (params.payload.context) {
|
|
223
|
-
message.context = params.payload.context;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return message;
|
|
227
|
-
}
|
|
228
|
-
requireExternalModules(modules, context) {
|
|
229
|
-
modules.forEach(module => {
|
|
230
|
-
if (!module) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
module = module.replace(/.*:/, '');
|
|
234
|
-
if (module.substr(0, 1) === '.') {
|
|
235
|
-
module = path_1.default.join(process.cwd(), module);
|
|
236
|
-
}
|
|
237
|
-
(0, utils_2.loadModule)(module, context);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
emit(event, payload, err) {
|
|
241
|
-
/**
|
|
242
|
-
* For some reason, Mocha fires a second 'suite:end' event for the root suite,
|
|
243
|
-
* with no matching 'suite:start', so this can be ignored.
|
|
244
|
-
*/
|
|
245
|
-
if (payload.root)
|
|
246
|
-
return;
|
|
247
|
-
let message = this.formatMessage({ type: event, payload, err });
|
|
248
|
-
message.cid = this._cid;
|
|
249
|
-
message.specs = this._specs;
|
|
250
|
-
message.uid = this.getUID(message);
|
|
251
|
-
this._reporter.emit(message.type, message);
|
|
252
|
-
}
|
|
253
|
-
getSyncEventIdStart(type) {
|
|
254
|
-
const prop = `_${type}Cnt`;
|
|
255
|
-
const suiteId = this._suiteIds[this._suiteIds.length - 1];
|
|
256
|
-
const cnt = this[prop].has(suiteId)
|
|
257
|
-
? this[prop].get(suiteId) || 0
|
|
258
|
-
: 0;
|
|
259
|
-
this[prop].set(suiteId, cnt + 1);
|
|
260
|
-
return `${type}-${suiteId}-${cnt}`;
|
|
261
|
-
}
|
|
262
|
-
getSyncEventIdEnd(type) {
|
|
263
|
-
const prop = `_${type}Cnt`;
|
|
264
|
-
const suiteId = this._suiteIds[this._suiteIds.length - 1];
|
|
265
|
-
const cnt = this[prop].get(suiteId) - 1;
|
|
266
|
-
return `${type}-${suiteId}-${cnt}`;
|
|
267
|
-
}
|
|
268
|
-
getUID(message) {
|
|
269
|
-
if (message.type === 'suite:start') {
|
|
270
|
-
const suiteCnt = this._suiteCnt.has(this._level.toString())
|
|
271
|
-
? this._suiteCnt.get(this._level.toString())
|
|
272
|
-
: 0;
|
|
273
|
-
const suiteId = `suite-${this._level}-${suiteCnt}`;
|
|
274
|
-
if (this._suiteCnt.has(this._level.toString())) {
|
|
275
|
-
this._suiteCnt.set(this._level.toString(), this._suiteCnt.get(this._level.toString()) + 1);
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
this._suiteCnt.set(this._level.toString(), 1);
|
|
279
|
-
}
|
|
280
|
-
// const suiteId = this.getSyncEventIdStart('suite')
|
|
281
|
-
this._suiteIds.push(`${this._level}${suiteCnt}`);
|
|
282
|
-
this._level++;
|
|
283
|
-
return suiteId;
|
|
284
|
-
}
|
|
285
|
-
if (message.type === 'suite:end') {
|
|
286
|
-
this._level--;
|
|
287
|
-
const suiteCnt = this._suiteCnt.get(this._level.toString()) - 1;
|
|
288
|
-
const suiteId = `suite-${this._level}-${suiteCnt}`;
|
|
289
|
-
this._suiteIds.pop();
|
|
290
|
-
return suiteId;
|
|
291
|
-
}
|
|
292
|
-
if (message.type === 'hook:start') {
|
|
293
|
-
return this.getSyncEventIdStart('hook');
|
|
294
|
-
}
|
|
295
|
-
if (message.type === 'hook:end') {
|
|
296
|
-
return this.getSyncEventIdEnd('hook');
|
|
297
|
-
}
|
|
298
|
-
if (['test:start', 'test:pending'].includes(message.type)) {
|
|
299
|
-
return this.getSyncEventIdStart('test');
|
|
300
|
-
}
|
|
301
|
-
if (['test:end', 'test:pass', 'test:fail', 'test:retry'].includes(message.type)) {
|
|
302
|
-
return this.getSyncEventIdEnd('test');
|
|
303
|
-
}
|
|
304
|
-
throw new Error(`Unknown message type : ${message.type}`);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
exports.MochaAdapter = MochaAdapter;
|
|
308
|
-
const adapterFactory = {};
|
|
309
|
-
exports.adapterFactory = adapterFactory;
|
|
310
|
-
adapterFactory.init = async function (...args) {
|
|
311
|
-
// @ts-ignore just passing through args
|
|
312
|
-
const adapter = new MochaAdapter(...args);
|
|
313
|
-
const instance = await adapter.init();
|
|
314
|
-
return instance;
|
|
315
|
-
};
|
|
316
|
-
exports.default = adapterFactory;
|
package/build/types.d.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { Options } from '@wdio/types';
|
|
2
|
-
import type Mocha from 'mocha';
|
|
3
|
-
export interface MochaOpts {
|
|
4
|
-
/**
|
|
5
|
-
* The `require` option is useful when you want to add or extend some
|
|
6
|
-
* basic functionality (WebdriverIO framework option).
|
|
7
|
-
*/
|
|
8
|
-
require?: string[];
|
|
9
|
-
/**
|
|
10
|
-
* Use the given module(s) to compile files. Compilers will be included
|
|
11
|
-
* before requires (WebdriverIO framework option).
|
|
12
|
-
*/
|
|
13
|
-
compilers?: string[];
|
|
14
|
-
/**
|
|
15
|
-
* Propagate uncaught errors?
|
|
16
|
-
*/
|
|
17
|
-
allowUncaught?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Force done callback or promise?
|
|
20
|
-
*/
|
|
21
|
-
asyncOnly?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Bail after first test failure?
|
|
24
|
-
*/
|
|
25
|
-
bail?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Check for global variable leaks?
|
|
28
|
-
*/
|
|
29
|
-
checkLeaks?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Delay root suite execution?
|
|
32
|
-
*/
|
|
33
|
-
delay?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Test filter given string.
|
|
36
|
-
*/
|
|
37
|
-
fgrep?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Tests marked only fail the suite?
|
|
40
|
-
*/
|
|
41
|
-
forbidOnly?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Pending tests fail the suite?
|
|
44
|
-
*/
|
|
45
|
-
forbidPending?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Full stacktrace upon failure?
|
|
48
|
-
*/
|
|
49
|
-
fullTrace?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Variables expected in global scope.
|
|
52
|
-
*/
|
|
53
|
-
global?: string[];
|
|
54
|
-
/**
|
|
55
|
-
* Test filter given regular expression.
|
|
56
|
-
*/
|
|
57
|
-
grep?: RegExp | string;
|
|
58
|
-
/**
|
|
59
|
-
* Invert test filter matches?
|
|
60
|
-
*/
|
|
61
|
-
invert?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Number of times to retry failed tests.
|
|
64
|
-
*/
|
|
65
|
-
retries?: number;
|
|
66
|
-
/**
|
|
67
|
-
* Timeout threshold value.
|
|
68
|
-
*/
|
|
69
|
-
timeout?: number | string;
|
|
70
|
-
/**
|
|
71
|
-
* Set test UI to one of the built-in test interfaces.
|
|
72
|
-
*/
|
|
73
|
-
ui?: 'bdd' | 'tdd' | 'qunit' | 'exports';
|
|
74
|
-
}
|
|
75
|
-
export interface MochaConfig extends Required<Options.Testrunner> {
|
|
76
|
-
mochaOpts: MochaOpts;
|
|
77
|
-
}
|
|
78
|
-
export interface MochaError {
|
|
79
|
-
name: string;
|
|
80
|
-
message: string;
|
|
81
|
-
stack: string;
|
|
82
|
-
type: string;
|
|
83
|
-
expected: any;
|
|
84
|
-
actual: any;
|
|
85
|
-
}
|
|
86
|
-
export interface FrameworkMessage {
|
|
87
|
-
type: string;
|
|
88
|
-
payload?: any;
|
|
89
|
-
err?: MochaError;
|
|
90
|
-
}
|
|
91
|
-
export interface FormattedMessage {
|
|
92
|
-
type: string;
|
|
93
|
-
cid?: string;
|
|
94
|
-
specs?: string[];
|
|
95
|
-
uid?: string;
|
|
96
|
-
title?: string;
|
|
97
|
-
parent?: string;
|
|
98
|
-
fullTitle?: string;
|
|
99
|
-
pending?: boolean;
|
|
100
|
-
passed?: boolean;
|
|
101
|
-
file?: string;
|
|
102
|
-
duration?: number;
|
|
103
|
-
currentTest?: string;
|
|
104
|
-
error?: MochaError;
|
|
105
|
-
context?: any;
|
|
106
|
-
}
|
|
107
|
-
export interface MochaContext {
|
|
108
|
-
context: Mocha.MochaGlobals;
|
|
109
|
-
file: string;
|
|
110
|
-
mocha: Mocha;
|
|
111
|
-
options: MochaOpts;
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=types.d.ts.map
|
package/build/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OA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G,CAAA;IACb,MAAM,EAAE,GAAG,CAAA;CACd;AAED,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,GAAG,CAAA;IACb,GAAG,CAAC,EAAE,UAAU,CAAA;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,OAAO,CAAC,EAAE,GAAG,CAAA;CAChB;AAED,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,KAAK,CAAC,YAAY,CAAA;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,SAAS,CAAA;CACrB"}
|
package/build/types.js
DELETED
package/build/utils.d.ts
DELETED
package/build/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,wBAAgB,UAAU,CAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,QAU9D"}
|
package/build/utils.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadModule = void 0;
|
|
4
|
-
function loadModule(name, context) {
|
|
5
|
-
try {
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
module.context = context;
|
|
8
|
-
require(name);
|
|
9
|
-
}
|
|
10
|
-
catch (err) {
|
|
11
|
-
throw new Error(`Module ${name} can't get loaded. Are you sure you have installed it?\n` +
|
|
12
|
-
'Note: if you\'ve installed WebdriverIO globally you need to install ' +
|
|
13
|
-
'these external modules globally too!');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.loadModule = loadModule;
|