@wdio/reporter 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.
@@ -6,7 +6,7 @@ import RunnableStats from './runnable.js';
6
6
  */
7
7
  export default class RunnerStats extends RunnableStats {
8
8
  cid: string;
9
- capabilities: Capabilities.RemoteCapability;
9
+ capabilities: Capabilities.ResolvedTestrunnerCapabilities;
10
10
  sanitizedCapabilities: string;
11
11
  config: Options.Testrunner;
12
12
  specs: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/stats/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAExD,OAAO,aAAa,MAAM,eAAe,CAAA;AAGzC;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,aAAa;IAClD,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,YAAY,CAAC,gBAAgB,CAAA;IAC3C,qBAAqB,EAAE,MAAM,CAAA;IAC7B,MAAM,EAAE,OAAO,CAAC,UAAU,CAAA;IAC1B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,OAAO,CAAA;IACtB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IACpD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;gBAEH,MAAM,EAAE,OAAO,CAAC,WAAW;CAY3C"}
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/stats/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAExD,OAAO,aAAa,MAAM,eAAe,CAAA;AAGzC;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,aAAa;IAClD,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,YAAY,CAAC,8BAA8B,CAAA;IACzD,qBAAqB,EAAE,MAAM,CAAA;IAC7B,MAAM,EAAE,OAAO,CAAC,UAAU,CAAA;IAC1B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,OAAO,CAAA;IACtB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IACpD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;gBAEH,MAAM,EAAE,OAAO,CAAC,WAAW;CAY3C"}
package/build/utils.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { Capabilities } from '@wdio/types';
2
1
  import { COLORS } from './constants.js';
3
2
  /**
4
3
  * replaces whitespaces with underscore and removes dots
@@ -10,7 +9,7 @@ export declare function sanitizeString(str?: string): string;
10
9
  * formats capability object into sanitized string for e.g.filenames
11
10
  * @param {object} caps Selenium capabilities
12
11
  */
13
- export declare function sanitizeCaps(caps?: Capabilities.DesiredCapabilities): string;
12
+ export declare function sanitizeCaps(caps?: WebdriverIO.Capabilities): string;
14
13
  /**
15
14
  * Takes a event emitted by a framework and extracts
16
15
  * an array of errors representing test or hook failures.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC;;;;GAIG;AACH,wBAAgB,cAAc,CAAE,GAAG,CAAC,EAAE,MAAM,UAU3C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAE,IAAI,CAAC,EAAE,YAAY,CAAC,mBAAmB,UA0BpE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAA;CAAE,OAQlE;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAE5C;AAED,wBAAgB,KAAK,CAAE,IAAI,EAAE,MAAM,OAAO,MAAM,EAAE,OAAO,EAAE,MAAM,UAKhE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAE,IAAI,EAAE,MAAM,OAAO,MAAM,EAAE,GAAG,EAAE,MAAM,UAKjE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC;;;;GAIG;AACH,wBAAgB,cAAc,CAAE,GAAG,CAAC,EAAE,MAAM,UAU3C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAE,IAAI,CAAC,EAAE,WAAW,CAAC,YAAY,UA8B5D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAA;CAAE,OAQlE;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAE5C;AAED,wBAAgB,KAAK,CAAE,IAAI,EAAE,MAAM,OAAO,MAAM,EAAE,OAAO,EAAE,MAAM,UAKhE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAE,IAAI,EAAE,MAAM,OAAO,MAAM,EAAE,GAAG,EAAE,MAAM,UAKjE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/reporter",
3
- "version": "9.0.0-alpha.78+fee2f8a88",
3
+ "version": "9.0.0",
4
4
  "description": "A WebdriverIO utility to help reporting all events",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-reporter",
@@ -25,25 +25,21 @@
25
25
  "access": "public"
26
26
  },
27
27
  "type": "module",
28
- "main": "./cjs/index.js",
28
+ "main": "./build/index.cjs",
29
29
  "module": "./build/index.js",
30
30
  "types": "./build/index.d.ts",
31
31
  "exports": {
32
- "./package.json": "./package.json",
33
- ".": [
34
- {
35
- "types": "./build/index.d.ts",
36
- "import": "./build/index.js",
37
- "require": "./cjs/index.js"
38
- },
39
- "./cjs/index.js"
40
- ]
32
+ ".": {
33
+ "types": "./build/index.d.ts",
34
+ "import": "./build/index.js",
35
+ "require": "./build/index.cjs"
36
+ }
41
37
  },
42
38
  "typeScriptVersion": "3.8.3",
43
39
  "dependencies": {
44
40
  "@types/node": "^20.1.0",
45
- "@wdio/logger": "9.0.0-alpha.78+fee2f8a88",
46
- "@wdio/types": "9.0.0-alpha.78+fee2f8a88",
41
+ "@wdio/logger": "9.0.0",
42
+ "@wdio/types": "9.0.0",
47
43
  "diff": "^5.0.0",
48
44
  "object-inspect": "^1.12.0"
49
45
  },
@@ -54,5 +50,5 @@
54
50
  "@types/tmp": "^0.2.3",
55
51
  "tmp": "^0.2.1"
56
52
  },
57
- "gitHead": "fee2f8a88d132537795eaf144abf1a7e242f99ff"
53
+ "gitHead": "957693463371a4cb329395dcdbce8fb0c930ab93"
58
54
  }
@@ -1,23 +0,0 @@
1
- export const COLORS = {
2
- pass: 90,
3
- fail: 31,
4
- 'bright pass': 92,
5
- 'bright fail': 91,
6
- 'bright yellow': 93,
7
- pending: 36,
8
- suite: 0,
9
- 'error title': 0,
10
- 'error message': 31,
11
- 'error stack': 90,
12
- checkmark: 32,
13
- fast: 90,
14
- medium: 33,
15
- slow: 31,
16
- green: 32,
17
- light: 90,
18
- 'diff gutter': 90,
19
- 'diff added': 32,
20
- 'diff removed': 31,
21
- 'diff added inline': '30;42',
22
- 'diff removed inline': '30;41'
23
- };
@@ -1,30 +0,0 @@
1
- import RunnableStats from './runnable.js';
2
- export default class HookStats extends RunnableStats {
3
- uid;
4
- cid;
5
- title;
6
- parent;
7
- // Mocha only
8
- body;
9
- errors;
10
- error;
11
- state;
12
- currentTest;
13
- constructor(runner) {
14
- super('hook');
15
- this.uid = RunnableStats.getIdentifier(runner);
16
- this.cid = runner.cid;
17
- this.title = runner.title;
18
- this.parent = runner.parent;
19
- this.currentTest = runner.currentTest;
20
- this.body = runner.body;
21
- }
22
- complete(errors) {
23
- this.errors = errors;
24
- if (errors && errors.length) {
25
- this.error = errors[0];
26
- this.state = 'failed';
27
- }
28
- super.complete();
29
- }
30
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Main class for a runnable class (e.g. test, suite or a hook)
3
- * mainly used to capture its running duration
4
- */
5
- export default class RunnableStats {
6
- type;
7
- start = new Date();
8
- end;
9
- _duration = 0;
10
- constructor(type) {
11
- this.type = type;
12
- }
13
- complete() {
14
- this.end = new Date();
15
- this._duration = this.end.getTime() - this.start.getTime();
16
- }
17
- get duration() {
18
- if (this.end) {
19
- return this._duration;
20
- }
21
- return new Date().getTime() - this.start.getTime();
22
- }
23
- /**
24
- * ToDo: we should always rely on uid
25
- */
26
- static getIdentifier(runner) {
27
- return runner.uid || runner.title;
28
- }
29
- }
@@ -1,31 +0,0 @@
1
- import RunnableStats from './runnable.js';
2
- import { sanitizeCaps } from '../utils.js';
3
- /**
4
- * Class to capture statistics about a test run. A test run is a single instance that
5
- * runs one or more spec files
6
- */
7
- export default class RunnerStats extends RunnableStats {
8
- cid;
9
- capabilities;
10
- sanitizedCapabilities;
11
- config;
12
- specs;
13
- sessionId;
14
- isMultiremote;
15
- instanceOptions;
16
- retry;
17
- failures;
18
- retries;
19
- constructor(runner) {
20
- super('runner');
21
- this.cid = runner.cid;
22
- this.capabilities = runner.capabilities;
23
- this.sanitizedCapabilities = sanitizeCaps(runner.capabilities);
24
- this.config = runner.config;
25
- this.specs = runner.specs;
26
- this.sessionId = runner.sessionId;
27
- this.isMultiremote = runner.isMultiremote;
28
- this.instanceOptions = runner.instanceOptions;
29
- this.retry = runner.retry;
30
- }
31
- }
@@ -1,37 +0,0 @@
1
- import RunnableStats from './runnable.js';
2
- /**
3
- * Class describing statistics about a single suite.
4
- */
5
- export default class SuiteStats extends RunnableStats {
6
- uid;
7
- cid;
8
- file;
9
- title;
10
- fullTitle;
11
- tags;
12
- tests = [];
13
- hooks = [];
14
- suites = [];
15
- parent;
16
- /**
17
- * an array of hooks and tests stored in order as they happen
18
- */
19
- hooksAndTests = [];
20
- description;
21
- rule;
22
- constructor(suite) {
23
- super(suite.type || 'suite');
24
- this.uid = RunnableStats.getIdentifier(suite);
25
- this.cid = suite.cid;
26
- this.file = suite.file;
27
- this.title = suite.title;
28
- this.fullTitle = suite.fullTitle;
29
- this.tags = suite.tags;
30
- this.parent = suite.parent;
31
- /**
32
- * only Cucumber
33
- */
34
- this.description = suite.description;
35
- this.rule = suite.rule;
36
- }
37
- }
@@ -1,108 +0,0 @@
1
- import { types as nodeUtilTypes } from 'node:util';
2
- import { diffWordsWithSpace } from 'diff';
3
- import objectInspect from 'object-inspect';
4
- import RunnableStats from './runnable.js';
5
- import { pad, color, colorLines } from '../utils.js';
6
- const maxStringLength = 2048;
7
- /**
8
- * TestStats class
9
- * captures data on a test.
10
- */
11
- export default class TestStats extends RunnableStats {
12
- uid;
13
- cid;
14
- title;
15
- currentTest;
16
- fullTitle;
17
- output;
18
- argument;
19
- retries;
20
- parent;
21
- /**
22
- * initial test state is pending
23
- * the state can change to the following: passed, skipped, failed
24
- */
25
- state;
26
- pendingReason;
27
- errors;
28
- error;
29
- body;
30
- constructor(test) {
31
- super('test');
32
- this.uid = RunnableStats.getIdentifier(test);
33
- this.cid = test.cid;
34
- this.title = test.title;
35
- this.fullTitle = test.fullTitle;
36
- this.output = [];
37
- this.argument = test.argument;
38
- this.retries = test.retries;
39
- this.parent = test.parent;
40
- // Mocha only
41
- this.body = test.body;
42
- /**
43
- * initial test state is pending
44
- * the state can change to the following: passed, skipped, failed
45
- */
46
- this.state = 'pending';
47
- }
48
- pass() {
49
- this.complete();
50
- this.state = 'passed';
51
- }
52
- skip(reason) {
53
- this.pendingReason = reason;
54
- this.state = 'skipped';
55
- }
56
- fail(errors) {
57
- this.complete();
58
- this.state = 'failed';
59
- /**
60
- * Iterates through all errors to check if they're a type of 'AssertionError',
61
- * and formats it if so. Otherwise, just leaves error as is
62
- */
63
- const formattedErrors = errors?.map((err) => (
64
- /**
65
- * only format if error object has either an "expected" or "actual" property set
66
- */
67
- ((err.expected || err.actual) && !nodeUtilTypes.isProxy(err.actual)) &&
68
- /**
69
- * and if they aren't already formated, e.g. in Jasmine
70
- */
71
- (err.message && !err.message.includes('Expected: ') && !err.message.includes('Received: '))
72
- ? this._stringifyDiffObjs(err)
73
- : err));
74
- this.errors = formattedErrors;
75
- if (formattedErrors && formattedErrors.length) {
76
- this.error = formattedErrors[0];
77
- }
78
- }
79
- _stringifyDiffObjs(err) {
80
- const inspectOpts = { maxStringLength };
81
- const expected = objectInspect(err.expected, inspectOpts);
82
- const actual = objectInspect(err.actual, inspectOpts);
83
- let msg = diffWordsWithSpace(actual, expected)
84
- .map((str) => (str.added
85
- ? colorLines('diff added inline', str.value)
86
- : str.removed
87
- ? colorLines('diff removed inline', str.value)
88
- : str.value))
89
- .join('');
90
- // linenos
91
- const lines = msg.split('\n');
92
- if (lines.length > 4) {
93
- const width = String(lines.length).length;
94
- msg = lines
95
- .map(function (str, i) {
96
- return pad(String(++i), width) + ' |' + ' ' + str;
97
- })
98
- .join('\n');
99
- }
100
- // legend
101
- msg = `\n${color('diff removed inline', 'actual')} ${color('diff added inline', 'expected')}\n\n${msg}\n`;
102
- // indent
103
- msg = msg.replace(/^/gm, ' ');
104
- const newError = new Error(err.message + msg);
105
- newError.stack = err.stack;
106
- return newError;
107
- }
108
- }
@@ -1,146 +0,0 @@
1
- /**
2
- * original source: https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js
3
- *
4
- * This file was imported due to lacking support of CJS environments in the original package.
5
- */
6
- import process from 'node:process';
7
- import os from 'node:os';
8
- import tty from 'node:tty';
9
- // From: https://github.com/sindresorhus/has-flag/blob/main/index.js
10
- /// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
11
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
12
- const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
13
- const position = argv.indexOf(prefix + flag);
14
- const terminatorPosition = argv.indexOf('--');
15
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
16
- }
17
- const { env } = process;
18
- let flagForceColor;
19
- if (hasFlag('no-color')
20
- || hasFlag('no-colors')
21
- || hasFlag('color=false')
22
- || hasFlag('color=never')) {
23
- flagForceColor = 0;
24
- }
25
- else if (hasFlag('color')
26
- || hasFlag('colors')
27
- || hasFlag('color=true')
28
- || hasFlag('color=always')) {
29
- flagForceColor = 1;
30
- }
31
- function envForceColor() {
32
- if ('FORCE_COLOR' in env) {
33
- if (env.FORCE_COLOR === 'true') {
34
- return 1;
35
- }
36
- if (env.FORCE_COLOR === 'false') {
37
- return 0;
38
- }
39
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
40
- }
41
- }
42
- function translateLevel(level) {
43
- if (level === 0) {
44
- return false;
45
- }
46
- return {
47
- level,
48
- hasBasic: true,
49
- has256: level >= 2,
50
- has16m: level >= 3,
51
- };
52
- }
53
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
54
- const noFlagForceColor = envForceColor();
55
- if (noFlagForceColor !== undefined) {
56
- flagForceColor = noFlagForceColor;
57
- }
58
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
59
- if (forceColor === 0) {
60
- return 0;
61
- }
62
- if (sniffFlags) {
63
- if (hasFlag('color=16m')
64
- || hasFlag('color=full')
65
- || hasFlag('color=truecolor')) {
66
- return 3;
67
- }
68
- if (hasFlag('color=256')) {
69
- return 2;
70
- }
71
- }
72
- // Check for Azure DevOps pipelines.
73
- // Has to be above the `!streamIsTTY` check.
74
- if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
75
- return 1;
76
- }
77
- if (haveStream && !streamIsTTY && forceColor === undefined) {
78
- return 0;
79
- }
80
- const min = forceColor || 0;
81
- if (env.TERM === 'dumb') {
82
- return min;
83
- }
84
- if (process.platform === 'win32') {
85
- // Windows 10 build 10586 is the first Windows release that supports 256 colors.
86
- // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
87
- const osRelease = os.release().split('.');
88
- if (Number(osRelease[0]) >= 10
89
- && Number(osRelease[2]) >= 10_586) {
90
- return Number(osRelease[2]) >= 14_931 ? 3 : 2;
91
- }
92
- return 1;
93
- }
94
- if ('CI' in env) {
95
- if ('GITHUB_ACTIONS' in env || 'GITEA_ACTIONS' in env) {
96
- return 3;
97
- }
98
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
99
- return 1;
100
- }
101
- return min;
102
- }
103
- if ('TEAMCITY_VERSION' in env) {
104
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
105
- }
106
- if (env.COLORTERM === 'truecolor') {
107
- return 3;
108
- }
109
- if (env.TERM === 'xterm-kitty') {
110
- return 3;
111
- }
112
- if ('TERM_PROGRAM' in env) {
113
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
114
- switch (env.TERM_PROGRAM) {
115
- case 'iTerm.app': {
116
- return version >= 3 ? 3 : 2;
117
- }
118
- case 'Apple_Terminal': {
119
- return 2;
120
- }
121
- // No default
122
- }
123
- }
124
- if (env.TERM && /-256(color)?$/i.test(env.TERM)) {
125
- return 2;
126
- }
127
- if (env.TERM && /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
128
- return 1;
129
- }
130
- if ('COLORTERM' in env) {
131
- return 1;
132
- }
133
- return min;
134
- }
135
- export function createSupportsColor(stream, options = {}) {
136
- const level = _supportsColor(stream, {
137
- streamIsTTY: stream && stream.isTTY,
138
- ...options,
139
- });
140
- return translateLevel(level);
141
- }
142
- const supportsColor = {
143
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
144
- stderr: createSupportsColor({ isTTY: tty.isatty(2) }),
145
- };
146
- export default supportsColor;
package/build/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/build/utils.js DELETED
@@ -1,93 +0,0 @@
1
- import supportsColor from './supportsColor.js';
2
- import { COLORS } from './constants.js';
3
- /**
4
- * replaces whitespaces with underscore and removes dots
5
- * @param {string} str variable to sanitize
6
- * @return {String} sanitized variable
7
- */
8
- export function sanitizeString(str) {
9
- if (!str) {
10
- return '';
11
- }
12
- return String(str)
13
- .replace(/^.*\/([^/]+)\/?$/, '$1')
14
- .replace(/\./g, '_')
15
- .replace(/\s/g, '')
16
- .toLowerCase();
17
- }
18
- /**
19
- * formats capability object into sanitized string for e.g.filenames
20
- * @param {object} caps Selenium capabilities
21
- */
22
- export function sanitizeCaps(caps) {
23
- if (!caps) {
24
- return '';
25
- }
26
- let result;
27
- /**
28
- * mobile caps
29
- */
30
- result = caps.deviceName
31
- ? [
32
- sanitizeString(caps.platformName),
33
- sanitizeString(caps.deviceName || caps['appium:deviceName']),
34
- sanitizeString(caps['appium:platformVersion']),
35
- sanitizeString(caps['appium:app'])
36
- ]
37
- : [
38
- sanitizeString(caps.browserName),
39
- sanitizeString(caps.version || caps.browserVersion),
40
- sanitizeString(caps.platform || caps.platformName),
41
- sanitizeString(caps['appium:app'])
42
- ];
43
- result = result.filter(n => n !== undefined && n !== '');
44
- return result.join('.');
45
- }
46
- /**
47
- * Takes a event emitted by a framework and extracts
48
- * an array of errors representing test or hook failures.
49
- * This exists to maintain compatibility between frameworks
50
- * with have a soft assertion model (Jasmine) and those that
51
- * have a hard assertion model (Mocha)
52
- * @param {*} e An event emitted by a framework adapter
53
- */
54
- export function getErrorsFromEvent(e) {
55
- if (e.errors) {
56
- return e.errors;
57
- }
58
- if (e.error) {
59
- return [e.error];
60
- }
61
- return [];
62
- }
63
- /**
64
- * Pads the given `str` to `len`.
65
- *
66
- * @private
67
- * @param {string} str
68
- * @param {number} len
69
- * @return {string}
70
- */
71
- export function pad(str, len) {
72
- return Array(len - str.length + 1).join(' ') + str;
73
- }
74
- export function color(type, content) {
75
- if (!supportsColor.stdout) {
76
- return String(content);
77
- }
78
- return `\u001b[${COLORS[type]}m${content}\u001b[0m`;
79
- }
80
- /**
81
- * Colors lines for `str`, using the color `name`.
82
- *
83
- * @private
84
- * @param {string} name
85
- * @param {string} str
86
- * @return {string}
87
- */
88
- export function colorLines(name, str) {
89
- return str
90
- .split('\n')
91
- .map((str) => color(name, str))
92
- .join('\n');
93
- }
package/cjs/constants.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COLORS = void 0;
4
- exports.COLORS = {
5
- pass: 90,
6
- fail: 31,
7
- 'bright pass': 92,
8
- 'bright fail': 91,
9
- 'bright yellow': 93,
10
- pending: 36,
11
- suite: 0,
12
- 'error title': 0,
13
- 'error message': 31,
14
- 'error stack': 90,
15
- checkmark: 32,
16
- fast: 90,
17
- medium: 33,
18
- slow: 31,
19
- green: 32,
20
- light: 90,
21
- 'diff gutter': 90,
22
- 'diff added': 32,
23
- 'diff removed': 31,
24
- 'diff added inline': '30;42',
25
- 'diff removed inline': '30;41'
26
- };