@sprucelabs/test 8.0.51 → 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.
Files changed (29) hide show
  1. package/build/esm/index.d.ts +2 -6
  2. package/build/esm/index.js +2 -6
  3. package/build/esm/{AssertionError.d.ts → lib/AssertionError.d.ts} +0 -3
  4. package/build/esm/{AssertionError.js → lib/AssertionError.js} +0 -3
  5. package/build/{StackCleaner.d.ts → esm/lib/StackCleaner.d.ts} +0 -3
  6. package/build/esm/{StackCleaner.js → lib/StackCleaner.js} +0 -3
  7. package/build/{assert.d.ts → esm/lib/assert.d.ts} +2 -5
  8. package/build/esm/{assert.js → lib/assert.js} +4 -8
  9. package/build/esm/{utilities → lib}/assert.utility.d.ts +1 -4
  10. package/build/esm/{utilities → lib}/assert.utility.js +11 -8
  11. package/build/esm/{decorators.d.ts → lib/decorators.d.ts} +2 -3
  12. package/build/esm/{decorators.js → lib/decorators.js} +5 -4
  13. package/build/index.d.ts +2 -6
  14. package/build/index.js +3 -24
  15. package/build/{AbstractSpruceTest.js → lib/AbstractSpruceTest.js} +1 -0
  16. package/build/{AssertionError.d.ts → lib/AssertionError.d.ts} +0 -3
  17. package/build/{AssertionError.js → lib/AssertionError.js} +1 -5
  18. package/build/{esm → lib}/StackCleaner.d.ts +0 -3
  19. package/build/{StackCleaner.js → lib/StackCleaner.js} +1 -4
  20. package/build/{esm → lib}/assert.d.ts +2 -5
  21. package/build/{assert.js → lib/assert.js} +33 -28
  22. package/build/{utilities → lib}/assert.utility.d.ts +1 -4
  23. package/build/{utilities → lib}/assert.utility.js +21 -19
  24. package/build/{decorators.d.ts → lib/decorators.d.ts} +2 -3
  25. package/build/{decorators.js → lib/decorators.js} +10 -7
  26. package/package.json +7 -7
  27. /package/build/{AbstractSpruceTest.d.ts → esm/lib/AbstractSpruceTest.d.ts} +0 -0
  28. /package/build/esm/{AbstractSpruceTest.js → lib/AbstractSpruceTest.js} +0 -0
  29. /package/build/{esm → lib}/AbstractSpruceTest.d.ts +0 -0
@@ -1,6 +1,2 @@
1
- export { default } from './AbstractSpruceTest';
2
- export { default as assert } from './assert';
3
- export * from './assert';
4
- export { default as test } from './decorators';
5
- export { default as assertUtil } from './utilities/assert.utility';
6
- export { default as StackCleaner } from './StackCleaner';
1
+ export { default } from './lib/AbstractSpruceTest';
2
+ export { default as StackCleaner } from './lib/StackCleaner';
@@ -1,6 +1,2 @@
1
- export { default } from './AbstractSpruceTest.js';
2
- export { default as assert } from './assert.js';
3
- export * from './assert.js';
4
- export { default as test } from './decorators.js';
5
- export { default as assertUtil } from './utilities/assert.utility.js';
6
- export { default as StackCleaner } from './StackCleaner.js';
1
+ export { default } from './lib/AbstractSpruceTest.js';
2
+ export { default as StackCleaner } from './lib/StackCleaner.js';
@@ -1,6 +1,3 @@
1
- /**
2
- * @deprecated delete and re-import from @sprucelabs/test-utils
3
- */
4
1
  export default class AssertionError extends Error {
5
2
  constructor(message: string, stack?: string);
6
3
  }
@@ -1,7 +1,4 @@
1
1
  import StackCleaner from './StackCleaner.js';
