@wdio/mocha-framework 9.0.0-alpha.78 → 9.0.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/build/common.js CHANGED
@@ -1,121 +1,122 @@
1
- import { wrapGlobalTestMethod } from '@wdio/utils';
2
- import { INTERFACES, TEST_INTERFACES, MOCHA_TIMEOUT_MESSAGE } from './constants.js';
3
- /**
4
- * Extracts the mocha UI type following this convention:
5
- * - If the mochaOpts.ui provided doesn't contain a '-' then the full name
6
- * is taken as ui type (i.e. 'bdd','tdd','qunit')
7
- * - If it contains a '-' then it asumes we are providing a custom ui for
8
- * mocha. Then it extracts the text after the last '-' (ignoring .js if
9
- * provided) as the interface type. (i.e. strong-bdd in
10
- * https://github.com/strongloop/strong-mocha-interfaces)
11
- */
12
- const MOCHA_UI_TYPE_EXTRACTOR = /^(?:.*-)?([^-.]+)(?:.js)?$/;
13
- const DEFAULT_INTERFACE_TYPE = 'bdd';
14
- export function formatMessage(params) {
15
- const message = {
16
- type: params.type
1
+ // src/common.ts
2
+ import { wrapGlobalTestMethod } from "@wdio/utils";
3
+
4
+ // src/constants.ts
5
+ var INTERFACES = {
6
+ bdd: ["it", "specify", "before", "beforeEach", "after", "afterEach"],
7
+ tdd: ["test", "suiteSetup", "setup", "suiteTeardown", "teardown"],
8
+ qunit: ["test", "before", "beforeEach", "after", "afterEach"]
9
+ };
10
+ var TEST_INTERFACES = {
11
+ bdd: ["it", "specify"],
12
+ tdd: ["test"],
13
+ qunit: ["test"]
14
+ };
15
+ var MOCHA_TIMEOUT_MESSAGE = 'For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.';
16
+
17
+ // src/common.ts
18
+ var MOCHA_UI_TYPE_EXTRACTOR = /^(?:.*-)?([^-.]+)(?:.js)?$/;
19
+ var DEFAULT_INTERFACE_TYPE = "bdd";
20
+ function formatMessage(params) {
21
+ const message = {
22
+ type: params.type
23
+ };
24
+ const mochaAllHooksIfPresent = params.payload?.title?.match(/^"(before|after)( all| each)?" hook/);
25
+ if (params.err) {
26
+ if (params.err && params.err.message && params.err.message.includes(MOCHA_TIMEOUT_MESSAGE)) {
27
+ const replacement = `The execution in the test "${params.payload.parent.title} ${params.payload.title}" took too long. Try to reduce the run time or increase your timeout for test specs (https://webdriver.io/docs/timeouts).`;
28
+ params.err.message = params.err.message.replace(MOCHA_TIMEOUT_MESSAGE, replacement);
29
+ params.err.stack = params.err.stack.replace(MOCHA_TIMEOUT_MESSAGE, replacement);
30
+ }
31
+ message.error = {
32
+ name: params.err.name,
33
+ message: params.err.message,
34
+ stack: params.err.stack,
35
+ type: params.err.type || params.err.name,
36
+ expected: params.err.expected,
37
+ actual: params.err.actual
17
38
  };
18
- const mochaAllHooksIfPresent = params.payload?.title?.match(/^"(before|after)( all| each)?" hook/);
19
- if (params.err) {
20
- /**
21
- * replace "Ensure the done() callback is being called in this test." with a more meaningful message
22
- */
23
- if (params.err && params.err.message && params.err.message.includes(MOCHA_TIMEOUT_MESSAGE)) {
24
- const replacement = (`The execution in the test "${params.payload.parent.title} ${params.payload.title}" took too long. Try to reduce the run time or ` +
25
- 'increase your timeout for test specs (https://webdriver.io/docs/timeouts).');
26
- params.err.message = params.err.message.replace(MOCHA_TIMEOUT_MESSAGE, replacement);
27
- params.err.stack = params.err.stack.replace(MOCHA_TIMEOUT_MESSAGE, replacement);
28
- }
29
- message.error = {
30
- name: params.err.name,
31
- message: params.err.message,
32
- stack: params.err.stack,
33
- type: params.err.type || params.err.name,
34
- expected: params.err.expected,
35
- actual: params.err.actual
36
- };
37
- /**
38
- * hook failures are emitted as "test:fail"
39
- */
40
- if (mochaAllHooksIfPresent) {
41
- message.type = 'hook:end';
42
- }
39
+ if (mochaAllHooksIfPresent) {
40
+ message.type = "hook:end";
43
41
  }
44
- if (params.payload) {
45
- message.title = params.payload.title;
46
- message.parent = params.payload.parent ? params.payload.parent.title : null;
47
- let fullTitle = message.title;
48
- if (params.payload.parent) {
49
- let parent = params.payload.parent;
50
- while (parent && parent.title) {
51
- fullTitle = parent.title + '.' + fullTitle;
52
- parent = parent.parent;
53
- }
54
- }
55
- message.fullTitle = fullTitle;
56
- message.pending = params.payload.pending || false;
57
- message.file = params.payload.file;
58
- message.duration = params.payload.duration;
59
- message.body = params.payload.body;
60
- /**
61
- * Add the current test title to the payload for cases where it helps to
62
- * identify the test, e.g. when running inside a beforeEach hook
63
- */
64
- if (params.payload.ctx && params.payload.ctx.currentTest) {
65
- message.currentTest = params.payload.ctx.currentTest.title;
66
- }
67
- if (params.type.match(/Test/)) {
68
- message.passed = (params.payload.state === 'passed');
69
- }
70
- if (params.payload.parent?.title && mochaAllHooksIfPresent) {
71
- const hookName = mochaAllHooksIfPresent[0];
72
- message.title = `${hookName} for ${params.payload.parent.title}`;
73
- }
74
- if (params.payload.context) {
75
- message.context = params.payload.context;
76
- }
42
+ }
43
+ if (params.payload) {
44
+ message.title = params.payload.title;
45
+ message.parent = params.payload.parent ? params.payload.parent.title : null;
46
+ let fullTitle = message.title;
47
+ if (params.payload.parent) {
48
+ let parent = params.payload.parent;
49
+ while (parent && parent.title) {
50
+ fullTitle = parent.title + "." + fullTitle;
51
+ parent = parent.parent;
52
+ }
77
53
  }
78
- return message;
79
- }
80
- /**
81
- * require external modules
82
- * @param mods list of modules to load before the test starts
83
- * @param loader function to import the module, optional and for testing purposes only
84
- */
85
- export function requireExternalModules(mods, loader = loadModule) {
86
- return mods.map((mod) => {
87
- if (!mod) {
88
- return Promise.resolve();
89
- }
90
- mod = mod.replace(/.*:/, '');
91
- if (mod.startsWith('./') && globalThis.process) {
92
- mod = `${globalThis.process.cwd()}/${mod.slice(2)}`;
93
- }
94
- return loader(mod);
95
- });
96
- }
97
- export function setupEnv(cid, options, beforeTest, beforeHook, afterTest, afterHook) {
98
- const match = MOCHA_UI_TYPE_EXTRACTOR.exec(options.ui);
99
- const type = (match && INTERFACES[match[1]] && match[1]) || DEFAULT_INTERFACE_TYPE;
100
- const hookArgsFn = (context) => {
101
- return [{ ...context.test, parent: context.test?.parent?.title }, context];
102
- };
103
- INTERFACES[type].forEach((fnName) => {
104
- const isTest = TEST_INTERFACES[type].flatMap((testCommand) => [testCommand, testCommand + '.only']).includes(fnName);
105
- wrapGlobalTestMethod(isTest, isTest ? beforeTest : beforeHook,
106
- // @ts-ignore
107
- hookArgsFn, isTest ? afterTest : afterHook, hookArgsFn, fnName, cid);
108
- });
109
- const { compilers = [] } = options;
110
- return requireExternalModules([...compilers]);
54
+ message.fullTitle = fullTitle;
55
+ message.pending = params.payload.pending || false;
56
+ message.file = params.payload.file;
57
+ message.duration = params.payload.duration;
58
+ message.body = params.payload.body;
59
+ if (params.payload.ctx && params.payload.ctx.currentTest) {
60
+ message.currentTest = params.payload.ctx.currentTest.title;
61
+ }
62
+ if (params.type.match(/Test/)) {
63
+ message.passed = params.payload.state === "passed";
64
+ }
65
+ if (params.payload.parent?.title && mochaAllHooksIfPresent) {
66
+ const hookName = mochaAllHooksIfPresent[0];
67
+ message.title = `${hookName} for ${params.payload.parent.title}`;
68
+ }
69
+ if (params.payload.context) {
70
+ message.context = params.payload.context;
71
+ }
72
+ }
73
+ return message;
111
74
  }
112
- export async function loadModule(name) {
113
- try {
114
- return await import(name);
75
+ function requireExternalModules(mods, loader = loadModule) {
76
+ return mods.map((mod) => {
77
+ if (!mod) {
78
+ return Promise.resolve();
115
79
  }
116
- catch (err) {
117
- throw new Error(`Module ${name} can't get loaded. Are you sure you have installed it?\n` +
118
- 'Note: if you\'ve installed WebdriverIO globally you need to install ' +
119
- 'these external modules globally too!');
80
+ mod = mod.replace(/.*:/, "");
81
+ if (mod.startsWith("./") && globalThis.process) {
82
+ mod = `${globalThis.process.cwd()}/${mod.slice(2)}`;
120
83
  }
84
+ return loader(mod);
85
+ });
86
+ }
87
+ function setupEnv(cid, options, beforeTest, beforeHook, afterTest, afterHook) {
88
+ const match = MOCHA_UI_TYPE_EXTRACTOR.exec(options.ui);
89
+ const type = match && INTERFACES[match[1]] && match[1] || DEFAULT_INTERFACE_TYPE;
90
+ const hookArgsFn = (context) => {
91
+ return [{ ...context.test, parent: context.test?.parent?.title }, context];
92
+ };
93
+ INTERFACES[type].forEach((fnName) => {
94
+ const isTest = TEST_INTERFACES[type].flatMap((testCommand) => [testCommand, testCommand + ".only"]).includes(fnName);
95
+ wrapGlobalTestMethod(
96
+ isTest,
97
+ isTest ? beforeTest : beforeHook,
98
+ // @ts-ignore
99
+ hookArgsFn,
100
+ isTest ? afterTest : afterHook,
101
+ hookArgsFn,
102
+ fnName,
103
+ cid
104
+ );
105
+ });
106
+ const { compilers = [] } = options;
107
+ return requireExternalModules([...compilers]);
108
+ }
109
+ async function loadModule(name) {
110
+ try {
111
+ return await import(name);
112
+ } catch (err) {
113
+ throw new Error(`Module ${name} can't get loaded. Are you sure you have installed it?
114
+ Note: if you've installed WebdriverIO globally you need to install these external modules globally too!`);
115
+ }
121
116
  }
117
+ export {
118
+ formatMessage,
119
+ loadModule,
120
+ requireExternalModules,
121
+ setupEnv
122
+ };
package/build/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import type { Capabilities, Services, Options } from '@wdio/types';
1
+ import type { Services, Options } from '@wdio/types';
3
2
  import type { MochaOpts as MochaOptsImport, FrameworkMessage, MochaError } from './types.js';
4
3
  import type { EventEmitter } from 'node:events';
5
4
  type EventTypes = 'hook' | 'test' | 'suite';
6
5
  interface ParsedConfiguration extends Required<Options.Testrunner> {
7
6
  rootDir: string;
7
+ mochaOpts: MochaOptsImport;
8
8
  }
9
9
  /**
10
10
  * Mocha runner
@@ -25,7 +25,7 @@ declare class MochaAdapter {
25
25
  private _hookCnt;
26
26
  private _testCnt;
27
27
  private _suiteStartDate;
28
- constructor(_cid: string, _config: ParsedConfiguration, _specs: string[], _capabilities: Capabilities.RemoteCapability, _reporter: EventEmitter);
28
+ constructor(_cid: string, _config: ParsedConfiguration, _specs: string[], _capabilities: WebdriverIO.Capabilities, _reporter: EventEmitter);
29
29
  init(): Promise<this>;
30
30
  _loadFiles(mochaOpts: MochaOptsImport): Promise<void>;
31
31
  hasTests(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AASA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAIlE,OAAO,KAAK,EAAE,SAAS,IAAI,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK/C,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE3C,UAAU,mBAAoB,SAAQ,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;IAC9D,OAAO,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,cAAM,YAAY;IAcV,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;IAjBrB,OAAO,CAAC,MAAM,CAAC,CAAO;IACtB,OAAO,CAAC,OAAO,CAAC,CAAQ;IACxB,OAAO,CAAC,cAAc,CAAC,CAAO;IAE9B,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,eAAe,CAAqB;gBAGhC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,MAAM,EAAE,EAChB,aAAa,EAAE,YAAY,CAAC,gBAAgB,EAC5C,SAAS,EAAE,YAAY;IAO7B,IAAI;IAqCJ,UAAU,CAAE,SAAS,EAAE,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ACjD;CACJ"}
package/build/index.js CHANGED
@@ -1,227 +1,337 @@
1
- import url from 'node:url';
2
- import path from 'node:path';
3
- import Mocha from 'mocha';
4
- // @ts-expect-error not exposed from package yet, see https://github.com/mochajs/mocha/issues/4961
5
- import { handleRequires } from 'mocha/lib/cli/run-helpers.js';
6
- import logger from '@wdio/logger';
7
- import { executeHooksWithArgs } from '@wdio/utils';
8
- import { formatMessage, setupEnv } from './common.js';
9
- import { EVENTS, NOOP } from './constants.js';
10
- const log = logger('@wdio/mocha-framework');
11
- const FILE_PROTOCOL = 'file://';
12
- /**
13
- * Mocha runner
14
- */
15
- class MochaAdapter {
16
- _cid;
17
- _config;
18
- _specs;
19
- _capabilities;
20
- _reporter;
21
- _mocha;
22
- _runner;
23
- _specLoadError;
24
- _level = 0;
25
- _hasTests = true;
26
- _suiteIds = ['0'];
27
- _suiteCnt = new Map();
28
- _hookCnt = new Map();
29
- _testCnt = new Map();
30
- _suiteStartDate = Date.now();
31
- constructor(_cid, _config, _specs, _capabilities, _reporter) {
32
- this._cid = _cid;
33
- this._config = _config;
34
- this._specs = _specs;
35
- this._capabilities = _capabilities;
36
- this._reporter = _reporter;
37
- this._config = Object.assign({
38
- mochaOpts: {}
39
- }, _config);
40
- }
41
- async init() {
42
- const { mochaOpts } = this._config;
43
- if (Array.isArray(mochaOpts.require)) {
44
- const plugins = await handleRequires(mochaOpts.require
45
- .filter((p) => typeof p === 'string')
46
- .map((p) => path.resolve(this._config.rootDir, p)));
47
- Object.assign(mochaOpts, plugins);
48
- }
49
- const mocha = this._mocha = new Mocha(mochaOpts);
50
- // @ts-ignore outdated types
51
- await mocha.loadFilesAsync({
52
- esmDecorator: (file) => `${file}?invalidateCache=${Math.random()}`
53
- });
54
- mocha.reporter(NOOP);
55
- mocha.fullTrace();
56
- /**
57
- * as Mocha doesn't support file:// formats yet we have to
58
- * remove it before adding it to Mocha
59
- */
60
- this._specs.forEach((spec) => mocha.addFile(spec.startsWith(FILE_PROTOCOL)
61
- ? url.fileURLToPath(spec)
62
- : spec));
63
- const { beforeTest, beforeHook, afterTest, afterHook } = this._config;
64
- mocha.suite.on('pre-require', () => setupEnv(this._cid, this._config.mochaOpts, beforeTest, beforeHook, afterTest, afterHook));
65
- mocha.suite.on('require', () => mocha.unloadFiles());
66
- await this._loadFiles(mochaOpts);
67
- return this;
68
- }
69
- async _loadFiles(mochaOpts) {
70
- try {
71
- // @ts-ignore outdated types
72
- await this._mocha.loadFilesAsync({
73
- esmDecorator: (file) => `${file}?invalidateCache=${Math.random()}`
74
- });
75
- /**
76
- * grep
77
- */
78
- const mochaRunner = new Mocha.Runner(this._mocha.suite, { delay: false });
79
- if (mochaOpts.grep) {
80
- mochaRunner.grep(this._mocha.options.grep, mochaOpts.invert);
81
- }
82
- this._hasTests = mochaRunner.total > 0;
83
- }
84
- catch (err) {
85
- const error = '' +
86
- 'Unable to load spec files quite likely because they rely on `browser` object that is not fully initialized.\n' +
87
- '`browser` object has only `capabilities` and some flags like `isMobile`.\n' +
88
- 'Helper files that use other `browser` commands have to be moved to `before` hook.\n' +
89
- `Spec file(s): ${this._specs.join(',')}\n` +
90
- `Error: ${err.stack}`;
91
- this._specLoadError = new Error(error);
92
- log.warn(error);
93
- }
1
+ // src/index.ts
2
+ import url from "node:url";
3
+ import path from "node:path";
4
+ import Mocha from "mocha";
5
+ import { handleRequires } from "mocha/lib/cli/run-helpers.js";
6
+ import logger from "@wdio/logger";
7
+ import { executeHooksWithArgs } from "@wdio/utils";
8
+
9
+ // src/common.ts
10
+ import { wrapGlobalTestMethod } from "@wdio/utils";
11
+
12
+ // src/constants.ts
13
+ var INTERFACES = {
14
+ bdd: ["it", "specify", "before", "beforeEach", "after", "afterEach"],
15
+ tdd: ["test", "suiteSetup", "setup", "suiteTeardown", "teardown"],
16
+ qunit: ["test", "before", "beforeEach", "after", "afterEach"]
17
+ };
18
+ var TEST_INTERFACES = {
19
+ bdd: ["it", "specify"],
20
+ tdd: ["test"],
21
+ qunit: ["test"]
22
+ };
23
+ var EVENTS = {
24
+ "suite": "suite:start",
25
+ "suite end": "suite:end",
26
+ "test": "test:start",
27
+ "test end": "test:end",
28
+ "hook": "hook:start",
29
+ "hook end": "hook:end",
30
+ "pass": "test:pass",
31
+ "fail": "test:fail",
32
+ "retry": "test:retry",
33
+ "pending": "test:pending"
34
+ };
35
+ var NOOP = (
36
+ /* istanbul ignore next */
37
+ function() {
38
+ }
39
+ );
40
+ var MOCHA_TIMEOUT_MESSAGE = 'For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.';
41
+
42
+ // src/common.ts
43
+ var MOCHA_UI_TYPE_EXTRACTOR = /^(?:.*-)?([^-.]+)(?:.js)?$/;
44
+ var DEFAULT_INTERFACE_TYPE = "bdd";
45
+ function formatMessage(params) {
46
+ const message = {
47
+ type: params.type
48
+ };
49
+ const mochaAllHooksIfPresent = params.payload?.title?.match(/^"(before|after)( all| each)?" hook/);
50
+ if (params.err) {
51
+ if (params.err && params.err.message && params.err.message.includes(MOCHA_TIMEOUT_MESSAGE)) {
52
+ const replacement = `The execution in the test "${params.payload.parent.title} ${params.payload.title}" took too long. Try to reduce the run time or increase your timeout for test specs (https://webdriver.io/docs/timeouts).`;
53
+ params.err.message = params.err.message.replace(MOCHA_TIMEOUT_MESSAGE, replacement);
54
+ params.err.stack = params.err.stack.replace(MOCHA_TIMEOUT_MESSAGE, replacement);
94
55
  }
95
- hasTests() {
96
- return this._hasTests;
97
- }
98
- async run() {
99
- const mocha = this._mocha;
100
- let runtimeError;
101
- const result = await new Promise((resolve) => {
102
- try {
103
- this._runner = mocha.run(resolve);
104
- }
105
- catch (err) {
106
- runtimeError = err;
107
- return resolve(1);
108
- }
109
- Object.keys(EVENTS).forEach((e) => this._runner.on(e, this.emit.bind(this, EVENTS[e])));
110
- this._runner.suite.beforeAll(this.wrapHook('beforeSuite'));
111
- this._runner.suite.afterAll(this.wrapHook('afterSuite'));
112
- });
113
- await executeHooksWithArgs('after', this._config.after, [runtimeError || result, this._capabilities, this._specs]);
114
- /**
115
- * in case the spec has a runtime error throw after the wdio hook
116
- */
117
- if (runtimeError || this._specLoadError) {
118
- throw runtimeError || this._specLoadError;
119
- }
120
- return result;
121
- }
122
- /**
123
- * Hooks which are added as true Mocha hooks need to call done() to notify async
124
- */
125
- wrapHook(hookName) {
126
- return () => executeHooksWithArgs(hookName, this._config[hookName], [this.prepareMessage(hookName)]).catch((e) => {
127
- log.error(`Error in ${hookName} hook: ${e.stack.slice(7)}`);
128
- });
129
- }
130
- prepareMessage(hookName) {
131
- const params = { type: hookName };
132
- switch (hookName) {
133
- case 'beforeSuite':
134
- this._suiteStartDate = Date.now();
135
- params.payload = this._runner?.suite.suites[0];
136
- break;
137
- case 'afterSuite':
138
- params.payload = this._runner?.suite.suites[0];
139
- if (params.payload) {
140
- params.payload.duration = params.payload.duration || (Date.now() - this._suiteStartDate);
141
- }
142
- break;
143
- case 'beforeTest':
144
- case 'afterTest':
145
- params.payload = this._runner?.test;
146
- break;
147
- }
148
- return formatMessage(params);
149
- }
150
- emit(event, payload, err) {
151
- /**
152
- * For some reason, Mocha fires a second 'suite:end' event for the root suite,
153
- * with no matching 'suite:start', so this can be ignored.
154
- */
155
- if (payload.root) {
156
- return;
157
- }
158
- const message = formatMessage({ type: event, payload, err });
159
- message.cid = this._cid;
160
- message.specs = this._specs;
161
- message.uid = this.getUID(message);
162
- this._reporter.emit(message.type, message);
163
- }
164
- getSyncEventIdStart(type) {
165
- const prop = `_${type}Cnt`;
166
- const suiteId = this._suiteIds[this._suiteIds.length - 1];
167
- const cnt = this[prop].has(suiteId)
168
- ? this[prop].get(suiteId) || 0
169
- : 0;
170
- this[prop].set(suiteId, cnt + 1);
171
- return `${type}-${suiteId}-${cnt}`;
172
- }
173
- getSyncEventIdEnd(type) {
174
- const prop = `_${type}Cnt`;
175
- const suiteId = this._suiteIds[this._suiteIds.length - 1];
176
- const cnt = this[prop].get(suiteId) - 1;
177
- return `${type}-${suiteId}-${cnt}`;
178
- }
179
- getUID(message) {
180
- if (message.type === 'suite:start') {
181
- const suiteCnt = this._suiteCnt.has(this._level.toString())
182
- ? this._suiteCnt.get(this._level.toString())
183
- : 0;
184
- const suiteId = `suite-${this._level}-${suiteCnt}`;
185
- if (this._suiteCnt.has(this._level.toString())) {
186
- this._suiteCnt.set(this._level.toString(), this._suiteCnt.get(this._level.toString()) + 1);
187
- }
188
- else {
189
- this._suiteCnt.set(this._level.toString(), 1);
190
- }
191
- // const suiteId = this.getSyncEventIdStart('suite')
192
- this._suiteIds.push(`${this._level}${suiteCnt}`);
193
- this._level++;
194
- return suiteId;
195
- }
196
- if (message.type === 'suite:end') {
197
- this._level--;
198
- const suiteCnt = this._suiteCnt.get(this._level.toString()) - 1;
199
- const suiteId = `suite-${this._level}-${suiteCnt}`;
200
- this._suiteIds.pop();
201
- return suiteId;
202
- }
203
- if (message.type === 'hook:start') {
204
- return this.getSyncEventIdStart('hook');
205
- }
206
- if (message.type === 'hook:end') {
207
- return this.getSyncEventIdEnd('hook');
208
- }
209
- if (['test:start', 'test:pending'].includes(message.type)) {
210
- return this.getSyncEventIdStart('test');
211
- }
212
- if (['test:end', 'test:pass', 'test:fail', 'test:retry'].includes(message.type)) {
213
- return this.getSyncEventIdEnd('test');
214
- }
215
- throw new Error(`Unknown message type : ${message.type}`);
56
+ message.error = {
57
+ name: params.err.name,
58
+ message: params.err.message,
59
+ stack: params.err.stack,
60
+ type: params.err.type || params.err.name,
61
+ expected: params.err.expected,
62
+ actual: params.err.actual
63
+ };
64
+ if (mochaAllHooksIfPresent) {
65
+ message.type = "hook:end";
66
+ }
67
+ }
68
+ if (params.payload) {
69
+ message.title = params.payload.title;
70
+ message.parent = params.payload.parent ? params.payload.parent.title : null;
71
+ let fullTitle = message.title;
72
+ if (params.payload.parent) {
73
+ let parent = params.payload.parent;
74
+ while (parent && parent.title) {
75
+ fullTitle = parent.title + "." + fullTitle;
76
+ parent = parent.parent;
77
+ }
78
+ }
79
+ message.fullTitle = fullTitle;
80
+ message.pending = params.payload.pending || false;
81
+ message.file = params.payload.file;
82
+ message.duration = params.payload.duration;
83
+ message.body = params.payload.body;
84
+ if (params.payload.ctx && params.payload.ctx.currentTest) {
85
+ message.currentTest = params.payload.ctx.currentTest.title;
86
+ }
87
+ if (params.type.match(/Test/)) {
88
+ message.passed = params.payload.state === "passed";
89
+ }
90
+ if (params.payload.parent?.title && mochaAllHooksIfPresent) {
91
+ const hookName = mochaAllHooksIfPresent[0];
92
+ message.title = `${hookName} for ${params.payload.parent.title}`;
93
+ }
94
+ if (params.payload.context) {
95
+ message.context = params.payload.context;
216
96
  }
97
+ }
98
+ return message;
217
99
  }
218
- const adapterFactory = {};
219
- adapterFactory.init = async function (...args) {
220
- // @ts-ignore just passing through args
221
- const adapter = new MochaAdapter(...args);
222
- const instance = await adapter.init();
223
- return instance;
100
+ function requireExternalModules(mods, loader = loadModule) {
101
+ return mods.map((mod) => {
102
+ if (!mod) {
103
+ return Promise.resolve();
104
+ }
105
+ mod = mod.replace(/.*:/, "");
106
+ if (mod.startsWith("./") && globalThis.process) {
107
+ mod = `${globalThis.process.cwd()}/${mod.slice(2)}`;
108
+ }
109
+ return loader(mod);
110
+ });
111
+ }
112
+ function setupEnv(cid, options, beforeTest, beforeHook, afterTest, afterHook) {
113
+ const match = MOCHA_UI_TYPE_EXTRACTOR.exec(options.ui);
114
+ const type = match && INTERFACES[match[1]] && match[1] || DEFAULT_INTERFACE_TYPE;
115
+ const hookArgsFn = (context) => {
116
+ return [{ ...context.test, parent: context.test?.parent?.title }, context];
117
+ };
118
+ INTERFACES[type].forEach((fnName) => {
119
+ const isTest = TEST_INTERFACES[type].flatMap((testCommand) => [testCommand, testCommand + ".only"]).includes(fnName);
120
+ wrapGlobalTestMethod(
121
+ isTest,
122
+ isTest ? beforeTest : beforeHook,
123
+ // @ts-ignore
124
+ hookArgsFn,
125
+ isTest ? afterTest : afterHook,
126
+ hookArgsFn,
127
+ fnName,
128
+ cid
129
+ );
130
+ });
131
+ const { compilers = [] } = options;
132
+ return requireExternalModules([...compilers]);
133
+ }
134
+ async function loadModule(name) {
135
+ try {
136
+ return await import(name);
137
+ } catch (err) {
138
+ throw new Error(`Module ${name} can't get loaded. Are you sure you have installed it?
139
+ Note: if you've installed WebdriverIO globally you need to install these external modules globally too!`);
140
+ }
141
+ }
142
+
143
+ // src/types.ts
144
+ import { default as default2 } from "mocha";
145
+
146
+ // src/index.ts
147
+ var log = logger("@wdio/mocha-framework");
148
+ var FILE_PROTOCOL = "file://";
149
+ var MochaAdapter = class {
150
+ constructor(_cid, _config, _specs, _capabilities, _reporter) {
151
+ this._cid = _cid;
152
+ this._config = _config;
153
+ this._specs = _specs;
154
+ this._capabilities = _capabilities;
155
+ this._reporter = _reporter;
156
+ this._config = Object.assign({
157
+ mochaOpts: {}
158
+ }, _config);
159
+ }
160
+ _mocha;
161
+ _runner;
162
+ _specLoadError;
163
+ _level = 0;
164
+ _hasTests = true;
165
+ _suiteIds = ["0"];
166
+ _suiteCnt = /* @__PURE__ */ new Map();
167
+ _hookCnt = /* @__PURE__ */ new Map();
168
+ _testCnt = /* @__PURE__ */ new Map();
169
+ _suiteStartDate = Date.now();
170
+ async init() {
171
+ const { mochaOpts } = this._config;
172
+ if (Array.isArray(mochaOpts.require)) {
173
+ const plugins = await handleRequires(
174
+ mochaOpts.require.filter((p) => typeof p === "string").map((p) => path.resolve(this._config.rootDir, p))
175
+ );
176
+ Object.assign(mochaOpts, plugins);
177
+ }
178
+ const mocha = this._mocha = new Mocha(mochaOpts);
179
+ await mocha.loadFilesAsync({
180
+ esmDecorator: (file) => `${file}?invalidateCache=${Math.random()}`
181
+ });
182
+ mocha.reporter(NOOP);
183
+ mocha.fullTrace();
184
+ this._specs.forEach((spec) => mocha.addFile(
185
+ spec.startsWith(FILE_PROTOCOL) ? url.fileURLToPath(spec) : spec
186
+ ));
187
+ const { beforeTest, beforeHook, afterTest, afterHook } = this._config;
188
+ mocha.suite.on("pre-require", () => setupEnv(this._cid, this._config.mochaOpts, beforeTest, beforeHook, afterTest, afterHook));
189
+ mocha.suite.on("require", () => mocha.unloadFiles());
190
+ await this._loadFiles(mochaOpts);
191
+ return this;
192
+ }
193
+ async _loadFiles(mochaOpts) {
194
+ try {
195
+ await this._mocha.loadFilesAsync({
196
+ esmDecorator: (file) => `${file}?invalidateCache=${Math.random()}`
197
+ });
198
+ const mochaRunner = new Mocha.Runner(this._mocha.suite, { delay: false });
199
+ if (mochaOpts.grep) {
200
+ mochaRunner.grep(this._mocha.options.grep, mochaOpts.invert);
201
+ }
202
+ this._hasTests = mochaRunner.total > 0;
203
+ } catch (err) {
204
+ const error = `Unable to load spec files quite likely because they rely on \`browser\` object that is not fully initialized.
205
+ \`browser\` object has only \`capabilities\` and some flags like \`isMobile\`.
206
+ Helper files that use other \`browser\` commands have to be moved to \`before\` hook.
207
+ Spec file(s): ${this._specs.join(",")}
208
+ Error: ${err.stack}`;
209
+ this._specLoadError = new Error(error);
210
+ log.warn(error);
211
+ }
212
+ }
213
+ hasTests() {
214
+ return this._hasTests;
215
+ }
216
+ async run() {
217
+ const mocha = this._mocha;
218
+ let runtimeError;
219
+ const result = await new Promise((resolve) => {
220
+ try {
221
+ this._runner = mocha.run(resolve);
222
+ } catch (err) {
223
+ runtimeError = err;
224
+ return resolve(1);
225
+ }
226
+ Object.keys(EVENTS).forEach((e) => this._runner.on(e, this.emit.bind(this, EVENTS[e])));
227
+ this._runner.suite.beforeAll(this.wrapHook("beforeSuite"));
228
+ this._runner.suite.afterAll(this.wrapHook("afterSuite"));
229
+ });
230
+ await executeHooksWithArgs("after", this._config.after, [runtimeError || result, this._capabilities, this._specs]);
231
+ if (runtimeError || this._specLoadError) {
232
+ throw runtimeError || this._specLoadError;
233
+ }
234
+ return result;
235
+ }
236
+ /**
237
+ * Hooks which are added as true Mocha hooks need to call done() to notify async
238
+ */
239
+ wrapHook(hookName) {
240
+ return () => executeHooksWithArgs(
241
+ hookName,
242
+ this._config[hookName],
243
+ [this.prepareMessage(hookName)]
244
+ ).catch((e) => {
245
+ log.error(`Error in ${hookName} hook: ${e.stack.slice(7)}`);
246
+ });
247
+ }
248
+ prepareMessage(hookName) {
249
+ const params = { type: hookName };
250
+ switch (hookName) {
251
+ case "beforeSuite":
252
+ this._suiteStartDate = Date.now();
253
+ params.payload = this._runner?.suite.suites[0];
254
+ break;
255
+ case "afterSuite":
256
+ params.payload = this._runner?.suite.suites[0];
257
+ if (params.payload) {
258
+ params.payload.duration = params.payload.duration || Date.now() - this._suiteStartDate;
259
+ }
260
+ break;
261
+ case "beforeTest":
262
+ case "afterTest":
263
+ params.payload = this._runner?.test;
264
+ break;
265
+ }
266
+ return formatMessage(params);
267
+ }
268
+ emit(event, payload, err) {
269
+ if (payload.root) {
270
+ return;
271
+ }
272
+ const message = formatMessage({ type: event, payload, err });
273
+ message.cid = this._cid;
274
+ message.specs = this._specs;
275
+ message.uid = this.getUID(message);
276
+ this._reporter.emit(message.type, message);
277
+ }
278
+ getSyncEventIdStart(type) {
279
+ const prop = `_${type}Cnt`;
280
+ const suiteId = this._suiteIds[this._suiteIds.length - 1];
281
+ const cnt = this[prop].has(suiteId) ? this[prop].get(suiteId) || 0 : 0;
282
+ this[prop].set(suiteId, cnt + 1);
283
+ return `${type}-${suiteId}-${cnt}`;
284
+ }
285
+ getSyncEventIdEnd(type) {
286
+ const prop = `_${type}Cnt`;
287
+ const suiteId = this._suiteIds[this._suiteIds.length - 1];
288
+ const cnt = this[prop].get(suiteId) - 1;
289
+ return `${type}-${suiteId}-${cnt}`;
290
+ }
291
+ getUID(message) {
292
+ if (message.type === "suite:start") {
293
+ const suiteCnt = this._suiteCnt.has(this._level.toString()) ? this._suiteCnt.get(this._level.toString()) : 0;
294
+ const suiteId = `suite-${this._level}-${suiteCnt}`;
295
+ if (this._suiteCnt.has(this._level.toString())) {
296
+ this._suiteCnt.set(this._level.toString(), this._suiteCnt.get(this._level.toString()) + 1);
297
+ } else {
298
+ this._suiteCnt.set(this._level.toString(), 1);
299
+ }
300
+ this._suiteIds.push(`${this._level}${suiteCnt}`);
301
+ this._level++;
302
+ return suiteId;
303
+ }
304
+ if (message.type === "suite:end") {
305
+ this._level--;
306
+ const suiteCnt = this._suiteCnt.get(this._level.toString()) - 1;
307
+ const suiteId = `suite-${this._level}-${suiteCnt}`;
308
+ this._suiteIds.pop();
309
+ return suiteId;
310
+ }
311
+ if (message.type === "hook:start") {
312
+ return this.getSyncEventIdStart("hook");
313
+ }
314
+ if (message.type === "hook:end") {
315
+ return this.getSyncEventIdEnd("hook");
316
+ }
317
+ if (["test:start", "test:pending"].includes(message.type)) {
318
+ return this.getSyncEventIdStart("test");
319
+ }
320
+ if (["test:end", "test:pass", "test:fail", "test:retry"].includes(message.type)) {
321
+ return this.getSyncEventIdEnd("test");
322
+ }
323
+ throw new Error(`Unknown message type : ${message.type}`);
324
+ }
325
+ };
326
+ var adapterFactory = {};
327
+ adapterFactory.init = async function(...args) {
328
+ const adapter = new MochaAdapter(...args);
329
+ const instance = await adapter.init();
330
+ return instance;
331
+ };
332
+ var src_default = adapterFactory;
333
+ export {
334
+ MochaAdapter,
335
+ adapterFactory,
336
+ src_default as default
224
337
  };
225
- export default adapterFactory;
226
- export { MochaAdapter, adapterFactory };
227
- export * from './types.js';
package/build/types.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="mocha" />
2
1
  export { default } from 'mocha';
3
2
  export interface MochaOpts {
4
3
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,MAAM,WAAW,SAAS;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CA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": "A WebdriverIO plugin. Adapter for Mocha testing framework.",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-mocha-framework",
@@ -28,8 +28,8 @@
28
28
  "types": "./build/index.d.ts"
29
29
  },
30
30
  "./common": {
31
- "import": "./build/common.js",
32
- "types": "./build/common.d.ts"
31
+ "source": "./src/common.ts",
32
+ "import": "./build/common.js"
33
33
  },
34
34
  "./package.json": "./package.json"
35
35
  },
@@ -38,13 +38,13 @@
38
38
  "dependencies": {
39
39
  "@types/mocha": "^10.0.6",
40
40
  "@types/node": "^20.11.28",
41
- "@wdio/logger": "9.0.0-alpha.78+fee2f8a88",
42
- "@wdio/types": "9.0.0-alpha.78+fee2f8a88",
43
- "@wdio/utils": "9.0.0-alpha.78+fee2f8a88",
41
+ "@wdio/logger": "9.0.0",
42
+ "@wdio/types": "9.0.0",
43
+ "@wdio/utils": "9.0.0",
44
44
  "mocha": "^10.3.0"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "fee2f8a88d132537795eaf144abf1a7e242f99ff"
49
+ "gitHead": "957693463371a4cb329395dcdbce8fb0c930ab93"
50
50
  }
@@ -1,27 +0,0 @@
1
- export const INTERFACES = {
2
- bdd: ['it', 'specify', 'before', 'beforeEach', 'after', 'afterEach'],
3
- tdd: ['test', 'suiteSetup', 'setup', 'suiteTeardown', 'teardown'],
4
- qunit: ['test', 'before', 'beforeEach', 'after', 'afterEach']
5
- };
6
- export const TEST_INTERFACES = {
7
- bdd: ['it', 'specify'],
8
- tdd: ['test'],
9
- qunit: ['test']
10
- };
11
- /**
12
- * to map Mocha events to WDIO events
13
- */
14
- export const EVENTS = {
15
- 'suite': 'suite:start',
16
- 'suite end': 'suite:end',
17
- 'test': 'test:start',
18
- 'test end': 'test:end',
19
- 'hook': 'hook:start',
20
- 'hook end': 'hook:end',
21
- 'pass': 'test:pass',
22
- 'fail': 'test:fail',
23
- 'retry': 'test:retry',
24
- 'pending': 'test:pending'
25
- };
26
- export const NOOP = /* istanbul ignore next */ function () { };
27
- export const MOCHA_TIMEOUT_MESSAGE = 'For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.';
package/build/types.js DELETED
@@ -1 +0,0 @@
1
- export { default } from 'mocha';
File without changes