@sprucelabs/test-utils 4.0.157 → 5.0.1
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/AbstractSpruceTest.js +1 -0
- package/build/AssertionError.js +1 -2
- package/build/StackCleaner.js +1 -1
- package/build/assert/assert.js +33 -24
- package/build/assert/assert.utility.js +20 -15
- package/build/decorators.js +5 -4
- package/build/esm/assert/assert.js +0 -1
- package/build/esm/assert/assert.utility.js +10 -4
- package/build/esm/decorators.js +1 -0
- package/build/utilities/errorAssert.js +3 -15
- package/package.json +11 -11
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
7
|
class AbstractSpruceTest {
|
|
8
|
+
static cwd;
|
|
8
9
|
static async beforeAll() {
|
|
9
10
|
this.cwd = process.cwd();
|
|
10
11
|
}
|
package/build/AssertionError.js
CHANGED
|
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const StackCleaner_1 = __importDefault(require("./StackCleaner"));
|
|
7
7
|
class AssertionError extends Error {
|
|
8
8
|
constructor(message, stack) {
|
|
9
|
-
var _a;
|
|
10
9
|
super(message);
|
|
11
10
|
this.message = StackCleaner_1.default.clean(message ? `${message}\n` : '');
|
|
12
|
-
this.stack = StackCleaner_1.default.clean(`${this.message}${(
|
|
11
|
+
this.stack = StackCleaner_1.default.clean(`${this.message}${(stack ?? this.stack ?? '').replace(message, '')}`);
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
exports.default = AssertionError;
|
package/build/StackCleaner.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class StackCleaner {
|
|
4
|
+
static matchPattern = /spruce-test\/(?!src\/__tests__)|node_modules|internal\/process\/task_queues|@babel|regenerator-runtime\/runtime/gi;
|
|
4
5
|
static clean(stack) {
|
|
5
6
|
const lines = stack.split(/\r?\n/);
|
|
6
7
|
const filtered = lines.filter((line) => line.search(this.matchPattern) === -1);
|
|
@@ -8,5 +9,4 @@ class StackCleaner {
|
|
|
8
9
|
return newStack;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
StackCleaner.matchPattern = /spruce-test\/(?!src\/__tests__)|node_modules|internal\/process\/task_queues|@babel|regenerator-runtime\/runtime/gi;
|
|
12
12
|
exports.default = StackCleaner;
|
package/build/assert/assert.js
CHANGED
|
@@ -18,47 +18,53 @@ const assert = {
|
|
|
18
18
|
isExactType,
|
|
19
19
|
isNumber(actual, message) {
|
|
20
20
|
if (typeof actual !== 'number') {
|
|
21
|
-
this.fail(message
|
|
21
|
+
this.fail(message ?? `${stringify(actual)} is not a number!`);
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
isEqual(actual, expected, message) {
|
|
25
25
|
if (actual !== expected) {
|
|
26
|
-
this.fail(message
|
|
26
|
+
this.fail(message ??
|
|
27
|
+
`${stringify(actual)} does not equal ${stringify(expected)}`);
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
30
|
isNotEqual(actual, expected, message) {
|
|
30
31
|
if (actual === expected) {
|
|
31
|
-
this.fail(message
|
|
32
|
+
this.fail(message ??
|
|
33
|
+
`${stringify(actual)} should not equal ${stringify(expected)}`);
|
|
32
34
|
}
|
|
33
35
|
},
|
|
34
36
|
isEqualDeep(actual, expected, message, shouldAppendDelta = true) {
|
|
35
37
|
if (!(0, deep_equal_1.default)(actual, expected, { strict: true })) {
|
|
36
38
|
let result = (0, variable_diff_1.default)(actual, expected);
|
|
37
|
-
this.fail(`${message
|
|
39
|
+
this.fail(`${message ??
|
|
40
|
+
`Deep equal failed.\n\nActual would need the following changes to match expected:`}${shouldAppendDelta ? `\n\n${result.text}` : ``}`);
|
|
38
41
|
}
|
|
39
42
|
},
|
|
40
43
|
isNotEqualDeep(actual, expected, message) {
|
|
41
|
-
this.doesThrow(() => this.isEqualDeep(actual, expected), undefined, message
|
|
44
|
+
this.doesThrow(() => this.isEqualDeep(actual, expected), undefined, message ??
|
|
45
|
+
`The objects you passed are deep equal! They should not be!`);
|
|
42
46
|
},
|
|
43
47
|
isAbove(actual, floor, message) {
|
|
44
48
|
if (typeof actual !== 'number') {
|
|
45
|
-
this.fail(message
|
|
49
|
+
this.fail(message ?? `${stringify(actual)} is not a number!`);
|
|
46
50
|
}
|
|
47
51
|
if (actual <= floor) {
|
|
48
|
-
this.fail(message
|
|
52
|
+
this.fail(message ??
|
|
53
|
+
`${stringify(actual)} is not above ${stringify(floor)}`);
|
|
49
54
|
}
|
|
50
55
|
},
|
|
51
56
|
isBelow(actual, ceiling, message) {
|
|
52
57
|
if (typeof actual !== 'number') {
|
|
53
|
-
this.fail(message
|
|
58
|
+
this.fail(message ?? `${stringify(actual)} is not a number!`);
|
|
54
59
|
}
|
|
55
60
|
if (actual >= ceiling) {
|
|
56
|
-
this.fail(message
|
|
61
|
+
this.fail(message ??
|
|
62
|
+
`${stringify(actual)} is not below ${stringify(ceiling)}`);
|
|
57
63
|
}
|
|
58
64
|
},
|
|
59
65
|
isUndefined(actual, message) {
|
|
60
66
|
if (typeof actual !== 'undefined') {
|
|
61
|
-
this.fail(message
|
|
67
|
+
this.fail(message ?? `${stringify(actual)} is not undefined`);
|
|
62
68
|
}
|
|
63
69
|
},
|
|
64
70
|
isTruthy(actual, message) {
|
|
@@ -66,17 +72,17 @@ const assert = {
|
|
|
66
72
|
actual === null ||
|
|
67
73
|
typeof actual === 'undefined' ||
|
|
68
74
|
actual === 0) {
|
|
69
|
-
this.fail(message
|
|
75
|
+
this.fail(message ?? `${stringify(actual)} is not truthy`);
|
|
70
76
|
}
|
|
71
77
|
},
|
|
72
78
|
isFalsy(actual, message) {
|
|
73
79
|
if (actual) {
|
|
74
|
-
this.fail(message
|
|
80
|
+
this.fail(message ?? `${stringify(actual)} is not falsy`);
|
|
75
81
|
}
|
|
76
82
|
},
|
|
77
83
|
isNull(actual, message) {
|
|
78
84
|
if (actual !== null) {
|
|
79
|
-
this.fail(message
|
|
85
|
+
this.fail(message ?? `${stringify(actual)} is not null`);
|
|
80
86
|
}
|
|
81
87
|
},
|
|
82
88
|
isString(actual, message) {
|
|
@@ -95,20 +101,22 @@ const assert = {
|
|
|
95
101
|
},
|
|
96
102
|
isObject(actual, message) {
|
|
97
103
|
if (!(0, isObjectLike_1.default)(actual)) {
|
|
98
|
-
throw this.fail(message
|
|
104
|
+
throw this.fail(message ?? `${stringify(actual)} is not an object`);
|
|
99
105
|
}
|
|
100
106
|
},
|
|
101
107
|
isArray(actual, message) {
|
|
102
108
|
if (!Array.isArray(actual)) {
|
|
103
|
-
throw this.fail(message
|
|
109
|
+
throw this.fail(message ?? `${stringify(actual)} is not an array`);
|
|
104
110
|
}
|
|
105
111
|
},
|
|
106
112
|
isLength(actual, expected, message) {
|
|
107
113
|
if (!actual) {
|
|
108
|
-
throw this.fail(message
|
|
114
|
+
throw this.fail(message ??
|
|
115
|
+
`Expected array of length ${expected}, but got ${stringify(actual)}`);
|
|
109
116
|
}
|
|
110
117
|
//@ts-ignore
|
|
111
|
-
this.isEqual(actual.length, expected, message
|
|
118
|
+
this.isEqual(actual.length, expected, message ??
|
|
119
|
+
`Expected length of ${stringify(expected)}, but got a length of ${stringify(actual.length)}`);
|
|
112
120
|
},
|
|
113
121
|
doesNotInclude(haystack, needle, message) {
|
|
114
122
|
let doesInclude = false;
|
|
@@ -116,15 +124,17 @@ const assert = {
|
|
|
116
124
|
this.doesInclude(haystack, needle);
|
|
117
125
|
doesInclude = true;
|
|
118
126
|
}
|
|
119
|
-
catch
|
|
127
|
+
catch {
|
|
120
128
|
doesInclude = false;
|
|
121
129
|
}
|
|
122
130
|
if (doesInclude) {
|
|
123
|
-
this.fail(message
|
|
131
|
+
this.fail(message ??
|
|
132
|
+
`${stringify(haystack)} should not include ${stringify(needle)}, but it does`);
|
|
124
133
|
}
|
|
125
134
|
},
|
|
126
135
|
doesInclude(haystack, needle, message) {
|
|
127
|
-
let msg = message
|
|
136
|
+
let msg = message ??
|
|
137
|
+
`Could not find ${stringify(needle)} in ${stringify(haystack)}`;
|
|
128
138
|
const isNeedleString = typeof needle === 'string';
|
|
129
139
|
const isNeedleRegex = needle instanceof RegExp;
|
|
130
140
|
if (typeof haystack === 'string' &&
|
|
@@ -149,9 +159,8 @@ const assert = {
|
|
|
149
159
|
//@ts-ignore
|
|
150
160
|
this.isEqualDeep(haystack, needle);
|
|
151
161
|
return;
|
|
152
|
-
// eslint-disable-next-line no-empty
|
|
153
162
|
}
|
|
154
|
-
catch
|
|
163
|
+
catch { }
|
|
155
164
|
}
|
|
156
165
|
if (assert_utility_1.default.foundUsing3rdPartyIncludes(haystack, needle, isHaystackObject)) {
|
|
157
166
|
return;
|
|
@@ -213,7 +222,7 @@ const assert = {
|
|
|
213
222
|
assert_utility_1.default.checkDoesThrowError(matcher, err, msg);
|
|
214
223
|
return err;
|
|
215
224
|
}
|
|
216
|
-
this.fail(msg
|
|
225
|
+
this.fail(msg ?? 'Expected a thrown error, but never got one!');
|
|
217
226
|
},
|
|
218
227
|
async doesThrowAsync(cb, matcher, msg) {
|
|
219
228
|
try {
|
|
@@ -223,7 +232,7 @@ const assert = {
|
|
|
223
232
|
assert_utility_1.default.checkDoesThrowError(matcher, err, msg);
|
|
224
233
|
return err;
|
|
225
234
|
}
|
|
226
|
-
this.fail(msg
|
|
235
|
+
this.fail(msg ?? 'Expected a thrown error, but never got one!');
|
|
227
236
|
},
|
|
228
237
|
fail: assert_utility_1.default.fail,
|
|
229
238
|
isInstanceOf(actual, Class) {
|
|
@@ -17,10 +17,9 @@ exports.CIRCULAR_PLACEHOLDER = '_____________circular_____________';
|
|
|
17
17
|
exports.NULL_PLACEHOLDER = '_____________null_____________';
|
|
18
18
|
const assertUtil = {
|
|
19
19
|
fail(message, stack) {
|
|
20
|
-
throw new AssertionError_1.default(message
|
|
20
|
+
throw new AssertionError_1.default(message ?? 'Fail!', stack);
|
|
21
21
|
},
|
|
22
22
|
stringify(object) {
|
|
23
|
-
var _a;
|
|
24
23
|
let stringified;
|
|
25
24
|
if (Array.isArray(object)) {
|
|
26
25
|
stringified = `[\n${object.map((o) => this.stringify(o).split('\n').join('\n\t'))}\n]`;
|
|
@@ -30,7 +29,7 @@ const assertUtil = {
|
|
|
30
29
|
stringified = chalk_1.default.bgBlack.white(` ${object} `);
|
|
31
30
|
}
|
|
32
31
|
else if (object instanceof Error) {
|
|
33
|
-
stringified = `${
|
|
32
|
+
stringified = `${object.stack ?? object.message}`;
|
|
34
33
|
}
|
|
35
34
|
else if (object instanceof RegExp) {
|
|
36
35
|
stringified = `${object.toString()}`;
|
|
@@ -60,7 +59,9 @@ const assertUtil = {
|
|
|
60
59
|
.replace(new RegExp(`"${exports.NULL_PLACEHOLDER}"`, 'g'), chalk_1.default.italic('NULL'));
|
|
61
60
|
},
|
|
62
61
|
dropInPlaceholders(obj) {
|
|
63
|
-
const checkedObjects = [
|
|
62
|
+
const checkedObjects = [
|
|
63
|
+
{ obj, depth: 0 },
|
|
64
|
+
];
|
|
64
65
|
let updated = this.dropInPlaceholder(obj, (obj, depth) => {
|
|
65
66
|
if ((0, isObject_1.default)(obj) &&
|
|
66
67
|
checkedObjects.some((checked) => {
|
|
@@ -80,7 +81,9 @@ const assertUtil = {
|
|
|
80
81
|
if (!(0, isObject_1.default)(obj)) {
|
|
81
82
|
return obj;
|
|
82
83
|
}
|
|
83
|
-
const updated = Array.isArray(obj)
|
|
84
|
+
const updated = Array.isArray(obj)
|
|
85
|
+
? []
|
|
86
|
+
: {};
|
|
84
87
|
Object.keys(obj).forEach((key) => {
|
|
85
88
|
//@ts-ignore
|
|
86
89
|
updated[key] =
|
|
@@ -102,24 +105,26 @@ const assertUtil = {
|
|
|
102
105
|
check(haystack, needle);
|
|
103
106
|
return true;
|
|
104
107
|
}
|
|
105
|
-
catch
|
|
108
|
+
catch {
|
|
106
109
|
return false;
|
|
107
110
|
}
|
|
108
111
|
});
|
|
109
112
|
},
|
|
110
113
|
assertTypeof(actual, type, message) {
|
|
111
114
|
if (typeof actual !== type) {
|
|
112
|
-
this.fail(message
|
|
115
|
+
this.fail(message ?? `${JSON.stringify(actual)} is not a ${type}`);
|
|
113
116
|
}
|
|
114
117
|
},
|
|
115
118
|
checkDoesThrowError(matcher, err, msg) {
|
|
116
|
-
|
|
117
|
-
const message = (_b = (_a = err.stack) !== null && _a !== void 0 ? _a : err.message) !== null && _b !== void 0 ? _b : '**MISSING ERROR MESSAGE**';
|
|
119
|
+
const message = err.stack ?? err.message ?? '**MISSING ERROR MESSAGE**';
|
|
118
120
|
if (typeof matcher === 'string' && message.search(matcher) === -1) {
|
|
119
|
-
this.fail(msg
|
|
121
|
+
this.fail(msg ??
|
|
122
|
+
`Expected thrown error whose message contains: \n\n${chalk_1.default.bold(matcher)}\n\nbut got back:\n\n\`${chalk_1.default.bold(message)}\`.`, '\n\nStack: ' + err.stack);
|
|
120
123
|
}
|
|
121
|
-
else if (matcher instanceof RegExp &&
|
|
122
|
-
|
|
124
|
+
else if (matcher instanceof RegExp &&
|
|
125
|
+
message.search(matcher) === -1) {
|
|
126
|
+
this.fail(msg ??
|
|
127
|
+
`Expected thrown error whose message matches the regex: \n\n${chalk_1.default.bold(matcher)}\n\nbut got back:\n\n\`${chalk_1.default.bold(message)}\`.`, '\n\nStack: ' + err.stack);
|
|
123
128
|
}
|
|
124
129
|
},
|
|
125
130
|
partialContains(object, subObject) {
|
|
@@ -135,7 +140,8 @@ const assertUtil = {
|
|
|
135
140
|
if (!Object.prototype.hasOwnProperty.call(object, subProp)) {
|
|
136
141
|
return false;
|
|
137
142
|
}
|
|
138
|
-
if ((!(0, isObjectLike_1.default)(object[subProp]) ||
|
|
143
|
+
if ((!(0, isObjectLike_1.default)(object[subProp]) ||
|
|
144
|
+
!(0, isObjectLike_1.default)(subObject[subProp])) &&
|
|
139
145
|
object[subProp] !== subObject[subProp]) {
|
|
140
146
|
return false;
|
|
141
147
|
}
|
|
@@ -157,9 +163,8 @@ const assertUtil = {
|
|
|
157
163
|
return { needleHasArrayNotation, path, expected };
|
|
158
164
|
},
|
|
159
165
|
splitPathBasedOnArrayNotation(path, haystack) {
|
|
160
|
-
var _a;
|
|
161
166
|
const pathParts = path.split('[].');
|
|
162
|
-
const pathToFirstArray =
|
|
167
|
+
const pathToFirstArray = pathParts.shift() ?? '';
|
|
163
168
|
const pathAfterFirstArray = pathParts.join('[].');
|
|
164
169
|
const actualBeforeArray = this.valueAtPath(haystack, pathToFirstArray);
|
|
165
170
|
return { actualBeforeArray, pathAfterFirstArray };
|
package/build/decorators.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable no-undef */
|
|
3
4
|
/** Hooks up before, after, etc. */
|
|
4
5
|
function hookupTestClass(target) {
|
|
5
6
|
if (target.__isTestingHookedUp) {
|
|
@@ -28,7 +29,7 @@ function test(description, ...args) {
|
|
|
28
29
|
hookupTestClass(target);
|
|
29
30
|
const bound = descriptor.value.bind(target);
|
|
30
31
|
// Make sure each test gets the spruce
|
|
31
|
-
it(description
|
|
32
|
+
it(description ?? propertyKey, async () => {
|
|
32
33
|
//@ts-ignore
|
|
33
34
|
global.activeTest = {
|
|
34
35
|
file: target.name,
|
|
@@ -46,7 +47,7 @@ test.only = (description, ...args) => {
|
|
|
46
47
|
hookupTestClass(target);
|
|
47
48
|
const bound = descriptor.value.bind(target);
|
|
48
49
|
// Make sure each test gets the spruce
|
|
49
|
-
it.only(description
|
|
50
|
+
it.only(description ?? propertyKey, async () => {
|
|
50
51
|
return bound(...args);
|
|
51
52
|
});
|
|
52
53
|
};
|
|
@@ -57,7 +58,7 @@ test.todo = (description, ..._args) => {
|
|
|
57
58
|
// Lets attach before/after
|
|
58
59
|
hookupTestClass(target);
|
|
59
60
|
// Make sure each test gets the spruce
|
|
60
|
-
it.todo(description
|
|
61
|
+
it.todo(description ?? propertyKey);
|
|
61
62
|
};
|
|
62
63
|
};
|
|
63
64
|
/** Skip decorator */
|
|
@@ -67,7 +68,7 @@ test.skip = (description, ...args) => {
|
|
|
67
68
|
hookupTestClass(target);
|
|
68
69
|
const bound = descriptor.value.bind(target);
|
|
69
70
|
// Make sure each test gets the spruce
|
|
70
|
-
it.skip(description
|
|
71
|
+
it.skip(description ?? propertyKey, async () => {
|
|
71
72
|
return bound(...args);
|
|
72
73
|
});
|
|
73
74
|
};
|
|
@@ -54,7 +54,9 @@ const assertUtil = {
|
|
|
54
54
|
.replace(new RegExp(`"${NULL_PLACEHOLDER}"`, 'g'), chalk.italic('NULL'));
|
|
55
55
|
},
|
|
56
56
|
dropInPlaceholders(obj) {
|
|
57
|
-
const checkedObjects = [
|
|
57
|
+
const checkedObjects = [
|
|
58
|
+
{ obj, depth: 0 },
|
|
59
|
+
];
|
|
58
60
|
let updated = this.dropInPlaceholder(obj, (obj, depth) => {
|
|
59
61
|
if (isObject(obj) &&
|
|
60
62
|
checkedObjects.some((checked) => {
|
|
@@ -74,7 +76,9 @@ const assertUtil = {
|
|
|
74
76
|
if (!isObject(obj)) {
|
|
75
77
|
return obj;
|
|
76
78
|
}
|
|
77
|
-
const updated = Array.isArray(obj)
|
|
79
|
+
const updated = Array.isArray(obj)
|
|
80
|
+
? []
|
|
81
|
+
: {};
|
|
78
82
|
Object.keys(obj).forEach((key) => {
|
|
79
83
|
//@ts-ignore
|
|
80
84
|
updated[key] =
|
|
@@ -112,7 +116,8 @@ const assertUtil = {
|
|
|
112
116
|
if (typeof matcher === 'string' && message.search(matcher) === -1) {
|
|
113
117
|
this.fail(msg !== null && msg !== void 0 ? msg : `Expected thrown error whose message contains: \n\n${chalk.bold(matcher)}\n\nbut got back:\n\n\`${chalk.bold(message)}\`.`, '\n\nStack: ' + err.stack);
|
|
114
118
|
}
|
|
115
|
-
else if (matcher instanceof RegExp &&
|
|
119
|
+
else if (matcher instanceof RegExp &&
|
|
120
|
+
message.search(matcher) === -1) {
|
|
116
121
|
this.fail(msg !== null && msg !== void 0 ? msg : `Expected thrown error whose message matches the regex: \n\n${chalk.bold(matcher)}\n\nbut got back:\n\n\`${chalk.bold(message)}\`.`, '\n\nStack: ' + err.stack);
|
|
117
122
|
}
|
|
118
123
|
},
|
|
@@ -129,7 +134,8 @@ const assertUtil = {
|
|
|
129
134
|
if (!Object.prototype.hasOwnProperty.call(object, subProp)) {
|
|
130
135
|
return false;
|
|
131
136
|
}
|
|
132
|
-
if ((!isObjectLike(object[subProp]) ||
|
|
137
|
+
if ((!isObjectLike(object[subProp]) ||
|
|
138
|
+
!isObjectLike(subObject[subProp])) &&
|
|
133
139
|
object[subProp] !== subObject[subProp]) {
|
|
134
140
|
return false;
|
|
135
141
|
}
|
package/build/esm/decorators.js
CHANGED
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
/* eslint-disable no-undef */
|
|
10
11
|
/** Hooks up before, after, etc. */
|
|
11
12
|
function hookupTestClass(target) {
|
|
12
13
|
if (target.__isTestingHookedUp) {
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
@@ -44,11 +33,10 @@ function removeProps(obj, keys) {
|
|
|
44
33
|
}
|
|
45
34
|
const errorAssert = {
|
|
46
35
|
assertError(error, expectedCode, expectedPartialOptions) {
|
|
47
|
-
var _a, _b;
|
|
48
36
|
const spruceErr = error;
|
|
49
37
|
if (!(spruceErr instanceof error_1.default)) {
|
|
50
38
|
if (spruceErr instanceof Error || spruceErr.message) {
|
|
51
|
-
assert_utility_1.default.fail(`Did not receive a SpruceError, got:\n\nMessage: ${
|
|
39
|
+
assert_utility_1.default.fail(`Did not receive a SpruceError, got:\n\nMessage: ${spruceErr.message ?? '***missing***'}`, spruceErr.stack ?? '');
|
|
52
40
|
}
|
|
53
41
|
else {
|
|
54
42
|
assert_utility_1.default.fail(`Did not receive a SpruceError, got: \n\n${assert_utility_1.default.stringify(error)}`);
|
|
@@ -60,8 +48,8 @@ const errorAssert = {
|
|
|
60
48
|
}
|
|
61
49
|
}
|
|
62
50
|
else {
|
|
63
|
-
const
|
|
64
|
-
assert_utility_1.default.fail(`Invalid error code. Expected:\n\n'${expectedCode}'\n\nbut got:\n\nCode: '${code}'\nMessage: '${friendlyMessage
|
|
51
|
+
const { code, friendlyMessage, ...options } = spruceErr.options;
|
|
52
|
+
assert_utility_1.default.fail(`Invalid error code. Expected:\n\n'${expectedCode}'\n\nbut got:\n\nCode: '${code}'\nMessage: '${friendlyMessage ?? spruceErr.message}'\nOptions:${assert_utility_1.default.stringify(options)}`, spruceErr.stack);
|
|
65
53
|
}
|
|
66
54
|
},
|
|
67
55
|
stripFriendlyMessageFromOptions(options) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "5.0.1",
|
|
7
7
|
"files": [
|
|
8
8
|
"build"
|
|
9
9
|
],
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"clean.build": "rm -rf build/",
|
|
45
45
|
"clean.dependencies": "rm -rf node_modules/ package-lock.json yarn.lock",
|
|
46
46
|
"clean.dist": "rm -rf build/__tests__ build/esm/__tests__",
|
|
47
|
-
"fix.lint": "eslint --fix --cache
|
|
48
|
-
"lint": "eslint --cache
|
|
47
|
+
"fix.lint": "eslint --fix --cache",
|
|
48
|
+
"lint": "eslint --cache",
|
|
49
49
|
"lint.tsc": "tsc -p . --noEmit",
|
|
50
50
|
"lint.watch": "chokidar 'index.ts' 'src/**/*.(js|jsx|ts|tsx)' -c 'yarn lint'",
|
|
51
51
|
"post.watch.build": "yarn build.copy-files && yarn build.resolve-paths",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"watch.tsc": "tsc -w"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@sprucelabs/error": "^
|
|
66
|
+
"@sprucelabs/error": "^6.0.1",
|
|
67
67
|
"deep-equal": "^2.2.3",
|
|
68
68
|
"just-clone": "^6.2.0",
|
|
69
69
|
"lodash": "^4.17.21",
|
|
@@ -71,25 +71,25 @@
|
|
|
71
71
|
"variable-diff": "^2.0.2"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@sprucelabs/esm-postbuild": "^
|
|
74
|
+
"@sprucelabs/esm-postbuild": "^6.0.0",
|
|
75
75
|
"@sprucelabs/jest-json-reporter": "^7.0.207",
|
|
76
76
|
"@sprucelabs/jest-sheets-reporter": "^2.0.20",
|
|
77
|
-
"@sprucelabs/semantic-release": "^
|
|
78
|
-
"@sprucelabs/test": "^
|
|
77
|
+
"@sprucelabs/semantic-release": "^5.0.1",
|
|
78
|
+
"@sprucelabs/test": "^9.0.2",
|
|
79
79
|
"@types/deep-equal": "^1.0.4",
|
|
80
80
|
"@types/jest": "^29.5.12",
|
|
81
81
|
"@types/lodash": "^4.17.0",
|
|
82
|
-
"@types/node": "^20.12.
|
|
82
|
+
"@types/node": "^20.12.7",
|
|
83
83
|
"chokidar-cli": "^3.0.0",
|
|
84
|
-
"eslint": "^
|
|
85
|
-
"eslint-config-spruce": "^
|
|
84
|
+
"eslint": "^9.0.0",
|
|
85
|
+
"eslint-config-spruce": "^11.2.3",
|
|
86
86
|
"jest": "^29.7.0",
|
|
87
87
|
"jest-circus": "^29.7.0",
|
|
88
88
|
"prettier": "^3.2.5",
|
|
89
89
|
"ts-node": "^10.9.2",
|
|
90
90
|
"tsc-watch": "^6.2.0",
|
|
91
91
|
"tsconfig-paths": "^4.2.0",
|
|
92
|
-
"typescript": "^5.4.
|
|
92
|
+
"typescript": "^5.4.5"
|
|
93
93
|
},
|
|
94
94
|
"jest": {
|
|
95
95
|
"testEnvironment": "node",
|