@unrift/core 0.0.0 → 0.2.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/dist/esm/cli.js +75 -5
- package/dist/esm/expect.d.ts +8 -0
- package/dist/esm/expect.d.ts.map +1 -1
- package/dist/esm/expect.js +48 -4
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/interface.d.ts +4 -1
- package/dist/esm/interface.d.ts.map +1 -1
- package/dist/esm/interface.js +4 -1
- package/dist/esm/matchers.d.ts +1 -0
- package/dist/esm/matchers.d.ts.map +1 -1
- package/dist/esm/matchers.js +61 -0
- package/dist/esm/run.d.ts.map +1 -1
- package/dist/esm/run.js +3 -4
- package/dist/esm/runner.d.ts.map +1 -1
- package/dist/esm/runner.js +201 -33
- package/dist/esm/suite.d.ts +2 -10
- package/dist/esm/suite.d.ts.map +1 -1
- package/dist/esm/suite.js +29 -10
- package/dist/esm/test.d.ts +1 -7
- package/dist/esm/test.d.ts.map +1 -1
- package/dist/esm/test.js +11 -2
- package/dist/esm/types.d.ts +3 -3
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/colors.d.ts +21 -0
- package/dist/esm/utils/colors.d.ts.map +1 -1
- package/dist/esm/utils/colors.js +34 -4
- package/dist/esm/utils/compareEngine.d.ts +10 -0
- package/dist/esm/utils/compareEngine.d.ts.map +1 -0
- package/dist/esm/utils/compareEngine.js +222 -0
- package/dist/esm/utils/deepEqual.d.ts.map +1 -1
- package/dist/esm/utils/deepEqual.js +7 -185
- package/dist/esm/utils/diff.d.ts +2 -0
- package/dist/esm/utils/diff.d.ts.map +1 -0
- package/dist/esm/utils/diff.js +84 -0
- package/dist/esm/utils/discoverTestFiles.d.ts.map +1 -1
- package/dist/esm/utils/discoverTestFiles.js +17 -2
- package/dist/esm/utils/looseEqual.d.ts +9 -0
- package/dist/esm/utils/looseEqual.d.ts.map +1 -1
- package/dist/esm/utils/looseEqual.js +16 -197
- package/dist/esm/utils/normalizePath.d.ts +2 -0
- package/dist/esm/utils/normalizePath.d.ts.map +1 -0
- package/dist/esm/utils/normalizePath.js +4 -0
- package/dist/esm/utils/toError.d.ts +2 -0
- package/dist/esm/utils/toError.d.ts.map +1 -0
- package/dist/esm/utils/toError.js +3 -0
- package/dist/esm/utils/transform.d.ts.map +1 -1
- package/dist/esm/utils/transform.js +31 -21
- package/package.json +21 -3
package/dist/esm/cli.js
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
2
5
|
import { runTestsCLI } from "./runner.js";
|
|
6
|
+
const __cliDir = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
function readVersion() {
|
|
8
|
+
// Walk up from current file to find package.json (works from both src/ and dist/esm/)
|
|
9
|
+
let dir = __cliDir;
|
|
10
|
+
for (let i = 0; i < 5; i++) {
|
|
11
|
+
try {
|
|
12
|
+
const pkg = JSON.parse(readFileSync(resolve(dir, "package.json"), "utf8"));
|
|
13
|
+
if (pkg.name === "@unrift/core")
|
|
14
|
+
return pkg.version;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// No package.json here, keep walking up
|
|
18
|
+
}
|
|
19
|
+
dir = resolve(dir, "..");
|
|
20
|
+
}
|
|
21
|
+
return "0.0.0";
|
|
22
|
+
}
|
|
23
|
+
const version = readVersion();
|
|
3
24
|
function safeRegExp(source) {
|
|
4
25
|
try {
|
|
5
26
|
return new RegExp(source);
|
|
@@ -11,30 +32,37 @@ function safeRegExp(source) {
|
|
|
11
32
|
}
|
|
12
33
|
function printHelp() {
|
|
13
34
|
console.log(`
|
|
14
|
-
Unrift Test Runner
|
|
35
|
+
Unrift Test Runner v${version}
|
|
15
36
|
|
|
16
37
|
Usage:
|
|
17
38
|
unrift [pattern] [options]
|
|
18
39
|
|
|
19
40
|
Options:
|
|
20
41
|
-c, --config <path> Path to config file
|
|
42
|
+
-b, --bail Stop on first test failure
|
|
43
|
+
-t, --timeout <ms> Default test timeout in milliseconds
|
|
21
44
|
-d, --debug Enable debug logging
|
|
22
45
|
-l, --list List discovered test files
|
|
23
46
|
-j, --json Output test results as JSON
|
|
24
47
|
--cache-clean Clear transform cache
|
|
48
|
+
-v, --version Show version
|
|
25
49
|
-h, --help Show help
|
|
26
50
|
|
|
27
51
|
Examples:
|
|
28
52
|
unrift
|
|
29
53
|
unrift math
|
|
30
|
-
unrift -c test/config.ts --
|
|
54
|
+
unrift -c test/config.ts --bail
|
|
55
|
+
unrift --timeout 10000
|
|
31
56
|
`);
|
|
32
57
|
}
|
|
33
58
|
function parseArgs(argv) {
|
|
34
59
|
let configPath;
|
|
35
60
|
let pattern;
|
|
61
|
+
let timeoutMs;
|
|
62
|
+
let bail;
|
|
36
63
|
let debug = false;
|
|
37
64
|
let help = false;
|
|
65
|
+
let showVersion = false;
|
|
38
66
|
let list = false;
|
|
39
67
|
let json = false;
|
|
40
68
|
let cacheClean = false;
|
|
@@ -45,6 +73,10 @@ function parseArgs(argv) {
|
|
|
45
73
|
help = true;
|
|
46
74
|
continue;
|
|
47
75
|
}
|
|
76
|
+
if (a === "--version" || a === "-v") {
|
|
77
|
+
showVersion = true;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
48
80
|
if (a === "--config" || a === "-c") {
|
|
49
81
|
const next = argv[i + 1];
|
|
50
82
|
if (!next)
|
|
@@ -53,6 +85,10 @@ function parseArgs(argv) {
|
|
|
53
85
|
i++;
|
|
54
86
|
continue;
|
|
55
87
|
}
|
|
88
|
+
if (a === "--bail" || a === "-b") {
|
|
89
|
+
bail = true;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
56
92
|
if (a === "--debug" || a === "-d") {
|
|
57
93
|
debug = true;
|
|
58
94
|
continue;
|
|
@@ -65,6 +101,16 @@ function parseArgs(argv) {
|
|
|
65
101
|
json = true;
|
|
66
102
|
continue;
|
|
67
103
|
}
|
|
104
|
+
if (a === "--timeout" || a === "-t") {
|
|
105
|
+
const next = argv[i + 1];
|
|
106
|
+
if (!next)
|
|
107
|
+
throw new Error(`${a} requires a value in milliseconds`);
|
|
108
|
+
timeoutMs = parseInt(next, 10);
|
|
109
|
+
if (Number.isNaN(timeoutMs))
|
|
110
|
+
throw new Error(`Invalid timeout: ${next}`);
|
|
111
|
+
i++;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
68
114
|
if (a === "--cache-clean" || a === "--clear-cache") {
|
|
69
115
|
cacheClean = true;
|
|
70
116
|
continue;
|
|
@@ -74,14 +120,38 @@ function parseArgs(argv) {
|
|
|
74
120
|
}
|
|
75
121
|
if (rest[0])
|
|
76
122
|
pattern = safeRegExp(rest[0]);
|
|
77
|
-
return {
|
|
123
|
+
return {
|
|
124
|
+
configPath,
|
|
125
|
+
pattern,
|
|
126
|
+
timeoutMs,
|
|
127
|
+
bail,
|
|
128
|
+
debug,
|
|
129
|
+
list,
|
|
130
|
+
json,
|
|
131
|
+
cacheClean,
|
|
132
|
+
help,
|
|
133
|
+
showVersion,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const { configPath, pattern, timeoutMs, bail, debug, list, json, cacheClean, help, showVersion, } = parseArgs(process.argv.slice(2));
|
|
137
|
+
if (showVersion) {
|
|
138
|
+
console.log(version);
|
|
139
|
+
process.exit(0);
|
|
78
140
|
}
|
|
79
|
-
const { configPath, pattern, debug, list, json, cacheClean, help } = parseArgs(process.argv.slice(2));
|
|
80
141
|
if (help) {
|
|
81
142
|
printHelp();
|
|
82
143
|
process.exit(0);
|
|
83
144
|
}
|
|
84
|
-
runTestsCLI({
|
|
145
|
+
runTestsCLI({
|
|
146
|
+
pattern,
|
|
147
|
+
configPath,
|
|
148
|
+
timeoutMs,
|
|
149
|
+
bail,
|
|
150
|
+
debug,
|
|
151
|
+
list,
|
|
152
|
+
json,
|
|
153
|
+
cacheClean,
|
|
154
|
+
}).catch((err) => {
|
|
85
155
|
console.error(err);
|
|
86
156
|
process.exit(1);
|
|
87
157
|
});
|
package/dist/esm/expect.d.ts
CHANGED
|
@@ -11,17 +11,25 @@ export interface Matchers<T> {
|
|
|
11
11
|
toBeNull(): void | Promise<void>;
|
|
12
12
|
toBeTruthy(): void | Promise<void>;
|
|
13
13
|
toBeUndefined(): void | Promise<void>;
|
|
14
|
+
toBeGreaterThan(expected: number): void | Promise<void>;
|
|
15
|
+
toBeLessThan(expected: number): void | Promise<void>;
|
|
16
|
+
toBeInstanceOf(expected: new (...args: unknown[]) => unknown): void | Promise<void>;
|
|
17
|
+
toContain(expected: unknown): void | Promise<void>;
|
|
14
18
|
toEqual(expected: unknown): void | Promise<void>;
|
|
19
|
+
toHaveLength(expected: number): void | Promise<void>;
|
|
15
20
|
toMatch(expected: RegExp | string): void | Promise<void>;
|
|
16
21
|
toStrictEqual(expected: unknown): void | Promise<void>;
|
|
17
22
|
toThrow(expected?: unknown): void | Promise<void>;
|
|
18
23
|
readonly not: Matchers<T>;
|
|
24
|
+
readonly resolves: Matchers<Awaited<T>>;
|
|
25
|
+
readonly rejects: Matchers<unknown>;
|
|
19
26
|
}
|
|
20
27
|
export interface Matchers<T> {
|
|
21
28
|
}
|
|
22
29
|
export interface ExpectInterface {
|
|
23
30
|
<T>(value: T): Matchers<T>;
|
|
24
31
|
extend<M extends MatcherMap>(m: M): void;
|
|
32
|
+
readonly matchers: Readonly<MatcherMap>;
|
|
25
33
|
}
|
|
26
34
|
export declare const expect: ExpectInterface;
|
|
27
35
|
//# sourceMappingURL=expect.d.ts.map
|
package/dist/esm/expect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/expect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,SAAS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,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CACrC;AAID,MAAM,WAAW,QAAQ,CAAC,CAAC;CAAI;AAE/B,MAAM,WAAW,eAAe;IAC9B,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CACzC;AAED,eAAO,MAAM,MAAM,EAAE,eA8FjB,CAAC"}
|
package/dist/esm/expect.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatDiff } from "./utils/diff.js";
|
|
1
2
|
const matcherRegistry = Object.create(null);
|
|
2
3
|
export function extendMatchers(newMatchers) {
|
|
3
4
|
for (const key in newMatchers)
|
|
@@ -9,10 +10,7 @@ export const expect = (() => {
|
|
|
9
10
|
const ctx = {
|
|
10
11
|
isNot,
|
|
11
12
|
diff(a, b) {
|
|
12
|
-
return (
|
|
13
|
-
JSON.stringify(a, null, 2) +
|
|
14
|
-
"\n Expected: " +
|
|
15
|
-
JSON.stringify(b, null, 2));
|
|
13
|
+
return formatDiff(a, b);
|
|
16
14
|
},
|
|
17
15
|
};
|
|
18
16
|
const matcherFns = {};
|
|
@@ -20,10 +18,56 @@ export const expect = (() => {
|
|
|
20
18
|
const fn = matcherRegistry[name];
|
|
21
19
|
matcherFns[name] = (...args) => fn.call(ctx, received, ...args);
|
|
22
20
|
}
|
|
21
|
+
function makeAsyncProxy(getActual) {
|
|
22
|
+
const asyncFns = {};
|
|
23
|
+
for (const name in matcherRegistry) {
|
|
24
|
+
const fn = matcherRegistry[name];
|
|
25
|
+
asyncFns[name] = async (...args) => {
|
|
26
|
+
const actual = await getActual();
|
|
27
|
+
return fn.call(ctx, actual, ...args);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return new Proxy(asyncFns, {
|
|
31
|
+
get(target, prop) {
|
|
32
|
+
if (prop === "not") {
|
|
33
|
+
return makeExpectation(!isNot);
|
|
34
|
+
}
|
|
35
|
+
if (typeof prop === "string" && !(prop in target)) {
|
|
36
|
+
throw new Error(`Unknown matcher: ${prop}`);
|
|
37
|
+
}
|
|
38
|
+
return target[prop];
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
23
42
|
return new Proxy(matcherFns, {
|
|
24
43
|
get(target, prop) {
|
|
25
44
|
if (prop === "not")
|
|
26
45
|
return makeExpectation(!isNot);
|
|
46
|
+
if (prop === "resolves") {
|
|
47
|
+
return makeAsyncProxy(async () => {
|
|
48
|
+
try {
|
|
49
|
+
return await received;
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
throw new Error(`Expected promise to resolve, but it rejected with: ${err instanceof Error ? err.message : String(err)}`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (prop === "rejects") {
|
|
57
|
+
return makeAsyncProxy(async () => {
|
|
58
|
+
try {
|
|
59
|
+
await received;
|
|
60
|
+
throw new Error("Expected promise to reject, but it resolved");
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
if (err instanceof Error &&
|
|
64
|
+
err.message === "Expected promise to reject, but it resolved") {
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
67
|
+
return err;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
27
71
|
if (typeof prop === "string" && !(prop in target)) {
|
|
28
72
|
throw new Error(`Unknown matcher: ${prop}`);
|
|
29
73
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { beforeEach, afterEach, beforeAll, afterAll } from "./hooks";
|
|
2
2
|
export { defineConfig, type UnriftConfigOptions } from "./utils/defineConfig";
|
|
3
|
-
export { describe, it } from "./interface";
|
|
3
|
+
export { describe, it, test } from "./interface";
|
|
4
4
|
export { expect, extendMatchers } from "./expect";
|
|
5
5
|
export type { Matchers, ExpectInterface } from "./expect";
|
|
6
|
-
export type { MatcherContext, MatcherFn, MatcherMap } from "./types";
|
|
6
|
+
export type { MatcherContext, MatcherFn, MatcherMap, Promisable, } from "./types";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAElD,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC1D,YAAY,EACV,cAAc,EACd,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,SAAS,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { beforeEach, afterEach, beforeAll, afterAll } from "./hooks.js";
|
|
2
2
|
export { defineConfig } from "./utils/defineConfig.js";
|
|
3
|
-
export { describe, it } from "./interface.js";
|
|
3
|
+
export { describe, it, test } from "./interface.js";
|
|
4
4
|
export { expect, extendMatchers } from "./expect.js";
|
package/dist/esm/interface.d.ts
CHANGED
|
@@ -6,13 +6,16 @@ type DescribeFn = {
|
|
|
6
6
|
(description: string, fn: () => void): void;
|
|
7
7
|
only: (description: string, fn: () => void) => void;
|
|
8
8
|
skip: (description: string, fn: () => void) => void;
|
|
9
|
+
todo: (description: string) => void;
|
|
9
10
|
};
|
|
10
11
|
type ItFn = {
|
|
11
12
|
(description: string, fn: PromisableFn<void>): void;
|
|
12
13
|
only: (description: string, fn: PromisableFn<void>) => void;
|
|
13
14
|
skip: (description: string, fn: PromisableFn<void>) => void;
|
|
15
|
+
todo: (description: string) => void;
|
|
14
16
|
};
|
|
15
17
|
declare const describe: DescribeFn;
|
|
16
18
|
declare const it: ItFn;
|
|
17
|
-
|
|
19
|
+
declare const test: ItFn;
|
|
20
|
+
export { describe, it, test };
|
|
18
21
|
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/interface.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAY,MAAM,SAAS,CAAC;AAEtD;;GAEG;AAEH,KAAK,UAAU,GAAG;IAChB,CAAC,WAAW,EAAE,MAAM,EA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AAI,EAAE,IAAS,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/esm/interface.js
CHANGED
|
@@ -18,6 +18,7 @@ function _describe(description, fn, mode) {
|
|
|
18
18
|
const describe = (description, fn) => _describe(description, fn, TaskMode.Default);
|
|
19
19
|
describe.only = (description, fn) => _describe(description, fn, TaskMode.Only);
|
|
20
20
|
describe.skip = (description, fn) => _describe(description, fn, TaskMode.Skip);
|
|
21
|
+
describe.todo = (description) => _describe(description, () => { }, TaskMode.Todo);
|
|
21
22
|
function _it(description, fn, mode) {
|
|
22
23
|
assertRegisterState("it");
|
|
23
24
|
const test = new Test(description, fn, mode);
|
|
@@ -26,4 +27,6 @@ function _it(description, fn, mode) {
|
|
|
26
27
|
const it = (description, fn) => _it(description, fn, TaskMode.Default);
|
|
27
28
|
it.only = (description, fn) => _it(description, fn, TaskMode.Only);
|
|
28
29
|
it.skip = (description, fn) => _it(description, fn, TaskMode.Skip);
|
|
29
|
-
|
|
30
|
+
it.todo = (description) => _it(description, () => { }, TaskMode.Todo);
|
|
31
|
+
const test = it;
|
|
32
|
+
export { describe, it, test };
|
package/dist/esm/matchers.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../../src/matchers.ts"],"names":[],"mappings":"AAUA,wBAAgB,sBAAsB,SAMrC"}
|
|
1
|
+
{"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../../src/matchers.ts"],"names":[],"mappings":"AAUA,wBAAgB,sBAAsB,SAMrC;AAED,wBAAgB,aAAa,SAE5B"}
|
package/dist/esm/matchers.js
CHANGED
|
@@ -9,6 +9,9 @@ export function ensureInternalMatchers() {
|
|
|
9
9
|
registerCoreMatchers();
|
|
10
10
|
matchersRegistered = true;
|
|
11
11
|
}
|
|
12
|
+
export function resetMatchers() {
|
|
13
|
+
matchersRegistered = false;
|
|
14
|
+
}
|
|
12
15
|
function registerCoreMatchers() {
|
|
13
16
|
expect.extend({
|
|
14
17
|
toBe(received, expected) {
|
|
@@ -47,12 +50,70 @@ function registerCoreMatchers() {
|
|
|
47
50
|
throw new Error(this.diff(received, undefined));
|
|
48
51
|
}
|
|
49
52
|
},
|
|
53
|
+
toBeGreaterThan(received, expected) {
|
|
54
|
+
if (typeof received !== "number") {
|
|
55
|
+
throw new Error(this.diff(received, "expected a number"));
|
|
56
|
+
}
|
|
57
|
+
const pass = received > expected;
|
|
58
|
+
if (this.isNot ? pass : !pass) {
|
|
59
|
+
throw new Error(this.diff(received, `> ${expected}`));
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
toBeLessThan(received, expected) {
|
|
63
|
+
if (typeof received !== "number") {
|
|
64
|
+
throw new Error(this.diff(received, "expected a number"));
|
|
65
|
+
}
|
|
66
|
+
const pass = received < expected;
|
|
67
|
+
if (this.isNot ? pass : !pass) {
|
|
68
|
+
throw new Error(this.diff(received, `< ${expected}`));
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
toBeInstanceOf(received, expected) {
|
|
72
|
+
const ctor = expected;
|
|
73
|
+
const pass = received instanceof ctor;
|
|
74
|
+
if (this.isNot ? pass : !pass) {
|
|
75
|
+
throw new Error(this.diff(typeof received === "object" && received
|
|
76
|
+
? (received.constructor?.name ?? typeof received)
|
|
77
|
+
: typeof received, ctor.name));
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
toContain(received, expected) {
|
|
81
|
+
let pass;
|
|
82
|
+
if (Array.isArray(received)) {
|
|
83
|
+
pass = received.includes(expected);
|
|
84
|
+
}
|
|
85
|
+
else if (typeof received === "string") {
|
|
86
|
+
pass = received.includes(expected);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new Error(this.diff(received, "expected an array or string for toContain()"));
|
|
90
|
+
}
|
|
91
|
+
if (this.isNot ? pass : !pass) {
|
|
92
|
+
throw new Error(this.diff(received, expected));
|
|
93
|
+
}
|
|
94
|
+
},
|
|
50
95
|
toEqual(received, expected) {
|
|
51
96
|
const pass = looseEqual(received, expected);
|
|
52
97
|
if (this.isNot ? pass : !pass) {
|
|
53
98
|
throw new Error(this.diff(received, expected));
|
|
54
99
|
}
|
|
55
100
|
},
|
|
101
|
+
toHaveLength(received, expected) {
|
|
102
|
+
const len = typeof received === "string"
|
|
103
|
+
? received.length
|
|
104
|
+
: received != null &&
|
|
105
|
+
typeof received === "object" &&
|
|
106
|
+
typeof received.length === "number"
|
|
107
|
+
? received.length
|
|
108
|
+
: undefined;
|
|
109
|
+
if (len === undefined) {
|
|
110
|
+
throw new Error(this.diff(received, "expected a value with a .length property"));
|
|
111
|
+
}
|
|
112
|
+
const pass = len === expected;
|
|
113
|
+
if (this.isNot ? pass : !pass) {
|
|
114
|
+
throw new Error(this.diff(len, expected));
|
|
115
|
+
}
|
|
116
|
+
},
|
|
56
117
|
toMatch(received, expected) {
|
|
57
118
|
if (typeof received !== "string") {
|
|
58
119
|
throw new Error(this.diff(received, "Value must be a string to use toMatch()"));
|
package/dist/esm/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":"AAIA,OAAO,EAAY,UAAU,EAAE,MAAM,SAAS,CAAC;AAI/C,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,UAAU,CAAC;QACnB,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;CACJ,CAAC;AAQF,wBAAsB,SAAS,CAC7B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CA2D1B"}
|
package/dist/esm/run.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { clearContext, computeOnlyFlags, rootSuite, Suite } from "./suite.js";
|
|
2
2
|
import { ensureInternalMatchers } from "./matchers.js";
|
|
3
3
|
import { RunState, unriftGlobalContext } from "./context.js";
|
|
4
|
+
import { normalizePath } from "./utils/normalizePath.js";
|
|
4
5
|
import { TaskMode } from "./types.js";
|
|
6
|
+
import { toError } from "./utils/toError.js";
|
|
5
7
|
import { toImportUrl } from "./utils/transform.js";
|
|
6
8
|
async function loadMatcherModules(specifiers) {
|
|
7
9
|
for (const spec of specifiers ?? []) {
|
|
8
10
|
await import(spec);
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
|
-
function normalizePath(p) {
|
|
12
|
-
return p.replace(/\\/g, "/");
|
|
13
|
-
}
|
|
14
13
|
export async function runEngine(options) {
|
|
15
14
|
const { files } = options;
|
|
16
15
|
clearContext();
|
|
@@ -28,7 +27,7 @@ export async function runEngine(options) {
|
|
|
28
27
|
await import(toImportUrl(file, "bundle-test"));
|
|
29
28
|
}
|
|
30
29
|
catch (err) {
|
|
31
|
-
const error =
|
|
30
|
+
const error = toError(err);
|
|
32
31
|
fileSuite.errors.push({
|
|
33
32
|
label: "import",
|
|
34
33
|
error,
|
package/dist/esm/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/runner.ts"],"names":[],"mappings":"AAgBA,UAAU,aAAa;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA2MD,wBAAsB,WAAW,CAAC,OAAO,GAAE,aAAkB,iBA2T5D"}
|