2
- /**
3
- * @deprecated delete and re-import from @sprucelabs/test-utils
4
- */
5
2
  export default class AssertionError extends Error {
6
3
  constructor(message, stack) {
7
4
  var _a;
@@ -1,6 +1,3 @@
1
- /**
2
- * @deprecated delete and re-import from @sprucelabs/test-utils
3
- */
4
1
  export default class StackCleaner {
5
2
  private static matchPattern;
6
3
  static clean(stack: string): string;
@@ -1,6 +1,3 @@
1
- /**
2
- * @deprecated delete and re-import from @sprucelabs/test-utils
3
- */
4
1
  class StackCleaner {
5
2
  static clean(stack) {
6
3
  const lines = stack.split(/\r?\n/);
@@ -40,8 +40,5 @@ export interface ISpruceAssert {
40
40
  doesThrowAsync(cb: () => any | Promise<any>, matcher?: string | RegExp | undefined, msg?: string | undefined): Promise<Error>;
41
41
  fail(message?: string): void;
42
42
  }
43
- /**
44
- * @deprecated delete and re-import from @sprucelabs/test-utils
45
- */
46
- declare const spruceAssert: ISpruceAssert;
47
- export default spruceAssert;
43
+ declare const assert: ISpruceAssert;
44
+ export default assert;
@@ -13,13 +13,10 @@ import escapeRegExp from 'lodash/escapeRegExp.js';
13
13
  import isObjectLike from 'lodash/isObjectLike.js';
14
14
  import { expectType } from 'ts-expect';
15
15
  import diff from 'variable-diff';
16
- import assertUtil from './utilities/assert.utility.js';
16
+ import assertUtil from './assert.utility.js';
17
17
  const stringify = assertUtil.stringify.bind(assertUtil);
18
18
  function isExactType(_) { }
19
- /**
20
- * @deprecated delete and re-import from @sprucelabs/test-utils
21
- */
22
- const spruceAssert = {
19
+ const assert = {
23
20
  areSameType() { },
24
21
  isType: expectType,
25
22
  isExactType,
@@ -40,7 +37,7 @@ const spruceAssert = {
40
37
  },
41
38
  isEqualDeep(actual, expected, message, shouldAppendDelta = true) {
42
39
  if (!deepEqual(actual, expected, { strict: true })) {
43
- let result = diff(actual, expected);
40
+ const result = diff(actual, expected);
44
41
  this.fail(`${message !== null && message !== void 0 ? message : `Deep equal failed.\n\nActual would need the following changes to match expected:`}${shouldAppendDelta ? `\n\n${result.text}` : ``}`);
45
42
  }
46
43
  },
@@ -153,7 +150,6 @@ const spruceAssert = {
153
150
  //@ts-ignore
154
151
  this.isEqualDeep(haystack, needle);
155
152
  return;
156
- // eslint-disable-next-line no-empty
157
153
  }
158
154
  catch (_a) { }
159
155
  }
@@ -233,4 +229,4 @@ const spruceAssert = {
233
229
  },
234
230
  fail: assertUtil.fail,
235
231
  };
236
- export default spruceAssert;
232
+ export default assert;
@@ -1,11 +1,8 @@
1
- import { ISpruceAssert } from '../assert';
1
+ import { ISpruceAssert } from './assert';
2
2
  export declare const UNDEFINED_PLACEHOLDER = "_____________undefined_____________";
3
3
  export declare const FUNCTION_PLACEHOLDER = "_____________function_____________";
4
4
  export declare const CIRCULAR_PLACEHOLDER = "_____________circular_____________";
5
5
  export declare const NULL_PLACEHOLDER = "_____________null_____________";
6
- /**
7
- * @deprecated delete and re-import from @sprucelabs/test-utils
8
- */
9
6
  declare const assertUtil: {
10
7
  fail(message?: string, stack?: string): never;
11
8
  stringify(object: any): string;
@@ -3,14 +3,11 @@ import get from 'lodash/get.js';
3
3
  import includes from 'lodash/includes.js';
4
4
  import isObject from 'lodash/isObject.js';
5
5
  import isObjectLike from 'lodash/isObjectLike.js';
6
- import AssertionError from '../AssertionError.js';
6
+ import AssertionError from './AssertionError.js';
7
7
  export const UNDEFINED_PLACEHOLDER = '_____________undefined_____________';
8
8
  export const FUNCTION_PLACEHOLDER = '_____________function_____________';
9
9
  export const CIRCULAR_PLACEHOLDER = '_____________circular_____________';
10
10
  export const NULL_PLACEHOLDER = '_____________null_____________';
11
- /**
12
- * @deprecated delete and re-import from @sprucelabs/test-utils
13
- */
14
11
  const assertUtil = {
15
12
  fail(message, stack) {
16
13
  throw new AssertionError(message !== null && message !== void 0 ? message : 'Fail!', stack);
@@ -56,7 +53,9 @@ const assertUtil = {
56
53
  .replace(new RegExp(`"${NULL_PLACEHOLDER}"`, 'g'), chalk.italic('NULL'));
57
54
  },
58
55
  dropInPlaceholders(obj) {
59
- const checkedObjects = [{ obj, depth: 0 }];
56
+ const checkedObjects = [
57
+ { obj, depth: 0 },
58
+ ];
60
59
  let updated = this.dropInPlaceholder(obj, (obj, depth) => {
61
60
  if (isObject(obj) &&
62
61
  checkedObjects.some((checked) => {
@@ -76,7 +75,9 @@ const assertUtil = {
76
75
  if (!isObject(obj)) {
77
76
  return obj;
78
77
  }
79
- const updated = Array.isArray(obj) ? [] : {};
78
+ const updated = Array.isArray(obj)
79
+ ? []
80
+ : {};
80
81
  Object.keys(obj).forEach((key) => {
81
82
  //@ts-ignore
82
83
  updated[key] =
@@ -114,7 +115,8 @@ const assertUtil = {
114
115
  if (typeof matcher === 'string' && message.search(matcher) === -1) {
115
116
  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);
116
117
  }
117
- else if (matcher instanceof RegExp && message.search(matcher) === -1) {
118
+ else if (matcher instanceof RegExp &&
119
+ message.search(matcher) === -1) {
118
120
  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);
119
121
  }
120
122
  },
@@ -131,7 +133,8 @@ const assertUtil = {
131
133
  if (!Object.prototype.hasOwnProperty.call(object, subProp)) {
132
134
  return false;
133
135
  }
134
- if ((!isObjectLike(object[subProp]) || !isObjectLike(subObject[subProp])) &&
136
+ if ((!isObjectLike(object[subProp]) ||
137
+ !isObjectLike(subObject[subProp])) &&
135
138
  object[subProp] !== subObject[subProp]) {
136
139
  return false;
137
140
  }
@@ -1,6 +1,5 @@
1
- /**
2
- * @deprecated delete and re-import from @sprucelabs/test-utils
3
- */
1
+ /** Hooks up before, after, etc. */
2
+ export declare function hookupTestClass(target: any): void;
4
3
  declare function test(description?: string, ...args: any[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
5
4
  declare namespace test {
6
5
  var only: (description?: string | undefined, ...args: any[]) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  /** Hooks up before, after, etc. */
11
- function hookupTestClass(target) {
11
+ export function hookupTestClass(target) {
12
12
  if (target.__isTestingHookedUp) {
13
13
  return;
14
14
  }
@@ -28,15 +28,13 @@ function hookupTestClass(target) {
28
28
  }
29
29
  });
30
30
  }
31
- /**
32
- * @deprecated delete and re-import from @sprucelabs/test-utils
33
- */
34
31
  export default function test(description, ...args) {
35
32
  return function (target, propertyKey, descriptor) {
36
33
  // Lets attach before/after
37
34
  hookupTestClass(target);
38
35
  const bound = descriptor.value.bind(target);
39
36
  // Make sure each test gets the spruce
37
+ // eslint-disable-next-line no-undef
40
38
  it(description !== null && description !== void 0 ? description : propertyKey, () => __awaiter(this, void 0, void 0, function* () {
41
39
  //@ts-ignore
42
40
  global.activeTest = {
@@ -56,6 +54,7 @@ test.only = (description, ...args) => {
56
54
  hookupTestClass(target);
57
55
  const bound = descriptor.value.bind(target);
58
56
  // Make sure each test gets the spruce
57
+ // eslint-disable-next-line no-undef
59
58
  it.only(description !== null && description !== void 0 ? description : propertyKey, () => __awaiter(this, void 0, void 0, function* () {
60
59
  return bound(...args);
61
60
  }));
@@ -69,6 +68,7 @@ test.todo = (description, ..._args) => {
69
68
  // Lets attach before/after
70
69
  hookupTestClass(target);
71
70
  // Make sure each test gets the spruce
71
+ // eslint-disable-next-line no-undef
72
72
  it.todo(description !== null && description !== void 0 ? description : propertyKey);
73
73
  };
74
74
  };
@@ -81,6 +81,7 @@ test.skip = (description, ...args) => {
81
81
  hookupTestClass(target);
82
82
  const bound = descriptor.value.bind(target);
83
83
  // Make sure each test gets the spruce
84
+ // eslint-disable-next-line no-undef
84
85
  it.skip(description !== null && description !== void 0 ? description : propertyKey, () => __awaiter(this, void 0, void 0, function* () {
85
86
  return bound(...args);
86
87
  }));
package/build/index.d.ts CHANGED
@@ -1,6 +1,2 @@
1
- export { default } from './AbstractSpruceTest';
2
- export { default as assert } from './assert';
3
- export * from './assert';
4
- export { default as test } from './decorators';
5
- export { default as assertUtil } from './utilities/assert.utility';
6
- export { default as StackCleaner } from './StackCleaner';
1
+ export { default } from './lib/AbstractSpruceTest';
2
+ export { default as StackCleaner } from './lib/StackCleaner';
package/build/index.js CHANGED
@@ -1,31 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
17
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
4
  };
19
5
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.StackCleaner = exports.assertUtil = exports.test = exports.assert = exports.default = void 0;
21
- var AbstractSpruceTest_1 = require("./AbstractSpruceTest");
6
+ exports.StackCleaner = exports.default = void 0;
7
+ var AbstractSpruceTest_1 = require("./lib/AbstractSpruceTest");
22
8
  Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(AbstractSpruceTest_1).default; } });
23
- var assert_1 = require("./assert");
24
- Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return __importDefault(assert_1).default; } });
25
- __exportStar(require("./assert"), exports);
26
- var decorators_1 = require("./decorators");
27
- Object.defineProperty(exports, "test", { enumerable: true, get: function () { return __importDefault(decorators_1).default; } });
28
- var assert_utility_1 = require("./utilities/assert.utility");
29
- Object.defineProperty(exports, "assertUtil", { enumerable: true, get: function () { return __importDefault(assert_utility_1).default; } });
30
- var StackCleaner_1 = require("./StackCleaner");
9
+ var StackCleaner_1 = require("./lib/StackCleaner");
31
10
  Object.defineProperty(exports, "StackCleaner", { enumerable: true, get: function () { return __importDefault(StackCleaner_1).default; } });
@@ -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
  }
@@ -1,6 +1,3 @@
1
- /**
2
- * @deprecated delete and re-import from @sprucelabs/test-utils
3
- */
4
1
  export default class AssertionError extends Error {
5
2
  constructor(message: string, stack?: string);
6
3
  }
@@ -4,15 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const StackCleaner_1 = __importDefault(require("./StackCleaner"));
7
- /**
8
- * @deprecated delete and re-import from @sprucelabs/test-utils
9
- */
10
7
  class AssertionError extends Error {
11
8
  constructor(message, stack) {
12
- var _a;
13
9
  super(message);
14
10
  this.message = StackCleaner_1.default.clean(message ? `${message}\n` : '');
15
- this.stack = StackCleaner_1.default.clean(`${this.message}${((_a = stack !== null && stack !== void 0 ? stack : this.stack) !== null && _a !== void 0 ? _a : '').replace(message, '')}`);
11
+ this.stack = StackCleaner_1.default.clean(`${this.message}${(stack ?? this.stack ?? '').replace(message, '')}`);
16
12
  }
17
13
  }
18
14
  exports.default = AssertionError;
@@ -1,6 +1,3 @@
1
- /**
2
- * @deprecated delete and re-import from @sprucelabs/test-utils
3
- */
4
1
  export default class StackCleaner {
5
2
  private static matchPattern;
6
3
  static clean(stack: string): string;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * @deprecated delete and re-import from @sprucelabs/test-utils
5
- */
6
3
  class StackCleaner {
4
+ static matchPattern = /spruce-test\/(?!src\/__tests__)|node_modules|internal\/process\/task_queues|@babel|regenerator-runtime\/runtime/gi;
7
5
  static clean(stack) {
8
6
  const lines = stack.split(/\r?\n/);
9
7
  const filtered = lines.filter((line) => line.search(this.matchPattern) === -1);
@@ -11,5 +9,4 @@ class StackCleaner {
11
9
  return newStack;
12
10
  }
13
11
  }
14
- StackCleaner.matchPattern = /spruce-test\/(?!src\/__tests__)|node_modules|internal\/process\/task_queues|@babel|regenerator-runtime\/runtime/gi;
15
12
  exports.default = StackCleaner;
@@ -40,8 +40,5 @@ export interface ISpruceAssert {
40
40
  doesThrowAsync(cb: () => any | Promise<any>, matcher?: string | RegExp | undefined, msg?: string | undefined): Promise<Error>;
41
41
  fail(message?: string): void;
42
42
  }
43
- /**
44
- * @deprecated delete and re-import from @sprucelabs/test-utils
45
- */
46
- declare const spruceAssert: ISpruceAssert;
47
- export default spruceAssert;
43
+ declare const assert: ISpruceAssert;
44
+ export default assert;
@@ -9,56 +9,58 @@ const escapeRegExp_1 = __importDefault(require("lodash/escapeRegExp"));
9
9
  const isObjectLike_1 = __importDefault(require("lodash/isObjectLike"));
10
10
  const ts_expect_1 = require("ts-expect");
11
11
  const variable_diff_1 = __importDefault(require("variable-diff"));
12
- const assert_utility_1 = __importDefault(require("./utilities/assert.utility"));
12
+ const assert_utility_1 = __importDefault(require("./assert.utility"));
13
13
  const stringify = assert_utility_1.default.stringify.bind(assert_utility_1.default);
14
14
  function isExactType(_) { }
15
- /**
16
- * @deprecated delete and re-import from @sprucelabs/test-utils
17
- */
18
- const spruceAssert = {
15
+ const assert = {
19
16
  areSameType() { },
20
17
  isType: ts_expect_1.expectType,
21
18
  isExactType,
22
19
  isNumber(actual, message) {
23
20
  if (typeof actual !== 'number') {
24
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not a number!`);
21
+ this.fail(message ?? `${stringify(actual)} is not a number!`);
25
22
  }
26
23
  },
27
24
  isEqual(actual, expected, message) {
28
25
  if (actual !== expected) {
29
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} does not equal ${stringify(expected)}`);
26
+ this.fail(message ??
27
+ `${stringify(actual)} does not equal ${stringify(expected)}`);
30
28
  }
31
29
  },
32
30
  isNotEqual(actual, expected, message) {
33
31
  if (actual === expected) {
34
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} should not equal ${stringify(expected)}`);
32
+ this.fail(message ??
33
+ `${stringify(actual)} should not equal ${stringify(expected)}`);
35
34
  }
36
35
  },
37
36
  isEqualDeep(actual, expected, message, shouldAppendDelta = true) {
38
37
  if (!(0, deep_equal_1.default)(actual, expected, { strict: true })) {
39
- let result = (0, variable_diff_1.default)(actual, expected);
40
- this.fail(`${message !== null && message !== void 0 ? message : `Deep equal failed.\n\nActual would need the following changes to match expected:`}${shouldAppendDelta ? `\n\n${result.text}` : ``}`);
38
+ const result = (0, variable_diff_1.default)(actual, expected);
39
+ this.fail(`${message ??
40
+ `Deep equal failed.\n\nActual would need the following changes to match expected:`}${shouldAppendDelta ? `\n\n${result.text}` : ``}`);
41
41
  }
42
42
  },
43
43
  isAbove(actual, floor, message) {
44
44
  if (typeof actual !== 'number') {
45
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not a number!`);
45
+ this.fail(message ?? `${stringify(actual)} is not a number!`);
46
46
  }
47
47
  if (actual <= floor) {
48
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not above ${stringify(floor)}`);
48
+ this.fail(message ??
49
+ `${stringify(actual)} is not above ${stringify(floor)}`);
49
50
  }
50
51
  },
51
52
  isBelow(actual, ceiling, message) {
52
53
  if (typeof actual !== 'number') {
53
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not a number!`);
54
+ this.fail(message ?? `${stringify(actual)} is not a number!`);
54
55
  }
55
56
  if (actual >= ceiling) {
56
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not below ${stringify(ceiling)}`);
57
+ this.fail(message ??
58
+ `${stringify(actual)} is not below ${stringify(ceiling)}`);
57
59
  }
58
60
  },
59
61
  isUndefined(actual, message) {
60
62
  if (typeof actual !== 'undefined') {
61
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not undefined`);
63
+ this.fail(message ?? `${stringify(actual)} is not undefined`);
62
64
  }
63
65
  },
64
66
  isTruthy(actual, message) {
@@ -66,17 +68,17 @@ const spruceAssert = {
66
68
  actual === null ||
67
69
  typeof actual === 'undefined' ||
68
70
  actual === 0) {
69
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not truthy`);
71
+ this.fail(message ?? `${stringify(actual)} is not truthy`);
70
72
  }
71
73
  },
72
74
  isFalsy(actual, message) {
73
75
  if (actual) {
74
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not falsy`);
76
+ this.fail(message ?? `${stringify(actual)} is not falsy`);
75
77
  }
76
78
  },
77
79
  isNull(actual, message) {
78
80
  if (actual !== null) {
79
- this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not null`);
81
+ this.fail(message ?? `${stringify(actual)} is not null`);
80
82
  }
81
83
  },
82
84
  isString(actual, message) {
@@ -95,20 +97,22 @@ const spruceAssert = {
95
97
  },
96
98
  isObject(actual, message) {
97
99
  if (!(0, isObjectLike_1.default)(actual)) {
98
- throw this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not an object`);
100
+ throw this.fail(message ?? `${stringify(actual)} is not an object`);
99
101
  }
100
102
  },
101
103
  isArray(actual, message) {
102
104
  if (!Array.isArray(actual)) {
103
- throw this.fail(message !== null && message !== void 0 ? message : `${stringify(actual)} is not an array`);
105
+ throw this.fail(message ?? `${stringify(actual)} is not an array`);
104
106
  }
105
107
  },
106
108
  isLength(actual, expected, message) {
107
109
  if (!actual) {
108
- throw this.fail(message !== null && message !== void 0 ? message : `Expected array of length ${expected}, but got ${stringify(actual)}`);
110
+ throw this.fail(message ??
111
+ `Expected array of length ${expected}, but got ${stringify(actual)}`);
109
112
  }
110
113
  //@ts-ignore
111
- this.isEqual(actual.length, expected, message !== null && message !== void 0 ? message : `Expected length of ${stringify(expected)}, but got a length of ${stringify(actual.length)}`);
114
+ this.isEqual(actual.length, expected, message ??
115
+ `Expected length of ${stringify(expected)}, but got a length of ${stringify(actual.length)}`);
112
116
  },
113
117
  doesNotInclude(haystack, needle, message) {
114
118
  let doesInclude = false;
@@ -116,15 +120,17 @@ const spruceAssert = {
116
120
  this.doesInclude(haystack, needle);
117
121
  doesInclude = true;
118
122
  }
119
- catch (_a) {
123
+ catch {
120
124
  doesInclude = false;
121
125
  }
122
126
  if (doesInclude) {
123
- this.fail(message !== null && message !== void 0 ? message : `${stringify(haystack)} should not include ${stringify(needle)}, but it does`);
127
+ this.fail(message ??
128
+ `${stringify(haystack)} should not include ${stringify(needle)}, but it does`);
124
129
  }
125
130
  },
126
131
  doesInclude(haystack, needle, message) {
127
- let msg = message !== null && message !== void 0 ? message : `Could not find ${stringify(needle)} in ${stringify(haystack)}`;
132
+ let msg = message ??
133
+ `Could not find ${stringify(needle)} in ${stringify(haystack)}`;
128
134
  const isNeedleString = typeof needle === 'string';
129
135
  const isNeedleRegex = needle instanceof RegExp;
130
136
  if (typeof haystack === 'string' &&
@@ -149,9 +155,8 @@ const spruceAssert = {
149
155
  //@ts-ignore
150
156
  this.isEqualDeep(haystack, needle);
151
157
  return;
152
- // eslint-disable-next-line no-empty
153
158
  }
154
- catch (_a) { }
159
+ catch { }
155
160
  }
156
161
  if (assert_utility_1.default.foundUsing3rdPartyIncludes(haystack, needle, isHaystackObject)) {
157
162
  return;
@@ -227,4 +232,4 @@ const spruceAssert = {
227
232
  },
228
233
  fail: assert_utility_1.default.fail,
229
234
  };
230
- exports.default = spruceAssert;
235
+ exports.default = assert;
@@ -1,11 +1,8 @@
1
- import { ISpruceAssert } from '../assert';
1
+ import { ISpruceAssert } from './assert';
2
2
  export declare const UNDEFINED_PLACEHOLDER = "_____________undefined_____________";
3
3
  export declare const FUNCTION_PLACEHOLDER = "_____________function_____________";
4
4
  export declare const CIRCULAR_PLACEHOLDER = "_____________circular_____________";
5
5
  export declare const NULL_PLACEHOLDER = "_____________null_____________";
6
- /**
7
- * @deprecated delete and re-import from @sprucelabs/test-utils
8
- */
9
6
  declare const assertUtil: {
10
7
  fail(message?: string, stack?: string): never;
11
8
  stringify(object: any): string;
@@ -9,20 +9,16 @@ const get_1 = __importDefault(require("lodash/get"));
9
9
  const includes_1 = __importDefault(require("lodash/includes"));
10
10
  const isObject_1 = __importDefault(require("lodash/isObject"));
11
11
  const isObjectLike_1 = __importDefault(require("lodash/isObjectLike"));
12
- const AssertionError_1 = __importDefault(require("../AssertionError"));
12
+ const AssertionError_1 = __importDefault(require("./AssertionError"));
13
13
  exports.UNDEFINED_PLACEHOLDER = '_____________undefined_____________';
14
14
  exports.FUNCTION_PLACEHOLDER = '_____________function_____________';
15
15
  exports.CIRCULAR_PLACEHOLDER = '_____________circular_____________';
16
16
  exports.NULL_PLACEHOLDER = '_____________null_____________';
17
- /**
18
- * @deprecated delete and re-import from @sprucelabs/test-utils
19
- */
20
17
  const assertUtil = {
21
18
  fail(message, stack) {
22
- throw new AssertionError_1.default(message !== null && message !== void 0 ? message : 'Fail!', stack);
19
+ throw new AssertionError_1.default(message ?? 'Fail!', stack);
23
20
  },
24
21
  stringify(object) {
25
- var _a;
26
22
  let stringified;
27
23
  if (Array.isArray(object)) {
28
24
  stringified = `[\n${object.map((o) => this.stringify(o).split('\n').join('\n\t'))}\n]`;
@@ -32,7 +28,7 @@ const assertUtil = {
32
28
  stringified = chalk_1.default.bgBlack.white(` ${object} `);
33
29
  }
34
30
  else if (object instanceof Error) {
35
- stringified = `${(_a = object.stack) !== null && _a !== void 0 ? _a : object.message}`;
31
+ stringified = `${object.stack ?? object.message}`;
36
32
  }
37
33
  else if (object instanceof RegExp) {
38
34
  stringified = `${object.toString()}`;
@@ -62,7 +58,9 @@ const assertUtil = {
62
58
  .replace(new RegExp(`"${exports.NULL_PLACEHOLDER}"`, 'g'), chalk_1.default.italic('NULL'));
63
59
  },
64
60
  dropInPlaceholders(obj) {
65
- const checkedObjects = [{ obj, depth: 0 }];
61
+ const checkedObjects = [
62
+ { obj, depth: 0 },
63
+ ];
66
64
  let updated = this.dropInPlaceholder(obj, (obj, depth) => {
67
65
  if ((0, isObject_1.default)(obj) &&
68
66
  checkedObjects.some((checked) => {
@@ -82,7 +80,9 @@ const assertUtil = {
82
80
  if (!(0, isObject_1.default)(obj)) {
83
81
  return obj;
84
82
  }
85
- const updated = Array.isArray(obj) ? [] : {};
83
+ const updated = Array.isArray(obj)
84
+ ? []
85
+ : {};
86
86
  Object.keys(obj).forEach((key) => {
87
87
  //@ts-ignore
88
88
  updated[key] =
@@ -104,24 +104,26 @@ const assertUtil = {
104
104
  check(haystack, needle);
105
105
  return true;
106
106
  }
107
- catch (_a) {
107
+ catch {
108
108
  return false;
109
109
  }
110
110
  });
111
111
  },
112
112
  assertTypeof(actual, type, message) {
113
113
  if (typeof actual !== type) {
114
- this.fail(message !== null && message !== void 0 ? message : `${JSON.stringify(actual)} is not a ${type}`);
114
+ this.fail(message ?? `${JSON.stringify(actual)} is not a ${type}`);
115
115
  }
116
116
  },
117
117
  checkDoesThrowError(matcher, err, msg) {
118
- var _a, _b;
119
- const message = (_b = (_a = err.stack) !== null && _a !== void 0 ? _a : err.message) !== null && _b !== void 0 ? _b : '**MISSING ERROR MESSAGE**';
118
+ const message = err.stack ?? err.message ?? '**MISSING ERROR MESSAGE**';
120
119
  if (typeof matcher === 'string' && message.search(matcher) === -1) {
121
- 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);
120
+ this.fail(msg ??
121
+ `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);
122
122
  }
123
- else if (matcher instanceof RegExp && message.search(matcher) === -1) {
124
- 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);
123
+ else if (matcher instanceof RegExp &&
124
+ message.search(matcher) === -1) {
125
+ this.fail(msg ??
126
+ `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);
125
127
  }
126
128
  },
127
129
  partialContains(object, subObject) {
@@ -137,7 +139,8 @@ const assertUtil = {
137
139
  if (!Object.prototype.hasOwnProperty.call(object, subProp)) {
138
140
  return false;
139
141
  }
140
- if ((!(0, isObjectLike_1.default)(object[subProp]) || !(0, isObjectLike_1.default)(subObject[subProp])) &&
142
+ if ((!(0, isObjectLike_1.default)(object[subProp]) ||
143
+ !(0, isObjectLike_1.default)(subObject[subProp])) &&
141
144
  object[subProp] !== subObject[subProp]) {
142
145
  return false;
143
146
  }
@@ -159,9 +162,8 @@ const assertUtil = {
159
162
  return { needleHasArrayNotation, path, expected };
160
163
  },
161
164
  splitPathBasedOnArrayNotation(path, haystack) {
162
- var _a;
163
165
  const pathParts = path.split('[].');
164
- const pathToFirstArray = (_a = pathParts.shift()) !== null && _a !== void 0 ? _a : '';
166
+ const pathToFirstArray = pathParts.shift() ?? '';
165
167
  const pathAfterFirstArray = pathParts.join('[].');
166
168
  const actualBeforeArray = this.valueAtPath(haystack, pathToFirstArray);
167
169
  return { actualBeforeArray, pathAfterFirstArray };
@@ -1,6 +1,5 @@
1
- /**
2
- * @deprecated delete and re-import from @sprucelabs/test-utils
3
- */
1
+ /** Hooks up before, after, etc. */
2
+ export declare function hookupTestClass(target: any): void;
4
3
  declare function test(description?: string, ...args: any[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
5
4
  declare namespace test {
6
5
  var only: (description?: string | undefined, ...args: any[]) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hookupTestClass = void 0;
3
4
  /** Hooks up before, after, etc. */
4
5
  function hookupTestClass(target) {
5
6
  if (target.__isTestingHookedUp) {
@@ -21,16 +22,15 @@ function hookupTestClass(target) {
21
22
  }
22
23
  });
23
24
  }
24
- /**
25
- * @deprecated delete and re-import from @sprucelabs/test-utils
26
- */
25
+ exports.hookupTestClass = hookupTestClass;
27
26
  function test(description, ...args) {
28
27
  return function (target, propertyKey, descriptor) {
29
28
  // Lets attach before/after
30
29
  hookupTestClass(target);
31
30
  const bound = descriptor.value.bind(target);
32
31
  // Make sure each test gets the spruce
33
- it(description !== null && description !== void 0 ? description : propertyKey, async () => {
32
+ // eslint-disable-next-line no-undef
33
+ it(description ?? propertyKey, async () => {
34
34
  //@ts-ignore
35
35
  global.activeTest = {
36
36
  file: target.name,
@@ -50,7 +50,8 @@ test.only = (description, ...args) => {
50
50
  hookupTestClass(target);
51
51
  const bound = descriptor.value.bind(target);
52
52
  // Make sure each test gets the spruce
53
- it.only(description !== null && description !== void 0 ? description : propertyKey, async () => {
53
+ // eslint-disable-next-line no-undef
54
+ it.only(description ?? propertyKey, async () => {
54
55
  return bound(...args);
55
56
  });
56
57
  };
@@ -63,7 +64,8 @@ test.todo = (description, ..._args) => {
63
64
  // Lets attach before/after
64
65
  hookupTestClass(target);
65
66
  // Make sure each test gets the spruce
66
- it.todo(description !== null && description !== void 0 ? description : propertyKey);
67
+ // eslint-disable-next-line no-undef
68
+ it.todo(description ?? propertyKey);
67
69
  };
68
70
  };
69
71
  /**
@@ -75,7 +77,8 @@ test.skip = (description, ...args) => {
75
77
  hookupTestClass(target);
76
78
  const bound = descriptor.value.bind(target);
77
79
  // Make sure each test gets the spruce
78
- it.skip(description !== null && description !== void 0 ? description : propertyKey, async () => {
80
+ // eslint-disable-next-line no-undef
81
+ it.skip(description ?? propertyKey, async () => {
79
82
  return bound(...args);
80
83
  });
81
84
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "8.0.51",
6
+ "version": "9.0.0",
7
7
  "skill": {
8
8
  "namespace": "spruce-test",
9
9
  "upgradeIgnoreList": [
@@ -49,8 +49,8 @@
49
49
  "clean.build": "rm -rf build/",
50
50
  "clean.dependencies": "rm -rf node_modules/ package-lock.json yarn.lock",
51
51
  "clean.dist": "rm -rf build/__tests__ build/esm/__tests__",
52
- "fix.lint": "eslint --fix --cache '**/*.ts'",
53
- "lint": "eslint --cache '**/*.ts'",
52
+ "fix.lint": "eslint --fix --cache",
53
+ "lint": "eslint --cache",
54
54
  "lint.tsc": "tsc -p . --noEmit",
55
55
  "local": "node --inspect=5200 ./build/index.js",
56
56
  "post.watch.build": "true",
@@ -75,17 +75,17 @@
75
75
  "lodash": "^4.17.21",
76
76
  "ts-expect": "^1.3.0",
77
77
  "ts-jest": "next",
78
- "typescript": "5.4.4",
78
+ "typescript": "^5.4.5",
79
79
  "variable-diff": "^2.0.2"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@sprucelabs/esm-postbuild": "^5.0.163",
83
- "@sprucelabs/semantic-release": "^4.0.8",
83
+ "@sprucelabs/semantic-release": "^5.0.1",
84
84
  "@types/deep-equal": "^1.0.4",
85
85
  "@types/jest": "^29.5.12",
86
86
  "@types/lodash": "^4.17.0",
87
- "eslint": "^8.57.0",
88
- "eslint-config-spruce": "^10.13.6",
87
+ "eslint": "^9.0.0",
88
+ "eslint-config-spruce": "^11.2.1",
89
89
  "prettier": "^3.2.5",
90
90
  "tsc-watch": "^6.2.0",
91
91
  "tsconfig-paths": "^4.2.0",
File without changes