@sprucelabs/test-utils 6.0.90 → 6.0.91

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.
@@ -19,6 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  const chalk_1 = __importDefault(require("chalk"));
21
21
  const deep_equal_1 = __importDefault(require("deep-equal"));
22
+ const lodash_1 = require("lodash");
22
23
  const escapeRegExp_1 = __importDefault(require("lodash/escapeRegExp"));
23
24
  const isObjectLike_1 = __importDefault(require("lodash/isObjectLike"));
24
25
  const ts_expect_1 = require("ts-expect");
@@ -139,7 +140,7 @@ const assert = {
139
140
  }
140
141
  },
141
142
  doesInclude(haystack, needle, message) {
142
- let msg = `Could not find ${stringify(needle)} in ${stringify(haystack)}`;
143
+ let msg = `Could not find \n\n${stringify(needle)}\n\n in \n\n${stringify(haystack)}\n\n`;
143
144
  const isNeedleString = typeof needle === 'string';
144
145
  const isNeedleRegex = needle instanceof RegExp;
145
146
  if (typeof haystack === 'string' &&
@@ -181,7 +182,15 @@ const assert = {
181
182
  msg = `The path ${stringify(path)} was not found in ${stringify(haystack)}`;
182
183
  }
183
184
  else {
184
- msg = `Expected:\n${chalk_1.default.green(stringify(needle[path]))}\nbut found:\n${chalk_1.default.red(stringify(actual))}\nat:\n${stringify(path)}\nin:\n${stringify(haystack)}`;
185
+ // msg = `Expected:\n\n${chalk.green(
186
+ // stringify(actual)
187
+ // )}\n\nbut found:\n\n${chalk.red(stringify(actual))}\n\nat key:\n\n${stringify(
188
+ // path
189
+ // )}\n\nin:\n\n${stringify(haystack)}`
190
+ msg = `Expected:\n\n${chalk_1.default.green(stringify(needle[path]))}\n\nbut found:\n\n${chalk_1.default.red(stringify(actual))}\n\nat key:\n\n${stringify(path)}`;
191
+ let clonedHaystack = (0, lodash_1.cloneDeep)(haystack);
192
+ clonedHaystack = (0, lodash_1.set)(clonedHaystack, path, `${actual} -> ${expected}`);
193
+ msg += `\n\nHere is the change:\n\n${stringify(clonedHaystack)}`;
185
194
  }
186
195
  if (typeof expected === 'string' &&
187
196
  typeof actual === 'string' &&
@@ -22,7 +22,7 @@ const assertUtil = {
22
22
  stringify(object) {
23
23
  let stringified;
24
24
  if (Array.isArray(object)) {
25
- stringified = `[\n${object.map((o) => this.stringify(o).split('\n').join('\n\t'))}\n]`;
25
+ stringified = `[\n ${object.map((o) => this.stringify(o).split('\n').join('\n '))}\n]`;
26
26
  }
27
27
  else if (typeof object === 'number') {
28
28
  // this hack allows the Spruce Test Reporter to render number errors (they got eaten by terminal-kit's style regex)
@@ -1,5 +1,6 @@
1
1
  import chalk from 'chalk';
2
2
  import deepEqual from 'deep-equal';
3
+ import { cloneDeep, set } from 'lodash';
3
4
  import escapeRegExp from 'lodash/escapeRegExp.js';
4
5
  import isObjectLike from 'lodash/isObjectLike.js';
5
6
  import { expectType } from 'ts-expect';
@@ -120,7 +121,7 @@ const assert = {
120
121
  }
121
122
  },
122
123
  doesInclude(haystack, needle, message) {
123
- let msg = `Could not find ${stringify(needle)} in ${stringify(haystack)}`;
124
+ let msg = `Could not find \n\n${stringify(needle)}\n\n in \n\n${stringify(haystack)}\n\n`;
124
125
  const isNeedleString = typeof needle === 'string';
125
126
  const isNeedleRegex = needle instanceof RegExp;
126
127
  if (typeof haystack === 'string' &&
@@ -162,7 +163,15 @@ const assert = {
162
163
  msg = `The path ${stringify(path)} was not found in ${stringify(haystack)}`;
163
164
  }
164
165
  else {
165
- msg = `Expected:\n${chalk.green(stringify(needle[path]))}\nbut found:\n${chalk.red(stringify(actual))}\nat:\n${stringify(path)}\nin:\n${stringify(haystack)}`;
166
+ // msg = `Expected:\n\n${chalk.green(
167
+ // stringify(actual)
168
+ // )}\n\nbut found:\n\n${chalk.red(stringify(actual))}\n\nat key:\n\n${stringify(
169
+ // path
170
+ // )}\n\nin:\n\n${stringify(haystack)}`
171
+ msg = `Expected:\n\n${chalk.green(stringify(needle[path]))}\n\nbut found:\n\n${chalk.red(stringify(actual))}\n\nat key:\n\n${stringify(path)}`;
172
+ let clonedHaystack = cloneDeep(haystack);
173
+ clonedHaystack = set(clonedHaystack, path, `${actual} -> ${expected}`);
174
+ msg += `\n\nHere is the change:\n\n${stringify(clonedHaystack)}`;
166
175
  }
167
176
  if (typeof expected === 'string' &&
168
177
  typeof actual === 'string' &&
@@ -17,7 +17,7 @@ const assertUtil = {
17
17
  var _a;
18
18
  let stringified;
19
19
  if (Array.isArray(object)) {
20
- stringified = `[\n${object.map((o) => this.stringify(o).split('\n').join('\n\t'))}\n]`;
20
+ stringified = `[\n ${object.map((o) => this.stringify(o).split('\n').join('\n '))}\n]`;
21
21
  }
22
22
  else if (typeof object === 'number') {
23
23
  // this hack allows the Spruce Test Reporter to render number errors (they got eaten by terminal-kit's style regex)
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "6.0.90",
6
+ "version": "6.0.91",
7
7
  "files": [
8
8
  "build"
9
9
  ],