proby 0.13.1 → 0.13.3
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/README.md +34 -65
- package/lib/Schema.d.ts +0 -1
- package/lib/Schema.js +0 -1
- package/lib/bin.js +21 -12
- package/lib/config.d.ts +0 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@ Test runner for JavaScript runtimes.
|
|
|
6
6
|
|
|
7
7
|
A cross-runtime test runner that automatically discovers and runs test files.
|
|
8
8
|
Works with both single repositories and monorepos. Supports TypeScript source
|
|
9
|
-
execution in monorepos without a build step when your packages expose
|
|
10
|
-
|
|
11
|
-
consistently across Node, Deno, and Bun.
|
|
9
|
+
execution in monorepos without a build step when your packages expose a custom
|
|
10
|
+
source condition in `package.json`. Uses `@rcompat/test` for writing tests.
|
|
11
|
+
Works consistently across Node, Deno, and Bun.
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
@@ -58,41 +58,50 @@ npx proby math.spec.ts addition
|
|
|
58
58
|
|
|
59
59
|
## How proby resolves source files
|
|
60
60
|
|
|
61
|
-
Proby
|
|
62
|
-
|
|
63
|
-
`imports` and `exports` to your TypeScript source files
|
|
64
|
-
JavaScript.
|
|
61
|
+
Proby reads `compilerOptions.customConditions` from your `tsconfig.json` and
|
|
62
|
+
relaunches itself with those conditions active before running tests. This lets
|
|
63
|
+
Node resolve package `imports` and `exports` to your TypeScript source files
|
|
64
|
+
instead of built JavaScript — no build step required.
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
Use a condition scoped to your project to avoid conflicts when multiple
|
|
67
|
+
monorepos share `node_modules`:
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"compilerOptions": {
|
|
72
|
+
"customConditions": ["@myproject/source"]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
70
76
|
|
|
71
|
-
|
|
77
|
+
Then expose matching entries in your packages:
|
|
72
78
|
|
|
73
79
|
```json
|
|
74
80
|
{
|
|
75
81
|
"imports": {
|
|
76
82
|
"#*": {
|
|
77
|
-
"source": "./src/*.ts",
|
|
78
|
-
"default": "./lib/*.js"
|
|
83
|
+
"@myproject/source": "./src/private/*.ts",
|
|
84
|
+
"default": "./lib/private/*.js"
|
|
79
85
|
}
|
|
80
86
|
},
|
|
81
87
|
"exports": {
|
|
82
88
|
".": {
|
|
83
|
-
"source": "./src/index.ts",
|
|
84
|
-
"default": "./lib/index.js"
|
|
89
|
+
"@myproject/source": "./src/public/index.ts",
|
|
90
|
+
"default": "./lib/public/index.js"
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
```
|
|
89
95
|
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
Because TypeScript reads the same `customConditions`, your editor's
|
|
97
|
+
jump-to-source also lands on the `.ts` source file — not compiled output.
|
|
98
|
+
|
|
99
|
+
The opt-in is per package and entirely additive. Packages without the condition
|
|
100
|
+
fall back to built output as normal.
|
|
92
101
|
|
|
93
102
|
## Configuration
|
|
94
103
|
|
|
95
|
-
Create `proby.config.ts` or `proby.config.js` in your project root
|
|
104
|
+
Create `proby.config.ts` or `proby.config.js` in your project root:
|
|
96
105
|
|
|
97
106
|
```ts
|
|
98
107
|
import config from "proby/config";
|
|
@@ -101,7 +110,6 @@ export default config({
|
|
|
101
110
|
monorepo: true,
|
|
102
111
|
packages: "packages",
|
|
103
112
|
include: ["src"],
|
|
104
|
-
conditions: ["source"],
|
|
105
113
|
});
|
|
106
114
|
```
|
|
107
115
|
|
|
@@ -115,11 +123,7 @@ boolean
|
|
|
115
123
|
|
|
116
124
|
Whether proby should scan package directories inside a monorepo.
|
|
117
125
|
|
|
118
|
-
Default:
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
false
|
|
122
|
-
```
|
|
126
|
+
Default: `false`
|
|
123
127
|
|
|
124
128
|
#### `packages`
|
|
125
129
|
|
|
@@ -129,11 +133,7 @@ string
|
|
|
129
133
|
|
|
130
134
|
Directory containing package folders when `monorepo` is enabled.
|
|
131
135
|
|
|
132
|
-
Default:
|
|
133
|
-
|
|
134
|
-
```ts
|
|
135
|
-
"packages"
|
|
136
|
-
```
|
|
136
|
+
Default: `"packages"`
|
|
137
137
|
|
|
138
138
|
#### `include`
|
|
139
139
|
|
|
@@ -143,30 +143,10 @@ string[]
|
|
|
143
143
|
|
|
144
144
|
Directories to scan for spec files.
|
|
145
145
|
|
|
146
|
-
Default:
|
|
147
|
-
|
|
148
|
-
```ts
|
|
149
|
-
["src"]
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
#### `conditions`
|
|
153
|
-
|
|
154
|
-
```ts
|
|
155
|
-
string[]
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
Runtime conditions used when proby relaunches itself.
|
|
159
|
-
|
|
160
|
-
Default:
|
|
161
|
-
|
|
162
|
-
```ts
|
|
163
|
-
["source"]
|
|
164
|
-
```
|
|
146
|
+
Default: `["src"]`
|
|
165
147
|
|
|
166
148
|
## Project structure
|
|
167
149
|
|
|
168
|
-
Proby automatically detects your project structure.
|
|
169
|
-
|
|
170
150
|
### Single repository
|
|
171
151
|
|
|
172
152
|
```text
|
|
@@ -206,7 +186,7 @@ my-monorepo/
|
|
|
206
186
|
|
|
207
187
|
Proby supports preloading sibling mock files before a spec file is evaluated.
|
|
208
188
|
This allows module mocks to be registered before the spec's static imports are
|
|
209
|
-
|
|
189
|
+
resolved.
|
|
210
190
|
|
|
211
191
|
Pair files by matching the spec extension exactly:
|
|
212
192
|
|
|
@@ -215,15 +195,6 @@ Pair files by matching the spec extension exactly:
|
|
|
215
195
|
|
|
216
196
|
If a sibling mock file exists, proby loads it before the spec file.
|
|
217
197
|
|
|
218
|
-
Example:
|
|
219
|
-
|
|
220
|
-
```ts
|
|
221
|
-
// math.ts
|
|
222
|
-
export function add(a: number, b: number) {
|
|
223
|
-
return a + b;
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
198
|
```ts
|
|
228
199
|
// math.mock.ts
|
|
229
200
|
import test from "@rcompat/test";
|
|
@@ -243,13 +214,12 @@ test.case("uses the preloaded mock", assert => {
|
|
|
243
214
|
});
|
|
244
215
|
```
|
|
245
216
|
|
|
246
|
-
Static mocks are file-scoped
|
|
247
|
-
into later spec files.
|
|
217
|
+
Static mocks are file-scoped — they do not leak into later spec files.
|
|
248
218
|
|
|
249
219
|
## Grouping tests
|
|
250
220
|
|
|
251
|
-
Use `test.group`
|
|
252
|
-
|
|
221
|
+
Use `test.group` to cluster related cases. Groups can be targeted individually
|
|
222
|
+
when running proby:
|
|
253
223
|
|
|
254
224
|
```js
|
|
255
225
|
import test from "@rcompat/test";
|
|
@@ -383,4 +353,3 @@ MIT
|
|
|
383
353
|
## Contributing
|
|
384
354
|
|
|
385
355
|
See [CONTRIBUTING.md](../../CONTRIBUTING.md) in the repository root.
|
|
386
|
-
|
package/lib/Schema.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ declare const Schema: import("pema").ObjectType<{
|
|
|
2
2
|
monorepo: import("pema").DefaultType<import("pema").BooleanType, false>;
|
|
3
3
|
packages: import("pema").DefaultType<import("pema").StringType, "packages">;
|
|
4
4
|
include: import("pema").DefaultType<import("pema").ArrayType<import("pema").StringType>, string[]>;
|
|
5
|
-
conditions: import("pema").DefaultType<import("pema").ArrayType<import("pema").StringType>, string[]>;
|
|
6
5
|
}>;
|
|
7
6
|
export default Schema;
|
|
8
7
|
//# sourceMappingURL=Schema.d.ts.map
|
package/lib/Schema.js
CHANGED
package/lib/bin.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import Schema from "#Schema";
|
|
3
3
|
import env from "@rcompat/env";
|
|
4
4
|
import fs from "@rcompat/fs";
|
|
5
5
|
import io from "@rcompat/io";
|
|
6
6
|
import is from "@rcompat/is";
|
|
7
7
|
import runtime from "@rcompat/runtime";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
async function read_conditions(file) {
|
|
9
|
+
const json = await file.json();
|
|
10
|
+
if (json.compilerOptions?.customConditions?.length) {
|
|
11
|
+
return json.compilerOptions.customConditions;
|
|
12
|
+
}
|
|
13
|
+
if (json.extends === undefined) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const next = await runtime.resolve(json.extends, file.directory.path);
|
|
17
|
+
return read_conditions(fs.ref(next));
|
|
18
|
+
}
|
|
14
19
|
const root = await fs.project.root();
|
|
15
20
|
const ts_config_file = root.join("proby.config.ts");
|
|
16
21
|
const js_config_file = root.join("proby.config.js");
|
|
@@ -19,14 +24,18 @@ const user_config = await ts_config_file.exists()
|
|
|
19
24
|
: await js_config_file.exists()
|
|
20
25
|
? (await js_config_file.import("default"))
|
|
21
26
|
: {};
|
|
22
|
-
const { include, packages,
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
const { include, packages, monorepo } = Schema.parse(user_config);
|
|
28
|
+
const ts_config = root.join("tsconfig.json");
|
|
29
|
+
const conditions = await ts_config.exists()
|
|
30
|
+
? await read_conditions(ts_config)
|
|
31
|
+
: [];
|
|
32
|
+
const conditions_flags = conditions
|
|
33
|
+
.map(c => ` --conditions="${c}"`)
|
|
34
|
+
.join("");
|
|
26
35
|
const script = runtime.script;
|
|
27
36
|
const args = runtime.args.join(" ");
|
|
28
37
|
if (!is.defined(env.try("PROBY_RELAUNCHED"))) {
|
|
29
|
-
await io.spawn(`${runtime.bin}
|
|
38
|
+
await io.spawn(`${runtime.bin}${conditions_flags} ${script} ${args}`, {
|
|
30
39
|
inherit: true,
|
|
31
40
|
env: { ...process.env, PROBY_RELAUNCHED: "1" },
|
|
32
41
|
});
|
package/lib/config.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ declare const _default: (input: typeof Schema.input) => {
|
|
|
3
3
|
monorepo?: boolean | undefined;
|
|
4
4
|
packages?: string | undefined;
|
|
5
5
|
include?: string[] | undefined;
|
|
6
|
-
conditions?: string[] | undefined;
|
|
7
6
|
} | undefined;
|
|
8
7
|
export default _default;
|
|
9
8
|
//# sourceMappingURL=config.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "proby",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"description": "Standard library test runner",
|
|
5
5
|
"bugs": "https://github.com/rcompat/rcompat/issues",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"pema": "^0.5.0",
|
|
20
|
-
"@rcompat/assert": "^0.8.
|
|
21
|
-
"@rcompat/cli": "^0.18.
|
|
22
|
-
"@rcompat/
|
|
23
|
-
"@rcompat/
|
|
24
|
-
"@rcompat/io": "^0.5.
|
|
25
|
-
"@rcompat/is": "^0.6.
|
|
26
|
-
"@rcompat/runtime": "^0.11.
|
|
20
|
+
"@rcompat/assert": "^0.8.1",
|
|
21
|
+
"@rcompat/cli": "^0.18.1",
|
|
22
|
+
"@rcompat/fs": "^0.28.1",
|
|
23
|
+
"@rcompat/env": "^0.17.1",
|
|
24
|
+
"@rcompat/io": "^0.5.1",
|
|
25
|
+
"@rcompat/is": "^0.6.1",
|
|
26
|
+
"@rcompat/runtime": "^0.11.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@rcompat/test": "^0.12.
|
|
29
|
+
"@rcompat/test": "^0.12.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependenciesMeta": {
|
|
32
32
|
"@rcompat/test": {
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"type": "module",
|
|
37
37
|
"imports": {
|
|
38
38
|
"#*": {
|
|
39
|
-
"source": "./src/*.ts",
|
|
39
|
+
"@rcompat/source": "./src/*.ts",
|
|
40
40
|
"default": "./lib/*.js"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"exports": {
|
|
44
44
|
"./config": {
|
|
45
|
-
"source": "./src/config.ts",
|
|
45
|
+
"@rcompat/source": "./src/config.ts",
|
|
46
46
|
"default": "./lib/config.js"
|
|
47
47
|
}
|
|
48
48
|
},
|