proby 0.13.2 → 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 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 `source`
10
- entries in `package.json`. Uses `@rcompat/test` for writing tests. Works
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 relaunches itself with runtime conditions before running tests. By
62
- default it uses the `source` condition, which lets runtimes resolve package
63
- `imports` and `exports` to your TypeScript source files instead of built
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
- This is especially useful in monorepos where packages depend on each other and
67
- you want to run tests against source directly.
66
+ Use a condition scoped to your project to avoid conflicts when multiple
67
+ monorepos share `node_modules`:
68
68
 
69
- To use this pattern, expose `source` entries in your packages.
69
+ ```json
70
+ {
71
+ "compilerOptions": {
72
+ "customConditions": ["@myproject/source"]
73
+ }
74
+ }
75
+ ```
70
76
 
71
- Example:
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
- With this setup, proby can run against your TypeScript source without requiring
91
- an upfront build step.
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
- read.
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. A mock loaded for one spec file does not leak
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` in your spec files to cluster related cases. Groups can then
252
- be targeted individually when running proby.
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
@@ -3,7 +3,6 @@ const Schema = p({
3
3
  monorepo: p.boolean.default(false),
4
4
  packages: p.string.default("packages"),
5
5
  include: p.array(p.string).default(["src"]),
6
- conditions: p.array(p.string).default(["source", "default"]),
7
6
  });
8
7
  export default Schema;
9
8
  //# sourceMappingURL=Schema.js.map
package/lib/bin.js CHANGED
@@ -1,10 +1,21 @@
1
1
  #!/usr/bin/env node
2
+ import Schema from "#Schema";
2
3
  import env from "@rcompat/env";
3
4
  import fs from "@rcompat/fs";
4
5
  import io from "@rcompat/io";
5
6
  import is from "@rcompat/is";
6
7
  import runtime from "@rcompat/runtime";
7
- import Schema from "./Schema.js";
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
+ }
8
19
  const root = await fs.project.root();
9
20
  const ts_config_file = root.join("proby.config.ts");
10
21
  const js_config_file = root.join("proby.config.js");
@@ -13,14 +24,18 @@ const user_config = await ts_config_file.exists()
13
24
  : await js_config_file.exists()
14
25
  ? (await js_config_file.import("default"))
15
26
  : {};
16
- const { include, packages, conditions, monorepo } = Schema.parse(user_config);
17
- const conditions_flag = conditions.length > 0
18
- ? ` --conditions=${conditions.join(",")}`
19
- : "";
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("");
20
35
  const script = runtime.script;
21
36
  const args = runtime.args.join(" ");
22
37
  if (!is.defined(env.try("PROBY_RELAUNCHED"))) {
23
- await io.spawn(`${runtime.bin} ${conditions_flag} ${script} ${args}`, {
38
+ await io.spawn(`${runtime.bin}${conditions_flags} ${script} ${args}`, {
24
39
  inherit: true,
25
40
  env: { ...process.env, PROBY_RELAUNCHED: "1" },
26
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.2",
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.0",
21
- "@rcompat/cli": "^0.18.0",
22
- "@rcompat/env": "^0.17.0",
23
- "@rcompat/fs": "^0.28.0",
24
- "@rcompat/is": "^0.6.0",
25
- "@rcompat/io": "^0.5.0",
26
- "@rcompat/runtime": "^0.11.0"
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.0"
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
  },