@sprucelabs/test-utils 5.1.407 → 5.1.409

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.
@@ -38,7 +38,7 @@ const assert = {
38
38
  }
39
39
  },
40
40
  isNotEqualDeep(actual, expected, message) {
41
- this.doesThrow(() => this.isEqualDeep(actual, expected), undefined, message !== null && message !== void 0 ? message : `The objects you passed are deep equal! They should not be!`);
41
+ this.doesThrow(() => this.isEqualDeep(actual, expected), undefined, buildErrorMessage(`The objects you passed are deep equal! They should not be!`, message));
42
42
  },
43
43
  isAbove(actual, floor, message) {
44
44
  if (typeof actual !== 'number') {
@@ -209,7 +209,7 @@ const assert = {
209
209
  cb();
210
210
  }
211
211
  catch (err) {
212
- assert_utility_1.default.checkDoesThrowError(matcher, err, msg);
212
+ assert_utility_1.default.assertErrorIncludes(matcher, err, msg);
213
213
  return err;
214
214
  }
215
215
  this.fail(buildErrorMessage('Expected a thrown error, but never got one!', msg));
@@ -219,7 +219,7 @@ const assert = {
219
219
  await cb();
220
220
  }
221
221
  catch (err) {
222
- assert_utility_1.default.checkDoesThrowError(matcher, err, msg);
222
+ assert_utility_1.default.assertErrorIncludes(matcher, err, msg);
223
223
  return err;
224
224
  }
225
225
  this.fail(buildErrorMessage('Expected a thrown error, but never got one!', msg));
@@ -11,7 +11,7 @@ declare const assertUtil: {
11
11
  dropInPlaceholder(obj: Record<string, any>, checker: (obj: any, depth: number) => boolean, placeholder: string, depth?: number): any[] | Record<string, any>;
12
12
  doHaystacksPassCheck(haystacks: any[], needle: any, check: ISpruceAssert["doesInclude"]): boolean;
13
13
  assertTypeof(actual: any, type: string, message: string | undefined): void;
14
- checkDoesThrowError(matcher: string | RegExp | undefined, err: Error, msg?: string | undefined): void;
14
+ assertErrorIncludes(matcher: string | RegExp | undefined, err: Error, msg?: string | undefined): void;
15
15
  partialContains(object: any, subObject: any): boolean | undefined;
16
16
  valueAtPath(object: Record<string, any>, path: string): any;
17
17
  parseIncludeNeedle(needle: any): {
@@ -116,17 +116,20 @@ const assertUtil = {
116
116
  this.fail(message !== null && message !== void 0 ? message : `${JSON.stringify(actual)} is not a ${type}`);
117
117
  }
118
118
  },
119
- checkDoesThrowError(matcher, err, msg) {
119
+ assertErrorIncludes(matcher, err, msg) {
120
120
  var _a;
121
- const message = (_a = err.message) !== null && _a !== void 0 ? _a : '';
122
- if (typeof matcher === 'string' &&
123
- message.search(matcher) === -1 &&
124
- !message.includes(matcher)) {
125
- this.fail(msg !== null && msg !== void 0 ? msg : `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);
126
- }
127
- else if (matcher instanceof RegExp &&
128
- message.search(matcher) === -1) {
129
- this.fail(msg !== null && msg !== void 0 ? msg : `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);
121
+ const originalErrorMessage = (_a = err.message) !== null && _a !== void 0 ? _a : '';
122
+ const errorMessage = originalErrorMessage.toLowerCase();
123
+ const needle = typeof matcher === 'string' ? matcher.toLowerCase() : matcher;
124
+ if (typeof needle === 'string' &&
125
+ errorMessage.search(needle) === -1 &&
126
+ !errorMessage.includes(needle)) {
127
+ this.fail(msg !== null && msg !== void 0 ? msg : `Expected thrown error whose message contains: \n\n${chalk_1.default.bold(matcher)}\n\nbut got back:\n\n\`${chalk_1.default.bold(originalErrorMessage)}\`.`, '\n\nStack: ' + err.stack);
128
+ }
129
+ else if (needle instanceof RegExp &&
130
+ errorMessage.search(needle) === -1 &&
131
+ originalErrorMessage.search(needle) === -1) {
132
+ this.fail(msg !== null && msg !== void 0 ? msg : `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(originalErrorMessage)}\`.`, '\n\nStack: ' + err.stack);
130
133
  }
131
134
  },
132
135
  partialContains(object, subObject) {
@@ -33,7 +33,7 @@ const assert = {
33
33
  }
34
34
  },
35
35
  isNotEqualDeep(actual, expected, message) {
36
- this.doesThrow(() => this.isEqualDeep(actual, expected), undefined, message !== null && message !== void 0 ? message : `The objects you passed are deep equal! They should not be!`);
36
+ this.doesThrow(() => this.isEqualDeep(actual, expected), undefined, buildErrorMessage(`The objects you passed are deep equal! They should not be!`, message));
37
37
  },
38
38
  isAbove(actual, floor, message) {
39
39
  if (typeof actual !== 'number') {
@@ -204,7 +204,7 @@ const assert = {
204
204
  cb();
205
205
  }
206
206
  catch (err) {
207
- assertUtil.checkDoesThrowError(matcher, err, msg);
207
+ assertUtil.assertErrorIncludes(matcher, err, msg);
208
208
  return err;
209
209
  }
210
210
  this.fail(buildErrorMessage('Expected a thrown error, but never got one!', msg));
@@ -214,7 +214,7 @@ const assert = {
214
214
  await cb();
215
215
  }
216
216
  catch (err) {
217
- assertUtil.checkDoesThrowError(matcher, err, msg);
217
+ assertUtil.assertErrorIncludes(matcher, err, msg);
218
218
  return err;
219
219
  }
220
220
  this.fail(buildErrorMessage('Expected a thrown error, but never got one!', msg));
@@ -11,7 +11,7 @@ declare const assertUtil: {
11
11
  dropInPlaceholder(obj: Record<string, any>, checker: (obj: any, depth: number) => boolean, placeholder: string, depth?: number): any[] | Record<string, any>;
12
12
  doHaystacksPassCheck(haystacks: any[], needle: any, check: ISpruceAssert["doesInclude"]): boolean;
13
13
  assertTypeof(actual: any, type: string, message: string | undefined): void;
14
- checkDoesThrowError(matcher: string | RegExp | undefined, err: Error, msg?: string | undefined): void;
14
+ assertErrorIncludes(matcher: string | RegExp | undefined, err: Error, msg?: string | undefined): void;
15
15
  partialContains(object: any, subObject: any): boolean | undefined;
16
16
  valueAtPath(object: Record<string, any>, path: string): any;
17
17
  parseIncludeNeedle(needle: any): {
@@ -110,17 +110,20 @@ const assertUtil = {
110
110
  this.fail(message !== null && message !== void 0 ? message : `${JSON.stringify(actual)} is not a ${type}`);
111
111
  }
112
112
  },
113
- checkDoesThrowError(matcher, err, msg) {
113
+ assertErrorIncludes(matcher, err, msg) {
114
114
  var _a;
115
- const message = (_a = err.message) !== null && _a !== void 0 ? _a : '';
116
- if (typeof matcher === 'string' &&
117
- message.search(matcher) === -1 &&
118
- !message.includes(matcher)) {
119
- 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);
120
- }
121
- else if (matcher instanceof RegExp &&
122
- message.search(matcher) === -1) {
123
- 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);
115
+ const originalErrorMessage = (_a = err.message) !== null && _a !== void 0 ? _a : '';
116
+ const errorMessage = originalErrorMessage.toLowerCase();
117
+ const needle = typeof matcher === 'string' ? matcher.toLowerCase() : matcher;
118
+ if (typeof needle === 'string' &&
119
+ errorMessage.search(needle) === -1 &&
120
+ !errorMessage.includes(needle)) {
121
+ 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(originalErrorMessage)}\`.`, '\n\nStack: ' + err.stack);
122
+ }
123
+ else if (needle instanceof RegExp &&
124
+ errorMessage.search(needle) === -1 &&
125
+ originalErrorMessage.search(needle) === -1) {
126
+ 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(originalErrorMessage)}\`.`, '\n\nStack: ' + err.stack);
124
127
  }
125
128
  },
126
129
  partialContains(object, subObject) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "5.1.407",
6
+ "version": "5.1.409",
7
7
  "files": [
8
8
  "build"
9
9
  ],
@@ -60,7 +60,7 @@
60
60
  "watch.tsc": "tsc -w"
61
61
  },
62
62
  "dependencies": {
63
- "@sprucelabs/error": "^6.0.458",
63
+ "@sprucelabs/error": "^6.0.459",
64
64
  "deep-equal": "^2.2.3",
65
65
  "just-clone": "^6.2.0",
66
66
  "lodash": "^4.17.21",
@@ -68,8 +68,8 @@
68
68
  "variable-diff": "^2.0.2"
69
69
  },
70
70
  "devDependencies": {
71
- "@sprucelabs/esm-postbuild": "^6.0.441",
72
- "@sprucelabs/jest-json-reporter": "^8.0.457",
71
+ "@sprucelabs/esm-postbuild": "^6.0.443",
72
+ "@sprucelabs/jest-json-reporter": "^8.0.459",
73
73
  "@sprucelabs/jest-sheets-reporter": "^2.0.20",
74
74
  "@sprucelabs/semantic-release": "^5.0.2",
75
75
  "@sprucelabs/test": "^9.0.49",