@dunx/testing 1.2.1 → 1.3.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/README.md +16 -12
- 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
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
module
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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.
|
|
3
|
+
"version": "1.3.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.
|
|
55
|
-
"@dunx/http": "^1.
|
|
54
|
+
"@dunx/core": "^1.3.0",
|
|
55
|
+
"@dunx/http": "^1.3.0",
|
|
56
56
|
"@types/bun": ">=1.3.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|