@dunx/testing 1.2.1 → 2.0.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.
Files changed (2) hide show
  1. package/README.md +16 -12
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -29,18 +29,22 @@ await server.close();
29
29
 
30
30
  ## Overrides replace; they never append
31
31
 
32
- This is the whole design, and it follows from the container being flat.
33
-
34
- `@dunx/core` collects every module's registrations into one list and **throws on a
35
- duplicate token**, naming both modules. So a test override cannot be an extra
36
- module appended at the end that wins - there is no "wins". It would be a duplicate.
37
-
38
- `createTestApp` therefore assembles the same flat list the app would have and
39
- substitutes by token as it goes. Three consequences worth relying on:
40
-
41
- - **The count per token never changes.** The duplicate-binding check runs
42
- unmodified, so a test cannot paper over a wiring bug that boot would have caught.
43
- Two modules binding one token still fails, with the override applied to both.
32
+ This is the whole design, and it follows from how `@dunx/core` applies an override:
33
+ by **substitution into the binding that already exists**, never by appending a
34
+ registration that has to out-rank the real one.
35
+
36
+ A module is a scope, and `providers` are private to it. So a test override cannot be
37
+ an extra module appended at the end that wins - an appended module's providers are
38
+ invisible to every scope that does not import it, which is exactly the scope the
39
+ code under test resolves from.
40
+
41
+ `createTestApp` therefore builds the same scope graph the app would have and
42
+ substitutes by token inside it. Three consequences worth relying on:
43
+
44
+ - **An override replaces the binding in every scope that holds it.** A test stubbing
45
+ `Logger` does not have to know how many modules bind it, and does not have to name
46
+ a scope. Where two scopes genuinely bind one token differently and only one is
47
+ meant, resolve through the module you care about instead.
44
48
  - **An override naming a token nobody binds is an error**, not a silent no-op. A
45
49
  typo'd token would otherwise leave the suite asserting against the real provider
46
50
  it thought it had swapped, which is the failure mode this package exists to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dunx/testing",
3
- "version": "1.2.1",
3
+ "version": "2.0.0",
4
4
  "description": "Test harness for dunx apps: a container with providers replaced in place, and a real Bun.serve on port 0",
5
5
  "keywords": [
6
6
  "bun",
@@ -51,8 +51,8 @@
51
51
  "@dunx/http": "workspace:*"
52
52
  },
53
53
  "peerDependencies": {
54
- "@dunx/core": "^1.2.1",
55
- "@dunx/http": "^1.2.1",
54
+ "@dunx/core": "^2.0.0",
55
+ "@dunx/http": "^2.0.0",
56
56
  "@types/bun": ">=1.3.0"
57
57
  },
58
58
  "peerDependenciesMeta": {