@fgv/ts-utils-jest 5.0.0-8 → 5.0.1-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.
- package/CHANGELOG.json +9 -3
- package/README.md +11 -0
- package/dist/ts-utils-jest.d.ts +3 -1
- package/eslint.config.js +16 -0
- package/lib/helpers/fsHelpers.d.ts +2 -1
- package/lib/helpers/fsHelpers.js +14 -45
- package/lib/index.js +0 -3
- package/lib/matchers/toFailTest/index.js +1 -1
- package/lib/matchers/toFailTest/predicate.js +1 -1
- package/lib/matchers/toFailTestAndMatchSnapshot/index.js +3 -2
- package/lib/matchers/toFailTestAndMatchSnapshot/predicate.js +1 -1
- package/lib/matchers/toFailTestWith/predicate.js +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/utils/colorHelpers.d.ts +54 -0
- package/lib/utils/colorHelpers.js +84 -0
- package/lib/utils/matcherHelpers.js +9 -5
- package/package.json +15 -15
- package/test/data/testData.json +4 -0
- package/CHANGELOG.md +0 -105
- package/lib/helpers/fsHelpers.d.ts.map +0 -1
- package/lib/helpers/fsHelpers.js.map +0 -1
- package/lib/helpers/index.d.ts.map +0 -1
- package/lib/helpers/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/matchers/index.d.ts.map +0 -1
- package/lib/matchers/index.js.map +0 -1
- package/lib/matchers/toFail/index.d.ts.map +0 -1
- package/lib/matchers/toFail/index.js.map +0 -1
- package/lib/matchers/toFail/predicate.d.ts.map +0 -1
- package/lib/matchers/toFail/predicate.js.map +0 -1
- package/lib/matchers/toFailTest/index.d.ts.map +0 -1
- package/lib/matchers/toFailTest/index.js.map +0 -1
- package/lib/matchers/toFailTest/predicate.d.ts.map +0 -1
- package/lib/matchers/toFailTest/predicate.js.map +0 -1
- package/lib/matchers/toFailTestAndMatchSnapshot/index.d.ts.map +0 -1
- package/lib/matchers/toFailTestAndMatchSnapshot/index.js.map +0 -1
- package/lib/matchers/toFailTestAndMatchSnapshot/predicate.d.ts.map +0 -1
- package/lib/matchers/toFailTestAndMatchSnapshot/predicate.js.map +0 -1
- package/lib/matchers/toFailTestWith/index.d.ts.map +0 -1
- package/lib/matchers/toFailTestWith/index.js.map +0 -1
- package/lib/matchers/toFailTestWith/predicate.d.ts.map +0 -1
- package/lib/matchers/toFailTestWith/predicate.js.map +0 -1
- package/lib/matchers/toFailWith/index.d.ts.map +0 -1
- package/lib/matchers/toFailWith/index.js.map +0 -1
- package/lib/matchers/toFailWith/predicate.d.ts.map +0 -1
- package/lib/matchers/toFailWith/predicate.js.map +0 -1
- package/lib/matchers/toFailWithDetail/index.d.ts.map +0 -1
- package/lib/matchers/toFailWithDetail/index.js.map +0 -1
- package/lib/matchers/toFailWithDetail/predicate.d.ts.map +0 -1
- package/lib/matchers/toFailWithDetail/predicate.js.map +0 -1
- package/lib/matchers/toHaveBeenCalledWithArgumentsMatching/index.d.ts.map +0 -1
- package/lib/matchers/toHaveBeenCalledWithArgumentsMatching/index.js.map +0 -1
- package/lib/matchers/toHaveBeenCalledWithArgumentsMatching/predicate.d.ts.map +0 -1
- package/lib/matchers/toHaveBeenCalledWithArgumentsMatching/predicate.js.map +0 -1
- package/lib/matchers/toSucceed/index.d.ts.map +0 -1
- package/lib/matchers/toSucceed/index.js.map +0 -1
- package/lib/matchers/toSucceed/predicate.d.ts.map +0 -1
- package/lib/matchers/toSucceed/predicate.js.map +0 -1
- package/lib/matchers/toSucceedAndMatchInlineSnapshot/index.d.ts.map +0 -1
- package/lib/matchers/toSucceedAndMatchInlineSnapshot/index.js.map +0 -1
- package/lib/matchers/toSucceedAndMatchSnapshot/index.d.ts.map +0 -1
- package/lib/matchers/toSucceedAndMatchSnapshot/index.js.map +0 -1
- package/lib/matchers/toSucceedAndSatisfy/index.d.ts.map +0 -1
- package/lib/matchers/toSucceedAndSatisfy/index.js.map +0 -1
- package/lib/matchers/toSucceedAndSatisfy/predicate.d.ts.map +0 -1
- package/lib/matchers/toSucceedAndSatisfy/predicate.js.map +0 -1
- package/lib/matchers/toSucceedWith/index.d.ts.map +0 -1
- package/lib/matchers/toSucceedWith/index.js.map +0 -1
- package/lib/matchers/toSucceedWith/predicate.d.ts.map +0 -1
- package/lib/matchers/toSucceedWith/predicate.js.map +0 -1
- package/lib/matchers/toSucceedWithDetail/index.d.ts.map +0 -1
- package/lib/matchers/toSucceedWithDetail/index.js.map +0 -1
- package/lib/matchers/toSucceedWithDetail/predicate.d.ts.map +0 -1
- package/lib/matchers/toSucceedWithDetail/predicate.js.map +0 -1
- package/lib/resolvers/cli.d.ts.map +0 -1
- package/lib/resolvers/cli.js.map +0 -1
- package/lib/resolvers/ide.d.ts.map +0 -1
- package/lib/resolvers/ide.js.map +0 -1
- package/lib/ts-utils.d.ts.map +0 -1
- package/lib/ts-utils.js.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib/utils/matcherHelpers.d.ts.map +0 -1
- package/lib/utils/matcherHelpers.js.map +0 -1
- package/lib/utils/snapshotResolver.d.ts.map +0 -1
- package/lib/utils/snapshotResolver.js.map +0 -1
package/CHANGELOG.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-utils-jest",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "5.0.1",
|
|
6
|
+
"tag": "@fgv/ts-utils-jest_v5.0.1",
|
|
7
|
+
"date": "Tue, 23 Sep 2025 03:13:55 GMT",
|
|
8
|
+
"comments": {}
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "5.0.0",
|
|
6
12
|
"tag": "@fgv/ts-utils-jest_v5.0.0",
|
|
7
|
-
"date": "
|
|
13
|
+
"date": "Tue, 23 Sep 2025 02:54:20 GMT",
|
|
8
14
|
"comments": {
|
|
9
15
|
"none": [
|
|
10
16
|
{
|
|
11
|
-
"comment": "
|
|
17
|
+
"comment": "better handling of snapshots with and without color escapes"
|
|
12
18
|
},
|
|
13
19
|
{
|
|
14
|
-
"comment": "
|
|
20
|
+
"comment": "update rushstack"
|
|
15
21
|
}
|
|
16
22
|
]
|
|
17
23
|
}
|
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ Also includes a handful of custom matchers to simplify the testing of other cust
|
|
|
16
16
|
- [Summary](#summary)
|
|
17
17
|
- [Installation](#installation)
|
|
18
18
|
- [Setup](#setup)
|
|
19
|
+
- [ANSI Color Stripping](#ansi-color-stripping)
|
|
19
20
|
- [API](#api)
|
|
20
21
|
- [Testing Result\<T\>](#testing-resultt)
|
|
21
22
|
- [.toFail()](#tofail)
|
|
@@ -43,6 +44,16 @@ npm install --save-dev @fgv/ts-utils-jest
|
|
|
43
44
|
|
|
44
45
|
Note that snapshot testing for Jest itself can be tricky because different environments (e.g. CLI vs IDE vs CICD) might generate slightly different output due to e.g. differences in color display of diffs. To facilitate snapshot testing across multiple environments, this library also provides an extensible set of snapshot resolvers that can be used to capture environment-specific snapshots.
|
|
45
46
|
|
|
47
|
+
### ANSI Color Stripping
|
|
48
|
+
|
|
49
|
+
**All matchers in this library automatically strip ANSI color codes** from Jest output to ensure consistent snapshots across different terminal environments. This includes:
|
|
50
|
+
|
|
51
|
+
- **Jest matcher utilities** (`printExpected`, `printReceived`) used in error messages
|
|
52
|
+
- **Snapshot content** passed to `toMatchSnapshot()` and `toFailTestAndMatchSnapshot()`
|
|
53
|
+
- **Test failure messages** captured by custom matcher testing utilities
|
|
54
|
+
|
|
55
|
+
This means you can run tests with any terminal color settings (`FORCE_COLOR=0`, `FORCE_COLOR=1`, or default) and get identical snapshot results. No special configuration is required - the color stripping happens automatically.
|
|
56
|
+
|
|
46
57
|
## API
|
|
47
58
|
|
|
48
59
|
### Testing Result\<T\>
|
package/dist/ts-utils-jest.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @public
|
|
3
5
|
*/
|
|
@@ -31,7 +33,7 @@ declare class MockFileSystem {
|
|
|
31
33
|
getExtraFilesWritten(): string[];
|
|
32
34
|
tryGetPayload(want: string): string | undefined;
|
|
33
35
|
reset(): void;
|
|
34
|
-
startSpies(): ReadWriteSpies;
|
|
36
|
+
startSpies(fsModule?: typeof fs): ReadWriteSpies;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
declare namespace MockFs {
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ESLint 9 flat config
|
|
2
|
+
const nodeProfile = require('@rushstack/eslint-config/flat/profile/node');
|
|
3
|
+
const packletsPlugin = require('@rushstack/eslint-config/flat/mixins/packlets');
|
|
4
|
+
const tsdocPlugin = require('@rushstack/eslint-config/flat/mixins/tsdoc');
|
|
5
|
+
|
|
6
|
+
module.exports = [
|
|
7
|
+
...nodeProfile,
|
|
8
|
+
packletsPlugin,
|
|
9
|
+
...tsdocPlugin,
|
|
10
|
+
{
|
|
11
|
+
// Override specific rules if needed
|
|
12
|
+
rules: {
|
|
13
|
+
'@rushstack/packlets/mechanics': 'warn'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
1
2
|
/**
|
|
2
3
|
* @public
|
|
3
4
|
*/
|
|
@@ -46,7 +47,7 @@ export declare class MockFileSystem {
|
|
|
46
47
|
getExtraFilesWritten(): string[];
|
|
47
48
|
tryGetPayload(want: string): string | undefined;
|
|
48
49
|
reset(): void;
|
|
49
|
-
startSpies(): ReadWriteSpies;
|
|
50
|
+
startSpies(fsModule?: typeof fs): ReadWriteSpies;
|
|
50
51
|
}
|
|
51
52
|
export {};
|
|
52
53
|
//# sourceMappingURL=fsHelpers.d.ts.map
|
package/lib/helpers/fsHelpers.js
CHANGED
|
@@ -20,46 +20,13 @@
|
|
|
20
20
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
* SOFTWARE.
|
|
22
22
|
*/
|
|
23
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
-
if (k2 === undefined) k2 = k;
|
|
25
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
-
}
|
|
29
|
-
Object.defineProperty(o, k2, desc);
|
|
30
|
-
}) : (function(o, m, k, k2) {
|
|
31
|
-
if (k2 === undefined) k2 = k;
|
|
32
|
-
o[k2] = m[k];
|
|
33
|
-
}));
|
|
34
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
-
}) : function(o, v) {
|
|
37
|
-
o["default"] = v;
|
|
38
|
-
});
|
|
39
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
-
var ownKeys = function(o) {
|
|
41
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
-
var ar = [];
|
|
43
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
-
return ar;
|
|
45
|
-
};
|
|
46
|
-
return ownKeys(o);
|
|
47
|
-
};
|
|
48
|
-
return function (mod) {
|
|
49
|
-
if (mod && mod.__esModule) return mod;
|
|
50
|
-
var result = {};
|
|
51
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
-
__setModuleDefault(result, mod);
|
|
53
|
-
return result;
|
|
54
|
-
};
|
|
55
|
-
})();
|
|
56
23
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
57
24
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
25
|
};
|
|
59
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
27
|
exports.MockFileSystem = exports.ReadWriteSpies = void 0;
|
|
61
28
|
const fs_1 = __importDefault(require("fs"));
|
|
62
|
-
const
|
|
29
|
+
const path_1 = __importDefault(require("path"));
|
|
63
30
|
/**
|
|
64
31
|
* @public
|
|
65
32
|
*/
|
|
@@ -89,7 +56,7 @@ class MockFileSystem {
|
|
|
89
56
|
this._options = options;
|
|
90
57
|
this._realReadFileSync = fs_1.default.readFileSync;
|
|
91
58
|
for (const config of configs) {
|
|
92
|
-
const fullPath =
|
|
59
|
+
const fullPath = path_1.default.resolve(config.path);
|
|
93
60
|
this._config.set(fullPath, config);
|
|
94
61
|
if (config.backingFile) {
|
|
95
62
|
this.readMockFileSync(fullPath);
|
|
@@ -101,7 +68,7 @@ class MockFileSystem {
|
|
|
101
68
|
}
|
|
102
69
|
readMockFileSync(wanted) {
|
|
103
70
|
var _a;
|
|
104
|
-
const fullPathWanted =
|
|
71
|
+
const fullPathWanted = path_1.default.resolve(wanted);
|
|
105
72
|
if (!this._data.has(fullPathWanted)) {
|
|
106
73
|
const config = this._config.get(fullPathWanted);
|
|
107
74
|
if ((config === null || config === void 0 ? void 0 : config.backingFile) === undefined) {
|
|
@@ -112,7 +79,7 @@ class MockFileSystem {
|
|
|
112
79
|
this._data.set(fullPathWanted, body);
|
|
113
80
|
}
|
|
114
81
|
else {
|
|
115
|
-
const fullBackingPath =
|
|
82
|
+
const fullBackingPath = path_1.default.resolve(config.backingFile);
|
|
116
83
|
const body = this._realReadFileSync(fullBackingPath).toString();
|
|
117
84
|
this._data.set(fullPathWanted, body);
|
|
118
85
|
}
|
|
@@ -127,7 +94,7 @@ class MockFileSystem {
|
|
|
127
94
|
}
|
|
128
95
|
writeMockFileSync(wanted, body) {
|
|
129
96
|
var _a;
|
|
130
|
-
const fullPathWanted =
|
|
97
|
+
const fullPathWanted = path_1.default.resolve(wanted);
|
|
131
98
|
const config = this._config.get(fullPathWanted);
|
|
132
99
|
if (config === undefined) {
|
|
133
100
|
if (((_a = this._options) === null || _a === void 0 ? void 0 : _a.allowUnknownMockWrite) !== true) {
|
|
@@ -144,17 +111,17 @@ class MockFileSystem {
|
|
|
144
111
|
return Array.from(this._extraWrites);
|
|
145
112
|
}
|
|
146
113
|
tryGetPayload(want) {
|
|
147
|
-
return this._data.get(
|
|
114
|
+
return this._data.get(path_1.default.resolve(want));
|
|
148
115
|
}
|
|
149
116
|
reset() {
|
|
150
117
|
const writable = Array.from(this._config.values()).filter((c) => c.writable === true);
|
|
151
118
|
for (const config of writable) {
|
|
152
|
-
this._data.delete(
|
|
119
|
+
this._data.delete(path_1.default.resolve(config.path));
|
|
153
120
|
if (config.backingFile) {
|
|
154
|
-
this.readMockFileSync(
|
|
121
|
+
this.readMockFileSync(path_1.default.resolve(config.path));
|
|
155
122
|
}
|
|
156
123
|
else if (config.payload) {
|
|
157
|
-
this._data.set(
|
|
124
|
+
this._data.set(path_1.default.resolve(config.path), config.payload);
|
|
158
125
|
}
|
|
159
126
|
}
|
|
160
127
|
for (const path of this._extraWrites) {
|
|
@@ -162,13 +129,15 @@ class MockFileSystem {
|
|
|
162
129
|
}
|
|
163
130
|
this._extraWrites.splice(0, this._extraWrites.length);
|
|
164
131
|
}
|
|
165
|
-
startSpies() {
|
|
166
|
-
|
|
132
|
+
startSpies(fsModule) {
|
|
133
|
+
// Dynamic import of fs at runtime to avoid babel instrumentation timing issues
|
|
134
|
+
const fsToMock = fsModule || require('fs');
|
|
135
|
+
return new ReadWriteSpies(jest.spyOn(fsToMock, 'readFileSync').mockImplementation((wanted) => {
|
|
167
136
|
if (typeof wanted !== 'string') {
|
|
168
137
|
throw new Error('readFileSync mock supports only string parameters');
|
|
169
138
|
}
|
|
170
139
|
return this.readMockFileSync(wanted);
|
|
171
|
-
}), jest.spyOn(
|
|
140
|
+
}), jest.spyOn(fsToMock, 'writeFileSync').mockImplementation((wanted, payload) => {
|
|
172
141
|
if (typeof wanted !== 'string' || typeof payload !== 'string') {
|
|
173
142
|
throw new Error('writeFileSync mock supports only string parameters');
|
|
174
143
|
}
|
package/lib/index.js
CHANGED
|
@@ -41,7 +41,6 @@ const matchers_1 = __importDefault(require("./matchers"));
|
|
|
41
41
|
require("./types");
|
|
42
42
|
const MockFs = __importStar(require("./helpers/fsHelpers"));
|
|
43
43
|
exports.MockFs = MockFs;
|
|
44
|
-
// eslint-disable-next-line no-undef
|
|
45
44
|
function isJestGlobal(g) {
|
|
46
45
|
return g.hasOwnProperty('expect');
|
|
47
46
|
}
|
|
@@ -50,11 +49,9 @@ if (isJestGlobal(global)) {
|
|
|
50
49
|
global.expect.extend(matchers_1.default);
|
|
51
50
|
}
|
|
52
51
|
else {
|
|
53
|
-
/* eslint-disable no-console */
|
|
54
52
|
console.error([
|
|
55
53
|
"Unable to find Jest's global expect",
|
|
56
54
|
'Please check that you have added ts-utils-jest correctly to your jest configuration.'
|
|
57
55
|
].join('\n'));
|
|
58
|
-
/* eslint-enable no-console */
|
|
59
56
|
}
|
|
60
57
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
4
|
const predicate_1 = require("./predicate");
|
|
5
5
|
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
6
6
|
const matcherHelpers_1 = require("../../utils/matcherHelpers");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.matcherName = void 0;
|
|
4
4
|
exports.predicate = predicate;
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unused-vars
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
6
6
|
const ts_utils_1 = require("../../ts-utils");
|
|
7
7
|
exports.matcherName = 'toFailTest';
|
|
8
8
|
function predicate(cb) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
4
|
const jest_snapshot_1 = require("jest-snapshot");
|
|
5
5
|
const predicate_1 = require("./predicate");
|
|
6
6
|
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
7
|
+
const colorHelpers_1 = require("../../utils/colorHelpers");
|
|
7
8
|
exports.default = {
|
|
8
9
|
toFailTestAndMatchSnapshot: function (cb) {
|
|
9
10
|
const context = this;
|
|
@@ -20,7 +21,7 @@ exports.default = {
|
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
return jest_snapshot_1.toMatchSnapshot.call(context, cbResult.value, 'toFailTestAndMatchSnapshot');
|
|
24
|
+
return jest_snapshot_1.toMatchSnapshot.call(context, (0, colorHelpers_1.stripAnsiColors)(cbResult.value), 'toFailTestAndMatchSnapshot');
|
|
24
25
|
}
|
|
25
26
|
};
|
|
26
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.matcherName = void 0;
|
|
4
4
|
exports.predicate = predicate;
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unused-vars
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
6
6
|
const ts_utils_1 = require("../../ts-utils");
|
|
7
7
|
exports.matcherName = 'toFailTestAndMatchSnapshot';
|
|
8
8
|
function predicate(cb) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.matcherName = void 0;
|
|
4
4
|
exports.predicate = predicate;
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unused-vars
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
6
6
|
const expect_utils_1 = require("@jest/expect-utils");
|
|
7
7
|
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
8
8
|
const ts_utils_1 = require("../../ts-utils");
|
package/lib/tsdoc-metadata.json
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for handling ANSI color codes in test output.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Strips ANSI color/style escape sequences from a string.
|
|
8
|
+
*
|
|
9
|
+
* This function removes all ANSI escape sequences commonly used for
|
|
10
|
+
* terminal colors and text styling, making the output suitable for
|
|
11
|
+
* color-agnostic snapshot testing.
|
|
12
|
+
*
|
|
13
|
+
* @param text - The text that may contain ANSI escape sequences
|
|
14
|
+
* @returns The text with all ANSI escape sequences removed
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const coloredText = '\u001b[31mError:\u001b[39m Something failed';
|
|
19
|
+
* const plainText = stripAnsiColors(coloredText);
|
|
20
|
+
* console.log(plainText); // "Error: Something failed"
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Common usage in Jest matchers
|
|
26
|
+
* const formattedOutput = matcherUtils.printReceived(value);
|
|
27
|
+
* const cleanOutput = stripAnsiColors(formattedOutput);
|
|
28
|
+
* expect(cleanOutput).toMatchSnapshot();
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare function stripAnsiColors(text: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a wrapper function that strips ANSI colors from any string-returning function.
|
|
36
|
+
*
|
|
37
|
+
* This is useful for wrapping Jest matcher utility functions to make them
|
|
38
|
+
* color-agnostic for snapshot testing.
|
|
39
|
+
*
|
|
40
|
+
* @param fn - A function that returns a string (potentially with ANSI colors)
|
|
41
|
+
* @returns A wrapped function that returns the same string with colors stripped
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { printReceived } from 'jest-matcher-utils';
|
|
46
|
+
*
|
|
47
|
+
* const printReceivedClean = createColorStripWrapper(printReceived);
|
|
48
|
+
* const output = printReceivedClean(someValue); // No colors
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export declare function createColorStripWrapper<T extends (...args: unknown[]) => string>(fn: T): T;
|
|
54
|
+
//# sourceMappingURL=colorHelpers.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utility functions for handling ANSI color codes in test output.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.stripAnsiColors = stripAnsiColors;
|
|
9
|
+
exports.createColorStripWrapper = createColorStripWrapper;
|
|
10
|
+
/**
|
|
11
|
+
* Regular expression to match ANSI color/style escape sequences.
|
|
12
|
+
*
|
|
13
|
+
* This matches:
|
|
14
|
+
* - ESC character (ASCII 27) followed by `[`
|
|
15
|
+
* - `[0-9;]*` - Zero or more digits and semicolons (parameters)
|
|
16
|
+
* - `[a-zA-Z]` - Single letter command (m for SGR, K for erase, etc.)
|
|
17
|
+
*
|
|
18
|
+
* Examples of what this matches:
|
|
19
|
+
* - `\u001b[31m` - Red foreground
|
|
20
|
+
* - `\u001b[39m` - Default foreground
|
|
21
|
+
* - `\u001b[2m` - Dim/faint
|
|
22
|
+
* - `\u001b[22m` - Normal intensity
|
|
23
|
+
*
|
|
24
|
+
* Using a pre-compiled regex literal to satisfy ESLint security requirements.
|
|
25
|
+
* We use the unicode escape sequence \\u001b instead of \\x1b to avoid control-regex warnings.
|
|
26
|
+
*/
|
|
27
|
+
// eslint-disable-next-line no-control-regex
|
|
28
|
+
const ANSI_COLOR_REGEX = /\u001b\[[0-9;]*[a-zA-Z]/g;
|
|
29
|
+
/**
|
|
30
|
+
* Strips ANSI color/style escape sequences from a string.
|
|
31
|
+
*
|
|
32
|
+
* This function removes all ANSI escape sequences commonly used for
|
|
33
|
+
* terminal colors and text styling, making the output suitable for
|
|
34
|
+
* color-agnostic snapshot testing.
|
|
35
|
+
*
|
|
36
|
+
* @param text - The text that may contain ANSI escape sequences
|
|
37
|
+
* @returns The text with all ANSI escape sequences removed
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const coloredText = '\u001b[31mError:\u001b[39m Something failed';
|
|
42
|
+
* const plainText = stripAnsiColors(coloredText);
|
|
43
|
+
* console.log(plainText); // "Error: Something failed"
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Common usage in Jest matchers
|
|
49
|
+
* const formattedOutput = matcherUtils.printReceived(value);
|
|
50
|
+
* const cleanOutput = stripAnsiColors(formattedOutput);
|
|
51
|
+
* expect(cleanOutput).toMatchSnapshot();
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
function stripAnsiColors(text) {
|
|
57
|
+
return text.replace(ANSI_COLOR_REGEX, '');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a wrapper function that strips ANSI colors from any string-returning function.
|
|
61
|
+
*
|
|
62
|
+
* This is useful for wrapping Jest matcher utility functions to make them
|
|
63
|
+
* color-agnostic for snapshot testing.
|
|
64
|
+
*
|
|
65
|
+
* @param fn - A function that returns a string (potentially with ANSI colors)
|
|
66
|
+
* @returns A wrapped function that returns the same string with colors stripped
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* import { printReceived } from 'jest-matcher-utils';
|
|
71
|
+
*
|
|
72
|
+
* const printReceivedClean = createColorStripWrapper(printReceived);
|
|
73
|
+
* const output = printReceivedClean(someValue); // No colors
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
function createColorStripWrapper(fn) {
|
|
79
|
+
return ((...args) => {
|
|
80
|
+
const result = fn(...args);
|
|
81
|
+
return stripAnsiColors(result);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=colorHelpers.js.map
|
|
@@ -5,8 +5,12 @@ exports.printExpectedDetailedResult = printExpectedDetailedResult;
|
|
|
5
5
|
exports.printReceivedResult = printReceivedResult;
|
|
6
6
|
exports.printReceivedDetailedResult = printReceivedDetailedResult;
|
|
7
7
|
const jest_matcher_utils_1 = require("jest-matcher-utils");
|
|
8
|
+
const colorHelpers_1 = require("./colorHelpers");
|
|
9
|
+
// Create color-stripped versions of Jest matcher utilities
|
|
10
|
+
const printExpectedClean = (0, colorHelpers_1.createColorStripWrapper)(jest_matcher_utils_1.printExpected);
|
|
11
|
+
const printReceivedClean = (0, colorHelpers_1.createColorStripWrapper)(jest_matcher_utils_1.printReceived);
|
|
8
12
|
function printExpectedValue(outcome, expected) {
|
|
9
|
-
return expected !== undefined ? ` ${outcome} with ${(
|
|
13
|
+
return expected !== undefined ? ` ${outcome} with ${printExpectedClean(expected)}` : ` ${outcome}`;
|
|
10
14
|
}
|
|
11
15
|
function printExpectedResult(expect, isNot, expected) {
|
|
12
16
|
return [
|
|
@@ -31,14 +35,14 @@ function printExpectedDetailedResult(expect, isNot, expectedMessage, expectedDet
|
|
|
31
35
|
: expect === 'success'
|
|
32
36
|
? printExpectedValue('Not success', expectedMessage)
|
|
33
37
|
: printExpectedValue('Not failure', expectedMessage),
|
|
34
|
-
` Detail: "${(
|
|
38
|
+
` Detail: "${printExpectedClean(expectedDetail)}"`
|
|
35
39
|
].join('\n');
|
|
36
40
|
}
|
|
37
41
|
function printReceivedResult(received) {
|
|
38
42
|
return [
|
|
39
43
|
'Received:',
|
|
40
44
|
received.isSuccess()
|
|
41
|
-
? ` Success with ${(
|
|
45
|
+
? ` Success with ${printReceivedClean(received.value)}`
|
|
42
46
|
: ` Failure with "${received.message}"`
|
|
43
47
|
].join('\n');
|
|
44
48
|
}
|
|
@@ -46,8 +50,8 @@ function printReceivedDetailedResult(received) {
|
|
|
46
50
|
return [
|
|
47
51
|
'Received:',
|
|
48
52
|
received.isSuccess()
|
|
49
|
-
? ` Success with "${(
|
|
50
|
-
: ` Failure with "${received.message}"\n Detail: "${(
|
|
53
|
+
? ` Success with "${printReceivedClean(received.value)}"\n Detail: "${printReceivedClean(received.detail)}"`
|
|
54
|
+
: ` Failure with "${received.message}"\n Detail: "${printReceivedClean(received.detail)}"`
|
|
51
55
|
].join('\n');
|
|
52
56
|
}
|
|
53
57
|
//# sourceMappingURL=matcherHelpers.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-utils-jest",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.1-0",
|
|
4
4
|
"description": "Custom matchers for ts-utils result class",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -23,29 +23,29 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/jest": "^29.5.14",
|
|
25
25
|
"@types/node": "^20.14.9",
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
27
|
-
"@typescript-eslint/parser": "^
|
|
28
|
-
"eslint": "^
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^8.42.0",
|
|
27
|
+
"@typescript-eslint/parser": "^8.42.0",
|
|
28
|
+
"eslint": "^9.35.0",
|
|
29
29
|
"eslint-plugin-import": "^2.32.0",
|
|
30
30
|
"eslint-plugin-node": "^11.1.0",
|
|
31
|
-
"eslint-plugin-promise": "^
|
|
31
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
32
32
|
"jest": "^29.7.0",
|
|
33
33
|
"prettier": "^3.6.2",
|
|
34
|
-
"rimraf": "^
|
|
35
|
-
"ts-jest": "^29.4.
|
|
34
|
+
"rimraf": "^6.0.1",
|
|
35
|
+
"ts-jest": "^29.4.1",
|
|
36
36
|
"ts-node": "^10.9.2",
|
|
37
|
-
"typescript": "
|
|
38
|
-
"@rushstack/heft": "
|
|
39
|
-
"@rushstack/eslint-config": "
|
|
40
|
-
"@rushstack/heft-jest-plugin": "
|
|
41
|
-
"@rushstack/heft-node-rig": "
|
|
37
|
+
"typescript": "5.8.3",
|
|
38
|
+
"@rushstack/heft": "0.74.4",
|
|
39
|
+
"@rushstack/eslint-config": "4.4.0",
|
|
40
|
+
"@rushstack/heft-jest-plugin": "0.16.13",
|
|
41
|
+
"@rushstack/heft-node-rig": "2.9.5",
|
|
42
42
|
"@types/heft-jest": "1.0.6",
|
|
43
|
-
"eslint-plugin-n": "^
|
|
43
|
+
"eslint-plugin-n": "^17.21.3",
|
|
44
44
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
45
|
-
"@fgv/ts-utils": "5.0.0
|
|
45
|
+
"@fgv/ts-utils": "5.0.1-0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@fgv/ts-utils": "5.0.0
|
|
48
|
+
"@fgv/ts-utils": "5.0.1-0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "heft build --clean",
|
package/CHANGELOG.md
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# Change Log - @fgv/ts-utils-jest
|
|
2
|
-
|
|
3
|
-
This log was last generated on Thu, 17 Jul 2025 00:13:24 GMT and should not be manually modified.
|
|
4
|
-
|
|
5
|
-
## 5.0.0
|
|
6
|
-
Thu, 17 Jul 2025 00:13:24 GMT
|
|
7
|
-
|
|
8
|
-
### Updates
|
|
9
|
-
|
|
10
|
-
- minor fixes
|
|
11
|
-
- bump version
|
|
12
|
-
|
|
13
|
-
## 4.6.0
|
|
14
|
-
Wed, 02 Jul 2025 05:48:16 GMT
|
|
15
|
-
|
|
16
|
-
_Version update only_
|
|
17
|
-
|
|
18
|
-
## 4.5.1
|
|
19
|
-
Wed, 02 Jul 2025 05:47:11 GMT
|
|
20
|
-
|
|
21
|
-
### Updates
|
|
22
|
-
|
|
23
|
-
- update rushstack
|
|
24
|
-
|
|
25
|
-
## 4.5.0
|
|
26
|
-
Tue, 01 Jul 2025 03:26:11 GMT
|
|
27
|
-
|
|
28
|
-
_Version update only_
|
|
29
|
-
|
|
30
|
-
## 4.4.0
|
|
31
|
-
Sat, 01 Feb 2025 17:13:10 GMT
|
|
32
|
-
|
|
33
|
-
_Version update only_
|
|
34
|
-
|
|
35
|
-
## 4.3.0
|
|
36
|
-
Thu, 30 Jan 2025 00:35:17 GMT
|
|
37
|
-
|
|
38
|
-
_Version update only_
|
|
39
|
-
|
|
40
|
-
## 4.2.2
|
|
41
|
-
Thu, 23 Jan 2025 06:19:32 GMT
|
|
42
|
-
|
|
43
|
-
_Version update only_
|
|
44
|
-
|
|
45
|
-
## 4.2.1
|
|
46
|
-
Tue, 21 Jan 2025 04:19:21 GMT
|
|
47
|
-
|
|
48
|
-
_Version update only_
|
|
49
|
-
|
|
50
|
-
## 4.2.0
|
|
51
|
-
Mon, 20 Jan 2025 09:46:53 GMT
|
|
52
|
-
|
|
53
|
-
_Version update only_
|
|
54
|
-
|
|
55
|
-
## 4.1.0
|
|
56
|
-
Thu, 09 Jan 2025 05:33:39 GMT
|
|
57
|
-
|
|
58
|
-
### Updates
|
|
59
|
-
|
|
60
|
-
- update dependencies
|
|
61
|
-
|
|
62
|
-
## 4.0.2
|
|
63
|
-
Tue, 14 May 2024 14:45:53 GMT
|
|
64
|
-
|
|
65
|
-
_Version update only_
|
|
66
|
-
|
|
67
|
-
## 4.0.1
|
|
68
|
-
Tue, 14 May 2024 05:02:20 GMT
|
|
69
|
-
|
|
70
|
-
### Updates
|
|
71
|
-
|
|
72
|
-
- publish
|
|
73
|
-
|
|
74
|
-
## 4.0.0
|
|
75
|
-
Tue, 14 May 2024 03:09:27 GMT
|
|
76
|
-
|
|
77
|
-
### Updates
|
|
78
|
-
|
|
79
|
-
- update dependencies
|
|
80
|
-
|
|
81
|
-
## 3.0.0
|
|
82
|
-
Mon, 22 Jan 2024 07:00:18 GMT
|
|
83
|
-
|
|
84
|
-
### Updates
|
|
85
|
-
|
|
86
|
-
- gitignore tweaks
|
|
87
|
-
- fix types for ts-utils-jest
|
|
88
|
-
- fix peers
|
|
89
|
-
- bump versions
|
|
90
|
-
- cleanup
|
|
91
|
-
- Update dependencies
|
|
92
|
-
- bump dependencies, fix tests
|
|
93
|
-
- version upgrades
|
|
94
|
-
- update dependencies
|
|
95
|
-
- update peer dependencies
|
|
96
|
-
- bump version
|
|
97
|
-
|
|
98
|
-
## 2.0.0
|
|
99
|
-
Mon, 10 Apr 2023 03:33:11 GMT
|
|
100
|
-
|
|
101
|
-
### Breaking changes
|
|
102
|
-
|
|
103
|
-
- initial checking
|
|
104
|
-
- refactor
|
|
105
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fsHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/fsHelpers.ts"],"names":[],"mappings":"AAyBA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB,SAAgB,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC;IACvC,SAAgB,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC;gBAErB,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW;IAK3D,KAAK,IAAI,I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oD,CAAC,CAAC;YACxE,CAAC;YACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AAxGD,wCAwGC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport fs from 'fs';\nimport * as path from 'path';\n\n/**\n * @public\n */\nexport interface IMockFileConfig {\n path: string;\n backingFile?: string;\n payload?: string;\n writable?: boolean;\n}\n\n/**\n * @public\n */\nexport class ReadWriteSpies {\n public readonly read: jest.SpyInstance;\n public readonly write: jest.SpyInstance;\n\n public constructor(read: jest.SpyInstance, write: jest.SpyInstance) {\n this.read = read;\n this.write = write;\n }\n\n public clear(): void {\n this.read.mockClear();\n this.write.mockClear();\n }\n\n public restore(): void {\n this.read.mockRestore();\n this.write.mockRestore();\n }\n}\n\n/**\n * @public\n */\nexport interface IMockFileSystemOptions {\n mockWriteOnly?: boolean;\n allowUnknownMockWrite?: boolean;\n}\n\n/**\n * @public\n */\n// eslint-disable-next-line @rushstack/no-new-null\ntype ReadFunc = (\n path: string | number | Buffer | URL,\n // eslint-disable-next-line @rushstack/no-new-null\n options?: { encoding?: null; flag?: string } | null\n) => Buffer;\n\n/**\n * @public\n */\nexport class MockFileSystem {\n protected readonly _options?: IMockFileSystemOptions;\n protected readonly _config: Map<string, IMockFileConfig>;\n protected readonly _data: Map<string, string>;\n protected readonly _realReadFileSync: ReadFunc;\n protected readonly _extraWrites: string[] = [];\n\n public constructor(configs: Iterable<IMockFileConfig>, options?: IMockFileSystemOptions) {\n this._config = new Map<string, IMockFileConfig>();\n this._data = new Map<string, string>();\n this._options = options;\n this._realReadFileSync = fs.readFileSync;\n\n for (const config of configs) {\n const fullPath = path.resolve(config.path);\n this._config.set(fullPath, config);\n if (config.backingFile) {\n this.readMockFileSync(fullPath);\n } else if (config.payload) {\n this._data.set(fullPath, config.payload);\n }\n }\n }\n\n public readMockFileSync(wanted: string): string {\n const fullPathWanted = path.resolve(wanted);\n if (!this._data.has(fullPathWanted)) {\n const config = this._config.get(fullPathWanted);\n if (config?.backingFile === undefined) {\n if (this._options?.mockWriteOnly !== true) {\n throw new Error(`Mock file not found: ${wanted}`);\n }\n const body = this._realReadFileSync(fullPathWanted).toString();\n this._data.set(fullPathWanted, body);\n } else {\n const fullBackingPath = path.resolve(config.backingFile);\n const body = this._realReadFileSync(fullBackingPath).toString();\n this._data.set(fullPathWanted, body);\n }\n }\n\n const payload = this._data.get(fullPathWanted);\n // not actually reproducible right now\n /* c8 ignore next 3 */\n if (payload === undefined) {\n throw new Error(`Mock file ${wanted} payload is undefined.`);\n }\n return payload;\n }\n\n public writeMockFileSync(wanted: string, body: string): void {\n const fullPathWanted = path.resolve(wanted);\n const config = this._config.get(fullPathWanted);\n if (config === undefined) {\n if (this._options?.allowUnknownMockWrite !== true) {\n throw new Error(`Mock path not found: ${wanted}`);\n }\n this._extraWrites.push(fullPathWanted);\n } else if (config.writable !== true) {\n throw new Error(`Mock permission denied: ${wanted}`);\n }\n this._data.set(fullPathWanted, body);\n }\n\n public getExtraFilesWritten(): string[] {\n return Array.from(this._extraWrites);\n }\n public tryGetPayload(want: string): string | undefined {\n return this._data.get(path.resolve(want));\n }\n\n public reset(): void {\n const writable = Array.from(this._config.values()).filter((c) => c.writable === true);\n for (const config of writable) {\n this._data.delete(path.resolve(config.path));\n if (config.backingFile) {\n this.readMockFileSync(path.resolve(config.path));\n } else if (config.payload) {\n this._data.set(path.resolve(config.path), config.payload);\n }\n }\n\n for (const path of this._extraWrites) {\n this._data.delete(path);\n }\n this._extraWrites.splice(0, this._extraWrites.length);\n }\n\n public startSpies(): ReadWriteSpies {\n return new ReadWriteSpies(\n jest.spyOn(fs, 'readFileSync').mockImplementation((wanted: unknown) => {\n if (typeof wanted !== 'string') {\n throw new Error('readFileSync mock supports only string parameters');\n }\n return this.readMockFileSync(wanted);\n }),\n jest.spyOn(fs, 'writeFileSync').mockImplementation((wanted: unknown, payload: unknown) => {\n if (typeof wanted !== 'string' || typeof payload !== 'string') {\n throw new Error('writeFileSync mock supports only string parameters');\n }\n return this.writeMockFileSync(wanted, payload);\n })\n );\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/lib/helpers/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B","sourcesContent":["export * from './fsHelpers';\n"]}
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,CAAC;AAEjB,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAkC;AAClC,mBAAiB;AAEjB,4DAA8C;AACrC,wBAAM;AAKf,oCAAoC;AACpC,SAAS,YAAY,CAAC,CAAgB;IACpC,OAAO,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED,oBAAoB;AACpB,IAAI,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAQ,CAAC,CAAC;AACjC,CAAC;KAAM,CAAC;IACN,+BAA+B;IAC/B,OAAO,CAAC,KAAK,CACX;QACE,qCAAqC;QACrC,sFAAsF;KACvF,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACF,8BAA8B;AAChC,CAAC","sourcesContent":["import matchers from './matchers';\nimport './types';\n\nimport * as MockFs from './helpers/fsHelpers';\nexport { MockFs };\n\n// eslint-disable-next-line no-undef\ntype JestGlobal = typeof global & { expect: jest.Expect };\n\n// eslint-disable-next-line no-undef\nfunction isJestGlobal(g: typeof global): g is JestGlobal {\n return g.hasOwnProperty('expect');\n}\n\n/* c8 ignore else */\nif (isJestGlobal(global)) {\n global.expect.extend(matchers);\n} else {\n /* eslint-disable no-console */\n console.error(\n [\n \"Unable to find Jest's global expect\",\n 'Please check that you have added ts-utils-jest correctly to your jest configuration.'\n ].join('\\n')\n );\n /* eslint-enable no-console */\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/matchers/index.ts"],"names":[],"mappings":";8OA6B81B,KAAM,mBAAmB;sJAAxd,KAAM,mBAAmB;mCAA+c,KAAM,cAAc,sFAAsE,KAAM,mBAAmB;yCARx+B,KAAM,cAAc,kDAE9B,KAAM,mBAAmB;+CAAhB,KAAM,cAAc,gFAGhC,KAAM,mBACD;mEAE2B,KAAM,mBAAmB;sDAAyzD,KAAM,IAAI,wBAA4B,KAAM,mBAAmB;sNAAvnC,KAAM,mBAAmB;2GAA9gB,KAAM,mBAAmB;iFAA8S,KAAM,mBAAmB;0CAXxqB,KAAI,cAAc,qBAEb,KAAM,mBACJ;uCAQ2D,KAAM,mBAAmB;gFAAjB,KAAM,mBAAmB;;AAfrG,wBAcE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/matchers/index.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAC9B,8DAAsC;AACtC,8FAAsE;AACtE,sEAA8C;AAC9C,8DAAsC;AACtC,0EAAkD;AAClD,oHAA4F;AAC5F,4DAAoC;AACpC,wGAAgF;AAChF,4FAAoE;AACpE,gFAAwD;AACxD,oEAA4C;AAC5C,gFAAwD;AAExD,4MACK,gBAAM,GACN,oBAAU,GACV,oCAA0B,GAC1B,wBAAc,GACd,oBAAU,GACV,0BAAgB,GAChB,+CAAqC,GACrC,mBAAS,GACT,yCAA+B,GAC/B,mCAAyB,GACzB,6BAAmB,GACnB,uBAAa,GACb,6BAAmB,EACtB","sourcesContent":["import ToFail from './toFail';\nimport ToFailTest from './toFailTest';\nimport ToFailTestAndMatchSnapshot from './toFailTestAndMatchSnapshot';\nimport ToFailTestWith from './toFailTestWith';\nimport ToFailWith from './toFailWith';\nimport ToFailWithDetail from './toFailWithDetail';\nimport ToHaveBeenCalledWithArgumentsMatching from './toHaveBeenCalledWithArgumentsMatching';\nimport ToSucceed from './toSucceed';\nimport ToSucceedAndMatchInlineSnapshot from './toSucceedAndMatchInlineSnapshot';\nimport ToSucceedAndMatchSnapshot from './toSucceedAndMatchSnapshot';\nimport ToSucceedAndSatisfy from './toSucceedAndSatisfy';\nimport ToSucceedWith from './toSucceedWith';\nimport toSucceedWithDetail from './toSucceedWithDetail';\n\nexport default {\n ...ToFail,\n ...ToFailTest,\n ...ToFailTestAndMatchSnapshot,\n ...ToFailTestWith,\n ...ToFailWith,\n ...ToFailWithDetail,\n ...ToHaveBeenCalledWithArgumentsMatching,\n ...ToSucceed,\n ...ToSucceedAndMatchInlineSnapshot,\n ...ToSucceedAndMatchSnapshot,\n ...ToSucceedAndSatisfy,\n ...ToSucceedWith,\n ...toSucceedWithDetail\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFail/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;eAEG;YACH,MAAM,IAAI,CAAC,CAAC;SACb;KACF;CACF;;aAmBmB,CAAC,SAAS,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAG,IAAI,CAAC,mBAAmB;;AADrF,wBASE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toFail/index.ts"],"names":[],"mappings":";;AAAA,+DAAsF;AACtF,2CAAqD;AAGrD,2DAAiD;AAejD,SAAS,WAAW,CAA4B,QAAW;IACzD,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,QAAQ,uBAAW,EAAE,CAAC;QAClC,IAAA,oCAAmB,EAAC,SAAS,EAAE,KAAK,CAAC;QACrC,IAAA,oCAAmB,EAAC,QAAQ,CAAC;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAA4B,QAAW;IACzD,OAAO,GAAG,EAAE,CACV,CAAC,IAAA,gCAAW,EAAC,GAAG,uBAAW,EAAE,CAAC,EAAE,IAAA,oCAAmB,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,IAAA,oCAAmB,EAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CACvG,IAAI,CACL,CAAC;AACN,CAAC;AAED,kBAAe;IACb,MAAM,EAAE,UAAqC,QAAW;QACtD,MAAM,IAAI,GAAG,IAAA,qBAAS,EAAC,QAAQ,CAAC,CAAC;QACjC,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;IACzD,CAAC;CACF,CAAC","sourcesContent":["import { printExpectedResult, printReceivedResult } from '../../utils/matcherHelpers';\nimport { matcherName, predicate } from './predicate';\n\nimport { Result } from '@fgv/ts-utils';\nimport { matcherHint } from 'jest-matcher-utils';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toFail to verify that a Result<T> is a failure\n */\n toFail(): R;\n }\n }\n}\n\nfunction passMessage<T extends Result<unknown>>(received: T): () => string {\n return () =>\n [\n matcherHint(`.not.${matcherName}`),\n printExpectedResult('failure', false),\n printReceivedResult(received)\n ].join('\\n');\n}\n\nfunction failMessage<T extends Result<unknown>>(received: T): () => string {\n return () =>\n [matcherHint(`${matcherName}`), printExpectedResult('failure', true), printReceivedResult(received)].join(\n '\\n'\n );\n}\n\nexport default {\n toFail: function <T extends Result<unknown>>(received: T): jest.CustomMatcherResult {\n const pass = predicate(received);\n if (pass) {\n return { pass: true, message: passMessage(received) };\n }\n\n return { pass: false, message: failMessage(received) };\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFail/predicate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,eAAO,MAAM,WAAW,EAAE,MAAiB,CAAC;AAE5C,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAEzD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toFail/predicate.ts"],"names":[],"mappings":";;;AAIA,8BAEC;AAJY,QAAA,WAAW,GAAW,QAAQ,CAAC;AAE5C,SAAgB,SAAS,CAAI,QAAmB;IAC9C,OAAO,QAAQ,CAAC,SAAS,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import { Result } from '../../ts-utils';\n\nexport const matcherName: string = 'toFail';\n\nexport function predicate<T>(received: Result<T>): boolean {\n return received.isFailure();\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFailTest/index.ts"],"names":[],"mappings":"AAMA,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;;eAGG;YACH,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC;SACpB;KACF;CACF;;iBAqBuB,CAAC,MAAM,MAAM,IAAI,KAAG,IAAI,CAAC,mBAAmB;;AADpE,wBASE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toFailTest/index.ts"],"names":[],"mappings":";;AAAA,qEAAqE;AACrE,2CAAqD;AAErD,2DAAiD;AACjD,+DAAiE;AAgBjE,SAAS,WAAW;IAClB,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,QAAQ,uBAAW,EAAE,EAAE,UAAU,CAAC;QAC9C,IAAA,oCAAmB,EAAC,SAAS,EAAE,KAAK,CAAC;QACrC,yBAAyB;KAC1B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,SAAS,WAAW;IAClB,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,GAAG,uBAAW,EAAE,EAAE,UAAU,CAAC;QACzC,IAAA,oCAAmB,EAAC,SAAS,EAAE,IAAI,CAAC;QACpC,yBAAyB;KAC1B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,kBAAe;IACb,UAAU,EAAE,UAAa,EAAc;QACrC,MAAM,IAAI,GAAG,IAAA,qBAAS,EAAC,EAAE,CAAC,CAAC;QAC3B,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC;QAChD,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC;IACjD,CAAC;CACF,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */\nimport { matcherName, predicate } from './predicate';\n\nimport { matcherHint } from 'jest-matcher-utils';\nimport { printExpectedResult } from '../../utils/matcherHelpers';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toFailTest to test a custom matcher by\n * verifying that a test case fails.\n */\n toFailTest<T>(): R;\n }\n }\n}\n\nfunction passMessage<T>(): () => string {\n return () =>\n [\n matcherHint(`.not.${matcherName}`, 'callback'),\n printExpectedResult('failure', false),\n ' Received: Test failed'\n ].join('\\n');\n}\n\nfunction failMessage<T>(): () => string {\n return () =>\n [\n matcherHint(`${matcherName}`, 'callback'),\n printExpectedResult('failure', true),\n ' Received: Test passed'\n ].join('\\n');\n}\n\nexport default {\n toFailTest: function <T>(cb: () => void): jest.CustomMatcherResult {\n const pass = predicate(cb);\n if (pass) {\n return { pass: true, message: passMessage() };\n }\n\n return { pass: false, message: failMessage() };\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFailTest/predicate.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,EAAE,MAAqB,CAAC;AAEhD,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAGpD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toFailTest/predicate.ts"],"names":[],"mappings":";;;AAIA,8BAGC;AAPD,qEAAqE;AACrE,6CAA+C;AAClC,QAAA,WAAW,GAAW,YAAY,CAAC;AAEhD,SAAgB,SAAS,CAAI,EAAc;IACzC,MAAM,QAAQ,GAAG,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC,SAAS,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */\nimport { captureResult } from '../../ts-utils';\nexport const matcherName: string = 'toFailTest';\n\nexport function predicate<T>(cb: () => void): boolean {\n const cbResult = captureResult(() => cb());\n return cbResult.isFailure();\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFailTestAndMatchSnapshot/index.ts"],"names":[],"mappings":"AAMA,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;;;eAIG;YACH,0BAA0B,CAAC,CAAC,KAAK,CAAC,CAAC;SACpC;KACF;CACF;;iCAGuC,CAAC,QAC/B,IAAI,CAAC,cAAc,MACrB,MAAM,IAAI,KACb,IAAI,CAAC,mBAAmB;;AAJ7B,wBAyBE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toFailTestAndMatchSnapshot/index.ts"],"names":[],"mappings":";;AAAA,qEAAqE;AACrE,iDAAyD;AACzD,2CAAqD;AAErD,2DAAiD;AAiBjD,kBAAe;IACb,0BAA0B,EAAE,UAE1B,EAAc;QAEd,MAAM,OAAO,GAAG,IAA0B,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAA,qBAAS,EAAC,EAAE,CAAC,CAAC;QAC/B,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;YACzB,OAAO;gBACL,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,GAAW,EAAE;oBACpB,OAAO;wBACL,IAAA,gCAAW,EAAC,GAAG,uBAAW,EAAE,EAAE,UAAU,CAAC;wBACzC,kEAAkE;wBAClE,gCAAgC;qBACjC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACf,CAAC;aACF,CAAC;QACJ,CAAC;QACD,OAAO,+BAAe,CAAC,IAAI,CACzB,OAAO,EACP,QAAQ,CAAC,KAAK,EACd,4BAA4B,CACD,CAAC;IAChC,CAAC;CACF,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */\nimport { Context, toMatchSnapshot } from 'jest-snapshot';\nimport { matcherName, predicate } from './predicate';\n\nimport { matcherHint } from 'jest-matcher-utils';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toFailTestWith to test a custom matcher by\n * verifying that a test case fails as expected and\n * reports an error matching a stored snapshot.\n */\n toFailTestAndMatchSnapshot<T>(): R;\n }\n }\n}\n\nexport default {\n toFailTestAndMatchSnapshot: function <T>(\n this: jest.MatcherContext,\n cb: () => void\n ): jest.CustomMatcherResult {\n const context = this as unknown as Context;\n const cbResult = predicate(cb);\n if (cbResult.isFailure()) {\n return {\n pass: false,\n message: (): string => {\n return [\n matcherHint(`${matcherName}`, 'callback'),\n ' Expected: Callback to fail with an error that matches snapshot',\n ' Received: Callback succeeded'\n ].join('\\n');\n }\n };\n }\n return toMatchSnapshot.call(\n context,\n cbResult.value,\n 'toFailTestAndMatchSnapshot'\n ) as jest.CustomMatcherResult;\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFailTestAndMatchSnapshot/predicate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAgC,MAAM,gBAAgB,CAAC;AAEtE,eAAO,MAAM,WAAW,EAAE,MAAqC,CAAC;AAEhE,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAM3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toFailTestAndMatchSnapshot/predicate.ts"],"names":[],"mappings":";;;AAKA,8BAMC;AAXD,qEAAqE;AACrE,6CAAsE;AAEzD,QAAA,WAAW,GAAW,4BAA4B,CAAC;AAEhE,SAAgB,SAAS,CAAI,EAAc;IACzC,MAAM,QAAQ,GAAG,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;QACzB,OAAO,IAAA,kBAAO,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,IAAA,eAAI,EAAC,uBAAuB,CAAC,CAAC;AACvC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */\nimport { Result, captureResult, fail, succeed } from '../../ts-utils';\n\nexport const matcherName: string = 'toFailTestAndMatchSnapshot';\n\nexport function predicate<T>(cb: () => void): Result<string> {\n const cbResult = captureResult(() => cb());\n if (cbResult.isFailure()) {\n return succeed(cbResult.message);\n }\n return fail('Callback did not fail');\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFailTestWith/index.ts"],"names":[],"mappings":"AAOA,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;;;;eAKG;YACH,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,CAAC;SAC5D;KACF;CACF;;qBAuB2B,CAAC,MACrB,MAAM,IAAI,YACJ,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,KACnC,IAAI,CAAC,mBAAmB;;AAJ7B,wBAYE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toFailTestWith/index.ts"],"names":[],"mappings":";;AAEA,2CAAqD;AAErD,2DAAiD;AACjD,+DAAiE;AAkBjE,SAAS,WAAW,CAAI,QAAyB,EAAE,QAAoC;IACrF,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,QAAQ,uBAAW,EAAE,EAAE,UAAU,EAAE,iBAAiB,CAAC;QACjE,IAAA,oCAAmB,EAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC;QAC/C,4CAA4C,QAAQ,CAAC,KAAK,QAAQ;KACnE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAI,QAAyB,EAAE,QAAoC;IACrF,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,GAAG,uBAAW,EAAE,EAAE,UAAU,EAAE,iBAAiB,CAAC;QAC5D,IAAA,oCAAmB,EAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC;QAC9C,QAAQ,CAAC,OAAO,KAAK,EAAE;YACrB,CAAC,CAAC,gCAAgC;YAClC,CAAC,CAAC,4CAA4C,QAAQ,CAAC,OAAO,QAAQ;KACzE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,kBAAe;IACb,cAAc,EAAE,UACd,EAAc,EACd,QAAoC;QAEpC,MAAM,QAAQ,GAAG,IAAA,qBAAS,EAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QACzC,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;YACzB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;QAClE,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;IACnE,CAAC;CACF,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */\nimport { Failure, Success } from '../../ts-utils';\nimport { matcherName, predicate } from './predicate';\n\nimport { matcherHint } from 'jest-matcher-utils';\nimport { printExpectedResult } from '../../utils/matcherHelpers';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toFailTestWith to test a custom matcher by\n * verifying that a test case fails as expected and\n * reports an error matching a supplied value.\n * @param expected -\n */\n toFailTestWith<T>(expected: string | string[] | RegExp): R;\n }\n }\n}\n\nfunction passMessage<T>(cbResult: Success<string>, expected: RegExp | string | string[]): () => string {\n return () =>\n [\n matcherHint(`.not.${matcherName}`, 'callback', 'expectedMessage'),\n printExpectedResult('failure', false, expected),\n ` Received: Callback failed with:\\n>>>>\\n${cbResult.value}\\n<<<<`\n ].join('\\n');\n}\n\nfunction failMessage<T>(cbResult: Failure<string>, expected: RegExp | string | string[]): () => string {\n return () =>\n [\n matcherHint(`${matcherName}`, 'callback', 'expectedMessage'),\n printExpectedResult('failure', true, expected),\n cbResult.message === ''\n ? ' Received: Callback succeeded'\n : ` Received: Callback failed with:\\n>>>>\\n${cbResult.message}\\n<<<<`\n ].join('\\n');\n}\n\nexport default {\n toFailTestWith: function <T>(\n cb: () => void,\n expected: RegExp | string | string[]\n ): jest.CustomMatcherResult {\n const cbResult = predicate(cb, expected);\n if (cbResult.isSuccess()) {\n return { pass: true, message: passMessage(cbResult, expected) };\n }\n\n return { pass: false, message: failMessage(cbResult, expected) };\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFailTestWith/predicate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAgC,MAAM,gBAAgB,CAAC;AAEtE,eAAO,MAAM,WAAW,EAAE,MAAyB,CAAC;AAEpD,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAgBjG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toFailTestWith/predicate.ts"],"names":[],"mappings":";;;AAOA,8BAgBC;AAvBD,qEAAqE;AACrE,qDAA4C;AAC5C,2DAA+C;AAC/C,6CAAsE;AAEzD,QAAA,WAAW,GAAW,gBAAgB,CAAC;AAEpD,SAAgB,SAAS,CAAI,EAAc,EAAE,QAAoC;IAC/E,MAAM,QAAQ,GAAG,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;QACzB,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,IAAI,QAAQ,YAAY,MAAM,EAAE,CAAC;YAC/B,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;QACtD,CAAC;aAAM,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO,GAAG,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC;QAC1C,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,OAAO,GAAG,IAAA,qBAAM,EAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,OAAO,IAAA,eAAI,EAAC,+BAA+B,IAAA,8BAAS,EAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;QACxF,CAAC;QACD,OAAO,OAAO,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAA,eAAI,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,IAAA,eAAI,EAAC,EAAE,CAAC,CAAC;AAClB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */\nimport { equals } from '@jest/expect-utils';\nimport { stringify } from 'jest-matcher-utils';\nimport { Result, captureResult, fail, succeed } from '../../ts-utils';\n\nexport const matcherName: string = 'toFailTestWith';\n\nexport function predicate<T>(cb: () => void, expected: string | string[] | RegExp): Result<string> {\n const cbResult = captureResult(() => cb());\n if (cbResult.isFailure()) {\n let success = false;\n if (expected instanceof RegExp) {\n success = cbResult.message.match(expected) !== null;\n } else if (typeof expected === 'string') {\n success = cbResult.message === expected;\n } else if (Array.isArray(expected)) {\n success = equals(cbResult.message.split('\\n'), expected);\n } else {\n return fail(`Unsupported expected value \"${stringify(expected)}\" for toFailTestWith`);\n }\n return success ? succeed(cbResult.message) : fail(cbResult.message);\n }\n return fail('');\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFailWith/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;;;eAIG;YACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,CAAC,CAAC;SACrD;KACF;CACF;;iBAqBuB,CAAC,YACX,MAAM,CAAC,CAAC,CAAC,YACT,MAAM,GAAG,MAAM,GAAG,SAAS,KACpC,IAAI,CAAC,mBAAmB;;AAJ7B,wBAYE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toFailWith/index.ts"],"names":[],"mappings":";;AAAA,+DAAsF;AACtF,2CAAqD;AAGrD,2DAAiD;AAiBjD,SAAS,WAAW,CAAI,QAAmB,EAAE,QAAqC;IAChF,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,QAAQ,uBAAW,EAAE,CAAC;QAClC,IAAA,oCAAmB,EAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC;QAC/C,IAAA,oCAAmB,EAAC,QAAQ,CAAC;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAI,QAAmB,EAAE,QAAqC;IAChF,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,GAAG,uBAAW,EAAE,CAAC;QAC7B,IAAA,oCAAmB,EAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC;QAC9C,IAAA,oCAAmB,EAAC,QAAQ,CAAC;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,kBAAe;IACb,UAAU,EAAE,UACV,QAAmB,EACnB,QAAqC;QAErC,MAAM,IAAI,GAAG,IAAA,qBAAS,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC3C,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;QAClE,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;IACnE,CAAC;CACF,CAAC","sourcesContent":["import { printExpectedResult, printReceivedResult } from '../../utils/matcherHelpers';\nimport { matcherName, predicate } from './predicate';\n\nimport { Result } from '@fgv/ts-utils';\nimport { matcherHint } from 'jest-matcher-utils';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toFailWith to verify that a Result<T> is a failure\n * that matches a supplied string, RegExp or undefined value\n * @param message -\n */\n toFailWith(message: string | RegExp | undefined): R;\n }\n }\n}\n\nfunction passMessage<T>(received: Result<T>, expected: string | RegExp | undefined): () => string {\n return () =>\n [\n matcherHint(`.not.${matcherName}`),\n printExpectedResult('failure', false, expected),\n printReceivedResult(received)\n ].join('\\n');\n}\n\nfunction failMessage<T>(received: Result<T>, expected: string | RegExp | undefined): () => string {\n return () =>\n [\n matcherHint(`${matcherName}`),\n printExpectedResult('failure', true, expected),\n printReceivedResult(received)\n ].join('\\n');\n}\n\nexport default {\n toFailWith: function <T>(\n received: Result<T>,\n expected: string | RegExp | undefined\n ): jest.CustomMatcherResult {\n const pass = predicate(received, expected);\n if (pass) {\n return { pass: true, message: passMessage(received, expected) };\n }\n\n return { pass: false, message: failMessage(received, expected) };\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFailWith/predicate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,eAAO,MAAM,WAAW,EAAE,MAAqB,CAAC;AAEhD,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAWhG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toFailWith/predicate.ts"],"names":[],"mappings":";;;AAIA,8BAWC;AAbY,QAAA,WAAW,GAAW,YAAY,CAAC;AAEhD,SAAgB,SAAS,CAAI,QAAmB,EAAE,QAAqC;IACrF,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;QACzB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,QAAQ,CAAC,OAAO,KAAK,SAAS,CAAC;QACxC,CAAC;aAAM,IAAI,QAAQ,YAAY,MAAM,EAAE,CAAC;YACtC,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { Result } from '../../ts-utils';\n\nexport const matcherName: string = 'toFailWith';\n\nexport function predicate<T>(received: Result<T>, expected: string | RegExp | undefined): boolean {\n if (received.isFailure()) {\n if (expected === undefined) {\n return received.message === undefined;\n } else if (expected instanceof RegExp) {\n return received.message.match(expected) !== null;\n } else {\n return received.message === expected;\n }\n }\n return false;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFailWithDetail/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAOjE,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;;;;eAKG;YACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SACxF;KACF;CACF;;uBA6B6B,CAAC,SAAS,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,YAC1D,CAAC,mBACM,MAAM,GAAG,MAAM,GAAG,SAAS,kBAC5B,gBAAgB,CAAC,CAAC,CAAC,KAClC,IAAI,CAAC,mBAAmB;;AAL7B,wBAaE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toFailWithDetail/index.ts"],"names":[],"mappings":";;AACA,+DAAsG;AACtG,2CAAqD;AAErD,2DAAiD;AAmBjD,SAAS,WAAW,CAClB,QAA+B,EAC/B,eAA4C,EAC5C,cAAkB;IAElB,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,QAAQ,uBAAW,EAAE,CAAC;QAClC,IAAA,4CAA2B,EAAC,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc,CAAC;QAC9E,IAAA,4CAA2B,EAAC,QAAQ,CAAC;KACtC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAClB,QAA+B,EAC/B,eAA4C,EAC5C,cAAkB;IAElB,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,GAAG,uBAAW,EAAE,CAAC;QAC7B,IAAA,4CAA2B,EAAC,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,CAAC;QAC7E,IAAA,4CAA2B,EAAC,QAAQ,CAAC;KACtC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,kBAAe;IACb,gBAAgB,EAAE,UAChB,QAAW,EACX,eAA4C,EAC5C,cAAmC;QAEnC,MAAM,IAAI,GAAG,IAAA,qBAAS,EAAC,QAAQ,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;QAClE,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,eAAe,EAAE,cAAc,CAAC,EAAE,CAAC;QACzF,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,eAAe,EAAE,cAAc,CAAC,EAAE,CAAC;IAC1F,CAAC;CACF,CAAC","sourcesContent":["import { DetailedResult, ResultDetailType } from '@fgv/ts-utils';\nimport { printExpectedDetailedResult, printReceivedDetailedResult } from '../../utils/matcherHelpers';\nimport { matcherName, predicate } from './predicate';\n\nimport { matcherHint } from 'jest-matcher-utils';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toFailWithDetail to verify that a DetailedResult<T> is\n * a failure that matches both a supplied expected failure message\n * (string, RegExp or undefined) and a supplied failure detail.\n * @param message -\n */\n toFailWithDetail(message: string | RegExp | undefined, detail: ResultDetailType<T>): R;\n }\n }\n}\n\nfunction passMessage<T, TD>(\n received: DetailedResult<T, TD>,\n expectedMessage: string | RegExp | undefined,\n expectedDetail: TD\n): () => string {\n return () =>\n [\n matcherHint(`.not.${matcherName}`),\n printExpectedDetailedResult('failure', false, expectedMessage, expectedDetail),\n printReceivedDetailedResult(received)\n ].join('\\n');\n}\n\nfunction failMessage<T, TD>(\n received: DetailedResult<T, TD>,\n expectedMessage: string | RegExp | undefined,\n expectedDetail: TD\n): () => string {\n return () =>\n [\n matcherHint(`${matcherName}`),\n printExpectedDetailedResult('failure', true, expectedMessage, expectedDetail),\n printReceivedDetailedResult(received)\n ].join('\\n');\n}\n\nexport default {\n toFailWithDetail: function <T extends DetailedResult<unknown, unknown>>(\n received: T,\n expectedMessage: string | RegExp | undefined,\n expectedDetail: ResultDetailType<T>\n ): jest.CustomMatcherResult {\n const pass = predicate(received, expectedMessage, expectedDetail);\n if (pass) {\n return { pass: true, message: passMessage(received, expectedMessage, expectedDetail) };\n }\n\n return { pass: false, message: failMessage(received, expectedMessage, expectedDetail) };\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toFailWithDetail/predicate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,WAAW,EAAE,MAAqB,CAAC;AAEhD,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAC7B,QAAQ,EAAE,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,EAC/B,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAC3C,cAAc,EAAE,EAAE,GACjB,OAAO,CAiBT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toFailWithDetail/predicate.ts"],"names":[],"mappings":";;;AAKA,8BAqBC;AA1BD,qDAA4C;AAG/B,QAAA,WAAW,GAAW,YAAY,CAAC;AAEhD,SAAgB,SAAS,CACvB,QAA+B,EAC/B,cAA2C,EAC3C,cAAkB;IAElB,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;QACzB,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,QAAQ,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBACnC,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;aAAM,IAAI,cAAc,YAAY,MAAM,EAAE,CAAC;YAC5C,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC;gBACpD,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;aAAM,IAAI,QAAQ,CAAC,OAAO,KAAK,cAAc,EAAE,CAAC;YAC/C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAA,qBAAM,EAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { equals } from '@jest/expect-utils';\nimport { DetailedResult } from '../../ts-utils';\n\nexport const matcherName: string = 'toFailWith';\n\nexport function predicate<T, TD>(\n received: DetailedResult<T, TD>,\n expectedResult: string | RegExp | undefined,\n expectedDetail: TD\n): boolean {\n if (received.isFailure()) {\n if (expectedResult === undefined) {\n if (received.message !== undefined) {\n return false;\n }\n } else if (expectedResult instanceof RegExp) {\n if (received.message.match(expectedResult) === null) {\n return false;\n }\n } else if (received.message !== expectedResult) {\n return false;\n }\n\n return equals(received.detail, expectedDetail);\n }\n return false;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toHaveBeenCalledWithArgumentsMatching/index.ts"],"names":[],"mappings":"AAIA,OAAO,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Hint, printExpected, printReceived } from 'jest-matcher-utils';\nimport { IMatchedCall, matcherName, predicate } from './predicate';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R> {\n /**\n * Use .toSucceedWith to verify that a Result<T> is a success\n * and that the result value matches the supplied value\n * @param expected -\n */\n toHaveBeenCalledWithArgumentsMatching(expected: unknown): R;\n }\n }\n}\n\nfunction getRange(length: number, cursor: number): { start: number; end: number } {\n // less than 3 return everything\n if (length < 3) {\n return { start: 0, end: length };\n }\n\n if (cursor === 0) {\n return { start: 0, end: 3 };\n } else if (cursor >= length - 1) {\n return { start: length - 3, end: length };\n }\n return { start: cursor - 1, end: cursor + 2 };\n}\n\nfunction formatOneCall(index: number, received: unknown, cursor: boolean): string {\n const indexString = index.toLocaleString([], { maximumFractionDigits: 0, minimumIntegerDigits: 3 });\n const cursorString = cursor ? '*' : ' ';\n return `${cursorString}${indexString}: ${printReceived(received)}`;\n}\n\nfunction formatArgsMessage(received: jest.Mock, cursor?: number): string[] {\n const calls = received.mock.calls;\n\n if (calls.length > 0) {\n // if there's no cursor, show the last 3\n const { start, end } = getRange(calls.length, cursor !== undefined ? cursor : calls.length - 1);\n const callsToShow = calls.slice(start, end);\n return callsToShow.map((c, i) => formatOneCall(start + i, c, start + i === cursor));\n }\n return [];\n}\n\nfunction passMessage(received: jest.Mock, expected: unknown, matched: IMatchedCall): () => string {\n return () =>\n [\n matcherHint(`.not.${matcherName}`),\n 'Expected no call with arguments matching:',\n ` ${printExpected(expected)}`,\n `Received (${received.mock.calls.length} total):`,\n ...formatArgsMessage(received, matched.index)\n ].join('\\n');\n}\n\nfunction failMessage(received: jest.Mock, expected: unknown): () => string {\n return () =>\n [\n matcherHint(`${matcherName}`),\n 'Expected call with arguments matching:',\n ` ${printExpected(expected)}`,\n `Received (${received.mock.calls.length} total):`,\n ...formatArgsMessage(received)\n ].join('\\n');\n}\n\nfunction isMock(received: unknown): received is jest.Mock {\n if (received !== null && !Array.isArray(received)) {\n return (\n getValueOfPropertyOrDefault('_isMockFunction', received as object) === true &&\n getTypeOfProperty('mock', received as object) === 'object'\n );\n }\n return false;\n}\n\nexport default {\n toHaveBeenCalledWithArgumentsMatching: function (\n received: jest.Mock,\n expected: unknown\n ): jest.CustomMatcherResult {\n if (!isMock(received)) {\n throw new Error('Test error: toHaveBeenCalledWithArgumentsMatching called with other than jest.Mock');\n }\n\n const matched = predicate(received, expected);\n if (matched !== undefined) {\n return { pass: true, message: passMessage(received, expected, matched) };\n }\n\n return { pass: false, message: failMessage(received, expected) };\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toHaveBeenCalledWithArgumentsMatching/predicate.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,EAAE,MAAgD,CAAC;AAE3E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,EAAE,CAAC;CACtB;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,YAAY,CAQ1F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toHaveBeenCalledWithArgumentsMatching/predicate.ts"],"names":[],"mappings":";;;AASA,8BAQC;AAjBD,qDAA4C;AAE/B,QAAA,WAAW,GAAW,uCAAuC,CAAC;AAO3E,SAAgB,SAAS,CAAC,QAAmB,EAAE,QAAiB;IAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,IAAA,qBAAM,EAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;YAC3B,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { equals } from '@jest/expect-utils';\n\nexport const matcherName: string = 'toHaveBeenCalledWithArgumentsMatching';\n\nexport interface IMatchedCall {\n index: number;\n arguments: unknown[];\n}\n\nexport function predicate(received: jest.Mock, expected: unknown): undefined | IMatchedCall {\n for (let i = 0; i < received.mock.calls.length; i++) {\n const args = received.mock.calls[i];\n if (equals(args, expected)) {\n return { index: i, arguments: args };\n }\n }\n return undefined;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toSucceed/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;eAEG;YACH,SAAS,IAAI,CAAC,CAAC;SAChB;KACF;CACF;;gBAmBsB,CAAC,YAAY,MAAM,CAAC,CAAC,CAAC,KAAG,IAAI,CAAC,mBAAmB;;AADxE,wBASE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toSucceed/index.ts"],"names":[],"mappings":";;AAAA,+DAAsF;AACtF,2CAAqD;AAGrD,2DAAiD;AAejD,SAAS,WAAW,CAAI,QAAmB;IACzC,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,QAAQ,uBAAW,EAAE,CAAC;QAClC,IAAA,oCAAmB,EAAC,SAAS,EAAE,KAAK,CAAC;QACrC,IAAA,oCAAmB,EAAC,QAAQ,CAAC;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAI,QAAmB;IACzC,OAAO,GAAG,EAAE,CACV,CAAC,IAAA,gCAAW,EAAC,GAAG,uBAAW,EAAE,CAAC,EAAE,IAAA,oCAAmB,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,IAAA,oCAAmB,EAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CACvG,IAAI,CACL,CAAC;AACN,CAAC;AAED,kBAAe;IACb,SAAS,EAAE,UAAa,QAAmB;QACzC,MAAM,IAAI,GAAG,IAAA,qBAAS,EAAC,QAAQ,CAAC,CAAC;QACjC,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;IACzD,CAAC;CACF,CAAC","sourcesContent":["import { printExpectedResult, printReceivedResult } from '../../utils/matcherHelpers';\nimport { matcherName, predicate } from './predicate';\n\nimport { Result } from '@fgv/ts-utils';\nimport { matcherHint } from 'jest-matcher-utils';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toSucceed to verify that a Result<T> is a success\n */\n toSucceed(): R;\n }\n }\n}\n\nfunction passMessage<T>(received: Result<T>): () => string {\n return () =>\n [\n matcherHint(`.not.${matcherName}`),\n printExpectedResult('success', false),\n printReceivedResult(received)\n ].join('\\n');\n}\n\nfunction failMessage<T>(received: Result<T>): () => string {\n return () =>\n [matcherHint(`${matcherName}`), printExpectedResult('success', true), printReceivedResult(received)].join(\n '\\n'\n );\n}\n\nexport default {\n toSucceed: function <T>(received: Result<T>): jest.CustomMatcherResult {\n const pass = predicate(received);\n if (pass) {\n return { pass: true, message: passMessage(received) };\n }\n\n return { pass: false, message: failMessage(received) };\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toSucceed/predicate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,eAAO,MAAM,WAAW,EAAE,MAAoB,CAAC;AAE/C,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAEzD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toSucceed/predicate.ts"],"names":[],"mappings":";;;AAIA,8BAEC;AAJY,QAAA,WAAW,GAAW,WAAW,CAAC;AAE/C,SAAgB,SAAS,CAAI,QAAmB;IAC9C,OAAO,QAAQ,CAAC,SAAS,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import { Result } from '../../ts-utils';\n\nexport const matcherName: string = 'toSucceed';\n\nexport function predicate<T>(received: Result<T>): boolean {\n return received.isSuccess();\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toSucceedAndMatchInlineSnapshot/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAKvC,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;;eAGG;YACH,+BAA+B,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,CAAC,CAAC;SACrE;KACF;CACF;;sCAK4C,CAAC,QACpC,IAAI,CAAC,cAAc,YACf,MAAM,CAAC,CAAC,CAAC,YACT,MAAM,GAAG,SAAS,KAC3B,IAAI,CAAC,mBAAmB;;AAL7B,wBAqBE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toSucceedAndMatchInlineSnapshot/index.ts"],"names":[],"mappings":";;AAEA,2DAAiD;AACjD,iDAA+D;AAC/D,+DAAiE;AAgBjE,MAAM,WAAW,GAAW,iCAAiC,CAAC;AAE9D,kBAAe;IACb,+BAA+B,EAAE,UAE/B,QAAmB,EACnB,QAA4B;QAE5B,MAAM,OAAO,GAAG,IAA0B,CAAC;QAC3C,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;YACzB,OAAO;gBACL,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,GAAW,EAAE;oBACpB,OAAO;wBACL,IAAA,gCAAW,EAAC,GAAG,WAAW,EAAE,EAAE,UAAU,CAAC;wBACzC,0EAA0E;wBAC1E,IAAA,oCAAmB,EAAC,QAAQ,CAAC;qBAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACf,CAAC;aACF,CAAC;QACJ,CAAC;QACD,OAAO,qCAAqB,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,EAAE,QAAQ,CAA6B,CAAC;IACvG,CAAC;CACF,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */\nimport { Result } from '@fgv/ts-utils';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { Context, toMatchInlineSnapshot } from 'jest-snapshot';\nimport { printReceivedResult } from '../../utils/matcherHelpers';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toSucceedAndMatchInlineSnapshot to verify that a Result<T> is a success\n * and that the result value matches an inline snapshot\n */\n toSucceedAndMatchInlineSnapshot<T>(snapshot: string | undefined): R;\n }\n }\n}\n\nconst matcherName: string = 'toSucceedAndMatchInlineSnapshot';\n\nexport default {\n toSucceedAndMatchInlineSnapshot: function <T>(\n this: jest.MatcherContext,\n received: Result<T>,\n snapshot: string | undefined\n ): jest.CustomMatcherResult {\n const context = this as unknown as Context;\n if (received.isFailure()) {\n return {\n pass: false,\n message: (): string => {\n return [\n matcherHint(`${matcherName}`, 'callback'),\n 'Expected:\\n Callback to succeed with a result that matches the snapshot',\n printReceivedResult(received)\n ].join('\\n');\n }\n };\n }\n return toMatchInlineSnapshot.call(context, received.value, {}, snapshot) as jest.CustomMatcherResult;\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toSucceedAndMatchSnapshot/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAKvC,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;;eAGG;YACH,yBAAyB,CAAC,CAAC,KAAK,CAAC,CAAC;SACnC;KACF;CACF;;gCAKsC,CAAC,QAC9B,IAAI,CAAC,cAAc,YACf,MAAM,CAAC,CAAC,CAAC,KAClB,IAAI,CAAC,mBAAmB;;AAJ7B,wBAwBE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toSucceedAndMatchSnapshot/index.ts"],"names":[],"mappings":";;AAEA,2DAAiD;AACjD,iDAAyD;AACzD,+DAAiE;AAgBjE,MAAM,WAAW,GAAW,2BAA2B,CAAC;AAExD,kBAAe;IACb,yBAAyB,EAAE,UAEzB,QAAmB;QAEnB,MAAM,OAAO,GAAG,IAA0B,CAAC;QAC3C,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;YACzB,OAAO;gBACL,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,GAAW,EAAE;oBACpB,OAAO;wBACL,IAAA,gCAAW,EAAC,GAAG,WAAW,EAAE,EAAE,UAAU,CAAC;wBACzC,0EAA0E;wBAC1E,IAAA,oCAAmB,EAAC,QAAQ,CAAC;qBAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACf,CAAC;aACF,CAAC;QACJ,CAAC;QACD,OAAO,+BAAe,CAAC,IAAI,CACzB,OAAO,EACP,QAAQ,CAAC,KAAK,EACd,2BAA2B,CACA,CAAC;IAChC,CAAC;CACF,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */\nimport { Result } from '@fgv/ts-utils';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { Context, toMatchSnapshot } from 'jest-snapshot';\nimport { printReceivedResult } from '../../utils/matcherHelpers';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toSucceedAndMatchSnapshot to verify that a Result<T> is a success\n * and that the result value matches a stored snapshot\n */\n toSucceedAndMatchSnapshot<T>(): R;\n }\n }\n}\n\nconst matcherName: string = 'toSucceedAndMatchSnapshot';\n\nexport default {\n toSucceedAndMatchSnapshot: function <T>(\n this: jest.MatcherContext,\n received: Result<T>\n ): jest.CustomMatcherResult {\n const context = this as unknown as Context;\n if (received.isFailure()) {\n return {\n pass: false,\n message: (): string => {\n return [\n matcherHint(`${matcherName}`, 'callback'),\n 'Expected:\\n Callback to succeed with a result that matches the snapshot',\n printReceivedResult(received)\n ].join('\\n');\n }\n };\n }\n return toMatchSnapshot.call(\n context,\n received.value,\n 'toSucceedAndMatchSnapshot'\n ) as jest.CustomMatcherResult;\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toSucceedAndSatisfy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAMxD,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;;;;eAKG;YACH,mBAAmB,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC;SAC7E;KACF;CACF;;0BAuCgC,CAAC,QACxB,IAAI,CAAC,cAAc,YACf,MAAM,CAAC,CAAC,CAAC,QACb,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,KACjC,IAAI,CAAC,mBAAmB;;AAL7B,wBAmBE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/matchers/toSucceedAndSatisfy/index.ts"],"names":[],"mappings":";;AACA,+DAAsF;AACtF,2CAAqD;AAErD,2DAAiD;AAkBjD,SAAS,WAAW,CAAI,QAAmB;IACzC,MAAM,QAAQ,GAAG,qBAAqB,CAAC;IACvC,MAAM,GAAG,GAAG,CAAC,IAAA,oCAAmB,EAAC,QAAQ,CAAC,CAAC,CAAC;IAC5C,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAErC,OAAO,GAAG,EAAE,CACV;QACE,IAAA,gCAAW,EAAC,QAAQ,uBAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC;QACxD,IAAA,oCAAmB,EAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC;QAC/C,GAAG,GAAG;KACP,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAI,QAAmB,EAAE,QAAgC;IAC3E,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AAO,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;IACnE,CAAC;CACF,CAAC","sourcesContent":["import { Result, ResultValueType } from '@fgv/ts-utils';\nimport { printExpectedResult, printReceivedResult } from '../../utils/matcherHelpers';\nimport { matcherName, predicate } from './predicate';\n\nimport { matcherHint } from 'jest-matcher-utils';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toSucceedAndSatisfy to verify that a Result<T> is a success\n * and that the supplied test function returns true (or void)\n * for the resulting value\n * @param test -\n */\n toSucceedAndSatisfy(test: (value: ResultValueType<T>) => boolean | void): R;\n }\n }\n}\n\nfunction passMessage<T>(received: Result<T>): () => string {\n const expected = 'successful callback';\n const got = [printReceivedResult(received)];\n got.push(' Callback returned true');\n\n return () =>\n [\n matcherHint(`.not.${matcherName}`, 'result', 'callback'),\n printExpectedResult('success', false, expected),\n ...got\n ].join('\\n');\n}\n\nfunction failMessage<T>(received: Result<T>, cbResult: Result<boolean | void>): () => string {\n const expected = 'successful callback';\n const got = [printReceivedResult(received)];\n\n /* c8 ignore else */\n if (cbResult.isFailure()) {\n got.push(cbResult.message);\n } else if (cbResult.value === false) {\n got.push(' Callback returned false');\n } else if (cbResult.value === undefined) {\n got.push(' Callback was not invoked');\n } else {\n throw new Error('Internal error: toSucceedAndSatisfy.failMessage passed success with true');\n }\n\n return () =>\n [\n matcherHint(`${matcherName}`, 'result', 'callback'),\n printExpectedResult('success', true, expected),\n ...got\n ].join('\\n');\n}\n\nexport default {\n toSucceedAndSatisfy: function <T>(\n this: jest.MatcherContext,\n received: Result<T>,\n test: (value: T) => boolean | void\n ): jest.CustomMatcherResult {\n // For the normal (not '.not') case, we do not want to capture exceptions\n // so that the IDE can display exactly the line on which the failure case.\n // For the .not case, we want to swallow exceptions or expect failures since\n // we're just testing failure and not the reason.\n const capture = this.isNot;\n const cbResult = predicate(received, test, !!capture);\n const pass = cbResult.isSuccess() && cbResult.value === true;\n if (pass) {\n return { pass: true, message: passMessage(received) };\n }\n\n return { pass: false, message: failMessage(received, cbResult) };\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toSucceedAndSatisfy/predicate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgC,MAAM,gBAAgB,CAAC;AAEtE,eAAO,MAAM,WAAW,EAAE,MAA8B,CAAC;AAMzD,wBAAgB,SAAS,CAAC,CAAC,EACzB,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EACnB,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,EAChC,OAAO,EAAE,OAAO,GACf,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,CAS7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toSucceedAndSatisfy/predicate.ts"],"names":[],"mappings":";;;AAQA,8BAaC;AArBD,6CAAsE;AAEzD,QAAA,WAAW,GAAW,qBAAqB,CAAC;AAEzD,8GAA8G;AAC9G,4CAA4C;AAC5C,6FAA6F;AAC7F,2DAA2D;AAC3D,SAAgB,SAAS,CACvB,QAAmB,EACnB,EAAgC,EAChC,OAAgB;IAEhB,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACjG,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;YACzB,OAAO,IAAA,kBAAO,EAAC,QAAQ,CAAC,KAAK,KAAK,IAAI,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,gCAAgC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { Result, captureResult, fail, succeed } from '../../ts-utils';\n\nexport const matcherName: string = 'toSucceedAndSatisfy';\n\n// If the result is successful and callback does not throw, returns Success with the callback return value, or\n// true if the callback returns undefined\n// If the result is successful but the callback throws, returns Failure with the thrown error\n// If the result is failure, returns Success with undefined\nexport function predicate<T>(\n received: Result<T>,\n cb: (value: T) => boolean | void,\n capture: boolean\n): Result<boolean | undefined> {\n if (received.isSuccess()) {\n const cbResult = capture ? captureResult(() => cb(received.value)) : succeed(cb(received.value));\n if (cbResult.isSuccess()) {\n return succeed(cbResult.value === true || cbResult.value === undefined);\n }\n return fail(` Callback failed with:\\n ${cbResult.message}`);\n }\n return succeed(undefined);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toSucceedWith/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAMxD,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;;;eAIG;YACH,aAAa,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC;SACzD;KACF;CACF;;oBA2B0B,CAAC,SAAS,MAAM,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C","sourcesContent":["import { Result, ResultValueType } from '@fgv/ts-utils';\nimport { printExpectedResult, printReceivedResult } from '../../utils/matcherHelpers';\nimport { matcherName, predicate } from './predicate';\n\nimport { matcherHint } from 'jest-matcher-utils';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toSucceedWith to verify that a Result\\<T\\> is a success\n * and that the result value matches the supplied value\n * @param expected -\n */\n toSucceedWith(expected: ResultValueType<T> | RegExp): R;\n }\n }\n}\n\nfunction passMessage<T extends Result<unknown>>(\n received: T,\n expected: ResultValueType<T> | RegExp\n): () => string {\n return () =>\n [\n matcherHint(`.not.${matcherName}`),\n printExpectedResult('success', false, expected),\n printReceivedResult(received)\n ].join('\\n');\n}\n\nfunction failMessage<T extends Result<unknown>>(\n received: T,\n expected: ResultValueType<T> | RegExp\n): () => string {\n return () =>\n [\n matcherHint(`${matcherName}`),\n printExpectedResult('success', true, expected),\n printReceivedResult(received)\n ].join('\\n');\n}\n\nexport default {\n toSucceedWith: function <T extends Result<unknown>>(\n received: T,\n expected: ResultValueType<T> | RegExp\n ): jest.CustomMatcherResult {\n const pass = predicate(received, expected);\n if (pass) {\n return { pass: true, message: passMessage(received, expected) };\n }\n\n return { pass: false, message: failMessage(received, expected) };\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toSucceedWith/predicate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,eAAO,MAAM,WAAW,EAAE,MAAwB,CAAC;AAEnD,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAQ5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toSucceedWith/predicate.ts"],"names":[],"mappings":";;;AAKA,8BAQC;AAbD,qDAA4C;AAG/B,QAAA,WAAW,GAAW,eAAe,CAAC;AAEnD,SAAgB,SAAS,CAAI,QAAmB,EAAE,QAAiB;IACjE,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;QACzB,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,IAAI,QAAQ,YAAY,MAAM,EAAE,CAAC;YACrE,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,IAAA,qBAAM,EAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { equals } from '@jest/expect-utils';\nimport { Result } from '../../ts-utils';\n\nexport const matcherName: string = 'toSucceedWith';\n\nexport function predicate<T>(received: Result<T>, expected: unknown): boolean {\n if (received.isSuccess()) {\n if (typeof received.value === 'string' && expected instanceof RegExp) {\n return expected.test(received.value);\n }\n return equals(received.value, expected);\n }\n return false;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/matchers/toSucceedWithDetail/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAOlF,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;;;eAIG;YACH,mBAAmB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC;S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,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;QAC1E,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;IAC3E,CAAC;CACF,CAAC","sourcesContent":["import { DetailedResult, ResultDetailType, ResultValueType } from '@fgv/ts-utils';\nimport { printExpectedDetailedResult, printReceivedDetailedResult } from '../../utils/matcherHelpers';\nimport { matcherName, predicate } from './predicate';\n\nimport { matcherHint } from 'jest-matcher-utils';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars, @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toSucceedWithDetail to verify that a DetailedResult\\<T, TD\\> is\n * a success and that the result value and detail matches the supplied\n * values\n */\n toSucceedWithDetail(expected: ResultValueType<T> | RegExp, detail: ResultDetailType<T> | undefined): R;\n }\n }\n}\n\nfunction passMessage<T extends DetailedResult<unknown, unknown>>(\n received: T,\n expected: ResultValueType<T> | RegExp,\n expectedDetail: ResultDetailType<T> | undefined\n): () => string {\n return () =>\n [\n matcherHint(`.not.${matcherName}`),\n printExpectedDetailedResult('success', false, expected, expectedDetail),\n printReceivedDetailedResult(received)\n ].join('\\n');\n}\n\nfunction failMessage<T extends DetailedResult<unknown, unknown>>(\n received: T,\n expected: ResultValueType<T> | RegExp,\n expectedDetail: ResultDetailType<T> | undefined\n): () => string {\n return () =>\n [\n matcherHint(`${matcherName}`),\n printExpectedDetailedResult('success', true, expected, expectedDetail),\n printReceivedDetailedResult(received)\n ].join('\\n');\n}\n\nexport default {\n toSucceedWithDetail: function <T extends DetailedResult<unknown, unknown>>(\n received: T,\n expected: ResultValueType<T> | RegExp,\n detail: ResultDetailType<T> | undefined\n ): jest.CustomMatcherResult {\n const pass = predicate(received, expected, detail);\n if (pass) {\n return { pass: true, message: passMessage(received, expected, detail) };\n }\n\n return { pass: false, message: failMessage(received, expected, detail) };\n }\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../../src/matchers/toSucceedWithDetail/predicate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,WAAW,EAAE,MAA8B,CAAC;AAEzD,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAC7B,QAAQ,EAAE,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,EAC/B,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,EAAE,GAAG,SAAS,GACrB,OAAO,CAaT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"predicate.js","sourceRoot":"","sources":["../../../src/matchers/toSucceedWithDetail/predicate.ts"],"names":[],"mappings":";;;AAKA,8BAiBC;AAtBD,qDAA4C;AAG/B,QAAA,WAAW,GAAW,qBAAqB,CAAC;AAEzD,SAAgB,SAAS,CACvB,QAA+B,EAC/B,QAAiB,EACjB,MAAsB;IAEtB,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;QACzB,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,IAAI,QAAQ,YAAY,MAAM,EAAE,CAAC;YACrE,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,IAAA,qBAAM,EAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC1C,CAAC;QAED,IAAI,GAAG,IAAI,IAAI,IAAA,qBAAM,EAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { equals } from '@jest/expect-utils';\nimport { DetailedResult } from '../../ts-utils';\n\nexport const matcherName: string = 'toSucceedWithDetail';\n\nexport function predicate<T, TD>(\n received: DetailedResult<T, TD>,\n expected: unknown,\n detail: TD | undefined\n): boolean {\n if (received.isSuccess()) {\n let pass = false;\n if (typeof received.value === 'string' && expected instanceof RegExp) {\n pass = expected.test(received.value);\n } else {\n pass = equals(received.value, expected);\n }\n\n pass = pass && equals(received.detail, detail);\n return pass;\n }\n return false;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/resolvers/cli.ts"],"names":[],"mappings":";AAoBA,wBAA8B"}
|
package/lib/resolvers/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/resolvers/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAsD;AAEtD,MAAM,mBAAmB,GAAW,SAAS,CAAC;AAE9C,SAAS,mBAAmB,CAAC,QAAgB,EAAE,GAAW;IACxD,OAAO,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,GAAG,EAAE,mBAAmB,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,eAAe,CAAC,YAAoB,EAAE,GAAW;IACxD,OAAO,QAAQ,CAAC,eAAe,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,2BAA2B,GAAW,QAAQ,CAAC,2BAA2B,CAAC;AAEjF,MAAM,CAAC,OAAO,GAAG;IACf,mBAAmB;IACnB,eAAe;IACf,2BAA2B;CAC5B,CAAC;AAEF,kBAAe,MAAM,CAAC,OAAO,CAAC","sourcesContent":["import * as Resolver from '../utils/snapshotResolver';\n\nconst CLI_SNAPSHOT_FOLDER: string = '__cli__';\n\nfunction resolveSnapshotPath(testPath: string, ext: string): string {\n return Resolver.resolveSnapshotPath(testPath, ext, CLI_SNAPSHOT_FOLDER);\n}\n\nfunction resolveTestPath(snapshotPath: string, ext: string): string {\n return Resolver.resolveTestPath(snapshotPath, ext);\n}\n\nconst testPathForConsistencyCheck: string = Resolver.testPathForConsistencyCheck;\n\nmodule.exports = {\n resolveSnapshotPath,\n resolveTestPath,\n testPathForConsistencyCheck\n};\n\nexport default module.exports;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ide.d.ts","sourceRoot":"","sources":["../../src/resolvers/ide.ts"],"names":[],"mappings":";AAoBA,wBAA8B"}
|
package/lib/resolvers/ide.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ide.js","sourceRoot":"","sources":["../../src/resolvers/ide.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAsD;AAEtD,MAAM,mBAAmB,GAAW,SAAS,CAAC;AAE9C,SAAS,mBAAmB,CAAC,QAAgB,EAAE,GAAW;IACxD,OAAO,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,GAAG,EAAE,mBAAmB,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,eAAe,CAAC,YAAoB,EAAE,GAAW;IACxD,OAAO,QAAQ,CAAC,eAAe,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,2BAA2B,GAAW,QAAQ,CAAC,2BAA2B,CAAC;AAEjF,MAAM,CAAC,OAAO,GAAG;IACf,mBAAmB;IACnB,eAAe;IACf,2BAA2B;CAC5B,CAAC;AAEF,kBAAe,MAAM,CAAC,OAAO,CAAC","sourcesContent":["import * as Resolver from '../utils/snapshotResolver';\n\nconst CLI_SNAPSHOT_FOLDER: string = '__ide__';\n\nfunction resolveSnapshotPath(testPath: string, ext: string): string {\n return Resolver.resolveSnapshotPath(testPath, ext, CLI_SNAPSHOT_FOLDER);\n}\n\nfunction resolveTestPath(snapshotPath: string, ext: string): string {\n return Resolver.resolveTestPath(snapshotPath, ext);\n}\n\nconst testPathForConsistencyCheck: string = Resolver.testPathForConsistencyCheck;\n\nmodule.exports = {\n resolveSnapshotPath,\n resolveTestPath,\n testPathForConsistencyCheck\n};\n\nexport default module.exports;\n"]}
|
package/lib/ts-utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ts-utils.d.ts","sourceRoot":"","sources":["../src/ts-utils.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
package/lib/ts-utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ts-utils.js","sourceRoot":"","sources":["../src/ts-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B","sourcesContent":["export * from '@fgv/ts-utils';\n"]}
|
package/lib/types/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGlE,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QAEb,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrB;;eAEG;YACH,SAAS,IAAI,CAAC,CAAC;YAEf;;;;eAIG;YACH,aAAa,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC;YAExD;;;;;;eAMG;YACH,mBAAmB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC;YAE9F;;;;;eAKG;YACH,mBAAmB,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC;YAE5E;;;eAGG;YACH,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,CAAC,CAAC;YAEjE;;;eAGG;YACH,yBAAyB,IAAI,CAAC,CAAC;YAE/B;;eAEG;YACH,MAAM,IAAI,CAAC,CAAC;YAEZ;;;;eAIG;YACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,CAAC,CAAC;YAErD;;;;;;eAMG;YACH,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC;YACxE,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YAEvF;;;eAGG;YACH,UAAU,IAAI,CAAC,CAAC;YAEhB;;;;eAIG;YACH,0BAA0B,IAAI,CAAC,CAAC;YAEhC;;;;;eAKG;YACH,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,CAAC;YAExD;;;;eAIG;YACH,qCAAqC,CAAC,QAAQ,EAAE,OAAO,GAAG,CAAC,CAAC;SAC7D;KACF;CACF"}
|
package/lib/types/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,6BAA6B","sourcesContent":["/// <reference types=\"jest\"/>\n\n// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-explicit-any\nexport type Function = (...args: any[]) => any;\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars\nimport { ResultDetailType, ResultValueType } from '@fgv/ts-utils';\n\n/* eslint-disable @typescript-eslint/no-unused-vars,no-unused-vars */\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n interface Matchers<R, T> {\n /**\n * Use .toSucceed to verify that a Result\\<T\\> is a success\n */\n toSucceed(): R;\n\n /**\n * Use .toSucceedWith to verify that a Result\\<T\\> is a success\n * and that the result value matches the supplied value\n * @param expected -\n */\n toSucceedWith(expected: ResultValueType<T> | RegExp): R;\n\n /**\n * Use .toSucceedWithDetail to verify that a DetailedResult\\<T, TD\\> is\n * a success and that the result value and detail matches the supplied\n * values\n * @param expected -\n * @param detail -\n */\n toSucceedWithDetail(expected: ResultValueType<T>, detail: ResultDetailType<T> | undefined): R;\n\n /**\n * Use .toSucceedAndSatisfy to verify that a Result\\<T\\> is a success\n * and that the supplied test function returns true (or void)\n * for the resulting value\n * @param test -\n */\n toSucceedAndSatisfy(test: (value: ResultValueType<T>) => boolean | void): R;\n\n /**\n * Use .toSucceedAndMatchInlineSnapshot to verify that a Result\\<T\\> is a success\n * and that the result value matches an inline snapshot\n */\n toSucceedAndMatchInlineSnapshot(snapshot: string | undefined): R;\n\n /**\n * Use .toSucceedAndMatchSnapshot to verify that a Result\\<T\\> is a success\n * and that the result value matches a stored snapshot\n */\n toSucceedAndMatchSnapshot(): R;\n\n /**\n * Use .toFail to verify that a Result\\<T\\> is a failure\n */\n toFail(): R;\n\n /**\n * Use .toFailWith to verify that a Result\\<T\\> is a failure\n * that matches a supplied string, RegExp or undefined value\n * @param message -\n */\n toFailWith(expected: string | RegExp | undefined): R;\n\n /**\n * Use .toFailWithDetail to verify that a DetailedResult\\<T\\> is\n * a failure that matches both a supplied expected failure value\n * (string, RegExp or undefined) and a supplied failure detail.\n * @param message -\n * @param detail -\n */\n toFailWithDetail<TDetail>(message: string | RegExp, detail: TDetail): R;\n toFailWithDetail(message: string | RegExp | undefined, detail: ResultDetailType<T>): R;\n\n /**\n * Use .toFailTest to test a custom matcher by\n * verifying that a test case fails.\n */\n toFailTest(): R;\n\n /**\n * Use .toFailTestWith to test a custom matcher by\n * verifying that a test case fails as expected and\n * reports an error matching a stored snapshot.\n */\n toFailTestAndMatchSnapshot(): R;\n\n /**\n * Use .toFailTestWith to test a custom matcher by\n * verifying that a test case fails as expected and\n * reports an error matching a supplied value.\n * @param expected -\n */\n toFailTestWith(expected: string | string[] | RegExp): R;\n\n /**\n * Use .toSucceedWith to verify that a Result\\<T\\> is a success\n * and that the result value matches the supplied value\n * @param expected -\n */\n toHaveBeenCalledWithArgumentsMatching(expected: unknown): R;\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"matcherHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/matcherHelpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,MAAM,CAW1G;AAED,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,EAAE,EAC/C,MAAM,EAAE,SAAS,GAAG,SAAS,EAC7B,KAAK,EAAE,OAAO,EACd,eAAe,CAAC,EAAE,CAAC,EACnB,cAAc,CAAC,EAAE,EAAE,GAClB,MAAM,CAaR;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAOlE;AAED,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,CAO1F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"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,kCAAa,EAAC,cAAc,CAAC,GAAG;KAC/C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAgB,mBAAmB,CAAI,QAAmB;IACxD,OAAO;QACL,WAAW;QACX,QAAQ,CAAC,SAAS,EAAE;YAClB,CAAC,CAAC,kBAAkB,IAAA,kCAAa,EAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACnD,CAAC,CAAC,mBAAmB,QAAQ,CAAC,OAAO,GAAG;KAC3C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAgB,2BAA2B,CAAQ,QAA+B;IAChF,OAAO;QACL,WAAW;QACX,QAAQ,CAAC,SAAS,EAAE;YAClB,CAAC,CAAC,mBAAmB,IAAA,kCAAa,EAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,IAAA,kCAAa,EAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;YACpG,CAAC,CAAC,mBAAmB,QAAQ,CAAC,OAAO,iBAAiB,IAAA,kCAAa,EAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;KAC1F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC","sourcesContent":["import { printExpected, printReceived } from 'jest-matcher-utils';\nimport { DetailedResult, Result } from '../ts-utils';\n\nfunction printExpectedValue<T>(outcome: string, expected?: T): string {\n return expected !== undefined ? ` ${outcome} with ${printExpected(expected)}` : ` ${outcome}`;\n}\n\nexport function printExpectedResult<T>(expect: 'success' | 'failure', isNot: boolean, expected?: T): string {\n return [\n 'Expected:',\n isNot\n ? expect === 'success'\n ? printExpectedValue('Success', expected)\n : printExpectedValue('Failure', expected)\n : expect === 'success'\n ? printExpectedValue('Not success', expected)\n : printExpectedValue('Not failure', expected)\n ].join('\\n');\n}\n\nexport function printExpectedDetailedResult<T, TD>(\n expect: 'success' | 'failure',\n isNot: boolean,\n expectedMessage?: T,\n expectedDetail?: TD\n): string {\n /* c8 ignore next */\n return [\n 'Expected:',\n isNot\n ? expect === 'success'\n ? printExpectedValue('Success', expectedMessage)\n : printExpectedValue('Failure', expectedMessage)\n : expect === 'success'\n ? printExpectedValue('Not success', expectedMessage)\n : printExpectedValue('Not failure', expectedMessage),\n ` Detail: \"${printExpected(expectedDetail)}\"`\n ].join('\\n');\n}\n\nexport function printReceivedResult<T>(received: Result<T>): string {\n return [\n 'Received:',\n received.isSuccess()\n ? ` Success with ${printReceived(received.value)}`\n : ` Failure with \"${received.message}\"`\n ].join('\\n');\n}\n\nexport function printReceivedDetailedResult<T, TD>(received: DetailedResult<T, TD>): string {\n return [\n 'Received:',\n received.isSuccess()\n ? ` Success with \"${printReceived(received.value)}\"\\n Detail: \"${printReceived(received.detail)}\"`\n : ` Failure with \"${received.message}\"\\n Detail: \"${printReceived(received.detail)}\"`\n ].join('\\n');\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotResolver.d.ts","sourceRoot":"","sources":["../../src/utils/snapshotResolver.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,MAAM,GACzB,MAAM,CAMR;AAED,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAM3F;AAED,eAAO,MAAM,2BAA2B,EAAE,MAKzC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotResolver.js","sourceRoot":"","sources":["../../src/utils/snapshotResolver.ts"],"names":[],"mappings":";;;;;;AAEA,kDAUC;AAED,0CAMC;AApBD,gDAAwB;AAExB,SAAgB,mBAAmB,CACjC,QAAgB,EAChB,iBAAyB,EACzB,kBAA0B;IAE1B,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAC5B,cAAI,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,kBAAkB,CAAC,EACtE,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAC5C,CAAC;IACF,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAgB,eAAe,CAAC,gBAAwB,EAAE,iBAAyB;IACjF,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CACxB,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAC1D,cAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CACnD,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAEY,QAAA,2BAA2B,GAAW,cAAI,CAAC,KAAK,CAAC,IAAI,CAChE,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,iBAAiB,CAClB,CAAC","sourcesContent":["import path from 'path';\n\nexport function resolveSnapshotPath(\n testPath: string,\n snapshotExtension: string,\n snapshotFolderName: string\n): string {\n const snapshotPath = path.join(\n path.join(path.dirname(testPath), '__snapshots__', snapshotFolderName),\n path.basename(testPath) + snapshotExtension\n );\n return snapshotPath;\n}\n\nexport function resolveTestPath(snapshotFilePath: string, snapshotExtension: string): string {\n const testPath = path.join(\n path.dirname(path.dirname(path.dirname(snapshotFilePath))),\n path.basename(snapshotFilePath, snapshotExtension)\n );\n return testPath;\n}\n\nexport const testPathForConsistencyCheck: string = path.posix.join(\n 'consistency_check',\n '__tests__',\n 'subdir',\n 'example.test.js'\n);\n"]}
|