@sprucelabs/test 9.0.29 → 9.0.31
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/esm/lib/AbstractSpruceTest.js +8 -27
- package/build/esm/lib/assert.js +11 -22
- package/build/esm/lib/assert.utility.d.ts +1 -1
- package/build/esm/lib/assert.utility.js +1 -1
- package/build/esm/lib/decorators.d.ts +3 -3
- package/build/esm/lib/decorators.js +8 -17
- package/build/lib/assert.utility.d.ts +1 -1
- package/build/lib/decorators.d.ts +3 -3
- package/build/lib/decorators.js +2 -3
- package/package.json +17 -6
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import path from 'path';
|
|
11
2
|
export default class AbstractSpruceTest {
|
|
12
|
-
static beforeAll() {
|
|
13
|
-
|
|
14
|
-
this.cwd = process.cwd();
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
static afterAll() {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
19
|
-
}
|
|
20
|
-
static beforeEach() {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
22
|
-
}
|
|
23
|
-
static afterEach() {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
3
|
+
static async beforeAll() {
|
|
4
|
+
this.cwd = process.cwd();
|
|
25
5
|
}
|
|
6
|
+
static async afterAll() { }
|
|
7
|
+
static async beforeEach() { }
|
|
8
|
+
static async afterEach() { }
|
|
26
9
|
static resolvePath(...filePath) {
|
|
27
10
|
const cwd = this.cwd;
|
|
28
11
|
let builtPath = path.join(...filePath);
|
|
@@ -37,11 +20,9 @@ export default class AbstractSpruceTest {
|
|
|
37
20
|
}
|
|
38
21
|
return builtPath;
|
|
39
22
|
}
|
|
40
|
-
static wait() {
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
setTimeout(() => resolve(true), ms);
|
|
44
|
-
});
|
|
23
|
+
static async wait(ms = 1000) {
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
setTimeout(() => resolve(true), ms);
|
|
45
26
|
});
|
|
46
27
|
}
|
|
47
28
|
static log(...args) {
|
package/build/esm/lib/assert.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import chalk from 'chalk';
|
|
11
2
|
import deepEqual from 'deep-equal';
|
|
12
3
|
import escapeRegExp from 'lodash/escapeRegExp.js';
|
|
@@ -120,7 +111,7 @@ const assert = {
|
|
|
120
111
|
this.doesInclude(haystack, needle);
|
|
121
112
|
doesInclude = true;
|
|
122
113
|
}
|
|
123
|
-
catch
|
|
114
|
+
catch {
|
|
124
115
|
doesInclude = false;
|
|
125
116
|
}
|
|
126
117
|
if (doesInclude) {
|
|
@@ -154,7 +145,7 @@ const assert = {
|
|
|
154
145
|
this.isEqualDeep(haystack, needle);
|
|
155
146
|
return;
|
|
156
147
|
}
|
|
157
|
-
catch
|
|
148
|
+
catch { }
|
|
158
149
|
}
|
|
159
150
|
if (assertUtil.foundUsing3rdPartyIncludes(haystack, needle, isHaystackObject)) {
|
|
160
151
|
return;
|
|
@@ -218,17 +209,15 @@ const assert = {
|
|
|
218
209
|
}
|
|
219
210
|
this.fail('Expected a thrown error, but never got one!');
|
|
220
211
|
},
|
|
221
|
-
doesThrowAsync(cb, matcher, msg) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
this.fail('Expected a thrown error, but never got one!');
|
|
231
|
-
});
|
|
212
|
+
async doesThrowAsync(cb, matcher, msg) {
|
|
213
|
+
try {
|
|
214
|
+
await cb();
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
assertUtil.checkDoesThrowError(matcher, err, msg);
|
|
218
|
+
return err;
|
|
219
|
+
}
|
|
220
|
+
this.fail('Expected a thrown error, but never got one!');
|
|
232
221
|
},
|
|
233
222
|
fail: assertUtil.fail,
|
|
234
223
|
};
|
|
@@ -9,7 +9,7 @@ declare const assertUtil: {
|
|
|
9
9
|
replacePlaceholders(str: string): string;
|
|
10
10
|
dropInPlaceholders(obj: Record<string, any>): any[] | Record<string, any>;
|
|
11
11
|
dropInPlaceholder(obj: Record<string, any>, checker: (obj: any, depth: number) => boolean, placeholder: string, depth?: number): any[] | Record<string, any>;
|
|
12
|
-
doHaystacksPassCheck(haystacks: any[], needle: any, check: ISpruceAssert[
|
|
12
|
+
doHaystacksPassCheck(haystacks: any[], needle: any, check: ISpruceAssert["doesInclude"]): boolean;
|
|
13
13
|
assertTypeof(actual: any, type: string, message: string | undefined): void;
|
|
14
14
|
checkDoesThrowError(matcher: string | RegExp | undefined, err: Error, msg?: string | undefined): void;
|
|
15
15
|
partialContains(object: any, subObject: any): boolean | undefined;
|
|
@@ -5,8 +5,8 @@ export declare function hookupTestClass(target: any): void;
|
|
|
5
5
|
*/
|
|
6
6
|
declare function test(description?: string, ...args: any[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
7
7
|
declare namespace test {
|
|
8
|
-
var only: (description?: string
|
|
9
|
-
var todo: (description?: string
|
|
10
|
-
var skip: (description?: string
|
|
8
|
+
var only: (description?: string, ...args: any[]) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
9
|
+
var todo: (description?: string, ..._args: any[]) => (target: any, propertyKey: string) => void;
|
|
10
|
+
var skip: (description?: string, ...args: any[]) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
11
11
|
}
|
|
12
12
|
export default test;
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
/** Hooks up before, after, etc. */
|
|
11
2
|
export function hookupTestClass(target) {
|
|
12
3
|
if (target.__isTestingHookedUp) {
|
|
@@ -22,9 +13,9 @@ export function hookupTestClass(target) {
|
|
|
22
13
|
// @ts-ignore
|
|
23
14
|
if (global[hook]) {
|
|
24
15
|
// @ts-ignore
|
|
25
|
-
global[hook](() =>
|
|
16
|
+
global[hook](async () => {
|
|
26
17
|
return target[hook]();
|
|
27
|
-
})
|
|
18
|
+
});
|
|
28
19
|
}
|
|
29
20
|
});
|
|
30
21
|
}
|
|
@@ -37,14 +28,14 @@ export default function test(description, ...args) {
|
|
|
37
28
|
hookupTestClass(target);
|
|
38
29
|
const bound = descriptor.value.bind(target);
|
|
39
30
|
// Make sure each test gets the spruce
|
|
40
|
-
it(description !== null && description !== void 0 ? description : propertyKey, () =>
|
|
31
|
+
it(description !== null && description !== void 0 ? description : propertyKey, async () => {
|
|
41
32
|
//@ts-ignore
|
|
42
33
|
global.activeTest = {
|
|
43
34
|
file: target.name,
|
|
44
35
|
test: propertyKey,
|
|
45
36
|
};
|
|
46
37
|
return bound(...args);
|
|
47
|
-
})
|
|
38
|
+
});
|
|
48
39
|
};
|
|
49
40
|
}
|
|
50
41
|
/**
|
|
@@ -56,9 +47,9 @@ test.only = (description, ...args) => {
|
|
|
56
47
|
hookupTestClass(target);
|
|
57
48
|
const bound = descriptor.value.bind(target);
|
|
58
49
|
// Make sure each test gets the spruce
|
|
59
|
-
it.only(description !== null && description !== void 0 ? description : propertyKey, () =>
|
|
50
|
+
it.only(description !== null && description !== void 0 ? description : propertyKey, async () => {
|
|
60
51
|
return bound(...args);
|
|
61
|
-
})
|
|
52
|
+
});
|
|
62
53
|
};
|
|
63
54
|
};
|
|
64
55
|
/**
|
|
@@ -81,8 +72,8 @@ test.skip = (description, ...args) => {
|
|
|
81
72
|
hookupTestClass(target);
|
|
82
73
|
const bound = descriptor.value.bind(target);
|
|
83
74
|
// Make sure each test gets the spruce
|
|
84
|
-
it.skip(description !== null && description !== void 0 ? description : propertyKey, () =>
|
|
75
|
+
it.skip(description !== null && description !== void 0 ? description : propertyKey, async () => {
|
|
85
76
|
return bound(...args);
|
|
86
|
-
})
|
|
77
|
+
});
|
|
87
78
|
};
|
|
88
79
|
};
|
|
@@ -9,7 +9,7 @@ declare const assertUtil: {
|
|
|
9
9
|
replacePlaceholders(str: string): string;
|
|
10
10
|
dropInPlaceholders(obj: Record<string, any>): any[] | Record<string, any>;
|
|
11
11
|
dropInPlaceholder(obj: Record<string, any>, checker: (obj: any, depth: number) => boolean, placeholder: string, depth?: number): any[] | Record<string, any>;
|
|
12
|
-
doHaystacksPassCheck(haystacks: any[], needle: any, check: ISpruceAssert[
|
|
12
|
+
doHaystacksPassCheck(haystacks: any[], needle: any, check: ISpruceAssert["doesInclude"]): boolean;
|
|
13
13
|
assertTypeof(actual: any, type: string, message: string | undefined): void;
|
|
14
14
|
checkDoesThrowError(matcher: string | RegExp | undefined, err: Error, msg?: string | undefined): void;
|
|
15
15
|
partialContains(object: any, subObject: any): boolean | undefined;
|
|
@@ -5,8 +5,8 @@ export declare function hookupTestClass(target: any): void;
|
|
|
5
5
|
*/
|
|
6
6
|
declare function test(description?: string, ...args: any[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
7
7
|
declare namespace test {
|
|
8
|
-
var only: (description?: string
|
|
9
|
-
var todo: (description?: string
|
|
10
|
-
var skip: (description?: string
|
|
8
|
+
var only: (description?: string, ...args: any[]) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
9
|
+
var todo: (description?: string, ..._args: any[]) => (target: any, propertyKey: string) => void;
|
|
10
|
+
var skip: (description?: string, ...args: any[]) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
11
11
|
}
|
|
12
12
|
export default test;
|
package/build/lib/decorators.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hookupTestClass =
|
|
3
|
+
exports.hookupTestClass = hookupTestClass;
|
|
4
|
+
exports.default = test;
|
|
4
5
|
/** Hooks up before, after, etc. */
|
|
5
6
|
function hookupTestClass(target) {
|
|
6
7
|
if (target.__isTestingHookedUp) {
|
|
@@ -22,7 +23,6 @@ function hookupTestClass(target) {
|
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
exports.hookupTestClass = hookupTestClass;
|
|
26
26
|
/**
|
|
27
27
|
* @deprecated - Remove and re-import from @sprucelabs/test-utils
|
|
28
28
|
*/
|
|
@@ -42,7 +42,6 @@ function test(description, ...args) {
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
exports.default = test;
|
|
46
45
|
/**
|
|
47
46
|
* @deprecated delete and re-import from @sprucelabs/test-utils
|
|
48
47
|
*/
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "9.0.
|
|
6
|
+
"version": "9.0.31",
|
|
7
7
|
"skill": {
|
|
8
8
|
"namespace": "spruce-test",
|
|
9
9
|
"upgradeIgnoreList": [
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"chokidar-cli",
|
|
16
16
|
"ts-jest",
|
|
17
17
|
"ts-node"
|
|
18
|
-
]
|
|
18
|
+
],
|
|
19
|
+
"blockedCommands": {
|
|
20
|
+
"upgrade": "You have to run yarn upgrade.packages.all to upgrade the packages in this skill."
|
|
21
|
+
}
|
|
19
22
|
},
|
|
20
23
|
"files": [
|
|
21
24
|
"build"
|
|
@@ -73,17 +76,17 @@
|
|
|
73
76
|
"lodash": "^4.17.21",
|
|
74
77
|
"ts-expect": "^1.3.0",
|
|
75
78
|
"ts-jest": "next",
|
|
76
|
-
"typescript": "^5.
|
|
79
|
+
"typescript": "^5.5.2",
|
|
77
80
|
"variable-diff": "^2.0.2"
|
|
78
81
|
},
|
|
79
82
|
"devDependencies": {
|
|
80
|
-
"@sprucelabs/esm-postbuild": "^
|
|
83
|
+
"@sprucelabs/esm-postbuild": "^6.0.50",
|
|
81
84
|
"@sprucelabs/semantic-release": "^5.0.1",
|
|
82
85
|
"@types/deep-equal": "^1.0.4",
|
|
83
86
|
"@types/jest": "^29.5.12",
|
|
84
87
|
"@types/lodash": "^4.17.5",
|
|
85
88
|
"eslint": "^9.5.0",
|
|
86
|
-
"eslint-config-spruce": "^11.2.
|
|
89
|
+
"eslint-config-spruce": "^11.2.25",
|
|
87
90
|
"prettier": "^3.3.2",
|
|
88
91
|
"tsc-watch": "^6.2.0",
|
|
89
92
|
"tsconfig-paths": "^4.2.0",
|
|
@@ -98,6 +101,14 @@
|
|
|
98
101
|
]
|
|
99
102
|
},
|
|
100
103
|
"yarn-upgrade-all": {
|
|
101
|
-
"ignore": [
|
|
104
|
+
"ignore": [
|
|
105
|
+
"@sprucelabs/resolve-path-aliases",
|
|
106
|
+
"@sprucelabs/spruce-test-fixtures",
|
|
107
|
+
"@types/node",
|
|
108
|
+
"chalk",
|
|
109
|
+
"chokidar-cli",
|
|
110
|
+
"ts-jest",
|
|
111
|
+
"ts-node"
|
|
112
|
+
]
|
|
102
113
|
}
|
|
103
114
|
}
|