@fluojs/testing 1.0.3 → 1.0.4
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.ko.md +1 -3
- package/README.md +1 -3
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +39 -5
- package/package.json +9 -9
package/README.ko.md
CHANGED
|
@@ -165,10 +165,8 @@ fluo는 테스트가 명시적인 `rootModule`을 이름으로 지정해야 한
|
|
|
165
165
|
|
|
166
166
|
## 공개 API
|
|
167
167
|
|
|
168
|
-
- **루트 패키지**: `createTestingModule(...)`, `createTestApp(...)`, 모듈 introspection 헬퍼, 공용 테스트 타입
|
|
168
|
+
- **루트 패키지**: `createTestingModule(...)`, `Test.createTestingModule(...)`, `createTestApp(...)`, 모듈 introspection 헬퍼, 공용 테스트 타입
|
|
169
169
|
- **서브패스**: `@fluojs/testing/app`, `@fluojs/testing/module`, `@fluojs/testing/http`, `@fluojs/testing/mock`, `@fluojs/testing/types`, `@fluojs/testing/vitest`, `@fluojs/testing/vitest/tooling`
|
|
170
|
-
- **Mock 서브패스**: `@fluojs/testing/mock`
|
|
171
|
-
- **HTTP 헬퍼**: `@fluojs/testing/http`
|
|
172
170
|
- **하니스 서브패스**: `platform-conformance`, `http-adapter-portability`, `web-runtime-adapter-portability`, `fetch-style-websocket-conformance`
|
|
173
171
|
- **도구 지원**: `@fluojs/testing/vitest`의 `fluoBabelDecoratorsPlugin()` 및 `@fluojs/testing/vitest/tooling`의 Vitest workspace config helper (`vitest`와 `@babel/core`를 함께 요구)
|
|
174
172
|
|
package/README.md
CHANGED
|
@@ -163,10 +163,8 @@ fluo differs from NestJS by requiring tests to name an explicit `rootModule`. Th
|
|
|
163
163
|
|
|
164
164
|
## Public API
|
|
165
165
|
|
|
166
|
-
- **Root package**: `createTestingModule(...)`, `createTestApp(...)`, module introspection helpers, shared testing types
|
|
166
|
+
- **Root package**: `createTestingModule(...)`, `Test.createTestingModule(...)`, `createTestApp(...)`, module introspection helpers, shared testing types
|
|
167
167
|
- **Subpaths**: `@fluojs/testing/app`, `@fluojs/testing/module`, `@fluojs/testing/http`, `@fluojs/testing/mock`, `@fluojs/testing/types`, `@fluojs/testing/vitest`, `@fluojs/testing/vitest/tooling`
|
|
168
|
-
- **Mock subpath**: `@fluojs/testing/mock`
|
|
169
|
-
- **HTTP helpers**: `@fluojs/testing/http`
|
|
170
168
|
- **Harness subpaths**: `platform-conformance`, `http-adapter-portability`, `web-runtime-adapter-portability`, `fetch-style-websocket-conformance`
|
|
171
169
|
- **Tooling**: `@fluojs/testing/vitest` with `fluoBabelDecoratorsPlugin()` and `@fluojs/testing/vitest/tooling` with Vitest workspace config helpers (requires `vitest` and `@babel/core` in the consuming workspace)
|
|
172
170
|
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EAId,KAAK,QAAQ,EAEd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAqC,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMrF,OAAO,KAAK,EAA2B,oBAAoB,EAAE,oBAAoB,EAAoB,MAAM,YAAY,CAAC;AAExH;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,EAAE,CAQzE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,EAAE,CAQ5E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,EAAE,CAQzE;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EAId,KAAK,QAAQ,EAEd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAqC,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMrF,OAAO,KAAK,EAA2B,oBAAoB,EAAE,oBAAoB,EAAoB,MAAM,YAAY,CAAC;AAExH;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,EAAE,CAQzE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,EAAE,CAQ5E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,EAAE,CAQzE;AAqyBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,oBAAoB,CAEvF;AAED;;GAEG;AACH,eAAO,MAAM,IAAI;;CAEhB,CAAC"}
|
package/dist/module.js
CHANGED
|
@@ -126,14 +126,37 @@ function effectiveProvidersForToken(introspection, token) {
|
|
|
126
126
|
return provider ? [provider] : [];
|
|
127
127
|
}
|
|
128
128
|
function isSingletonLifecycleProvider(provider) {
|
|
129
|
-
if (provider.multi === true) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
129
|
if (provider.scope !== Scope.DEFAULT) {
|
|
133
130
|
return false;
|
|
134
131
|
}
|
|
135
132
|
return provider.type === 'class' || provider.type === 'value' && hasAnyBootstrapLifecycleHook(provider.useValue);
|
|
136
133
|
}
|
|
134
|
+
async function resolveLifecycleDependency(entry, bootstrapped, introspection) {
|
|
135
|
+
if (isOptionalToken(entry) && !hasTokenInContainer(introspection, entry.token)) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
return bootstrapped.container.resolve(dependencyToken(entry));
|
|
139
|
+
}
|
|
140
|
+
async function instantiateLifecycleProvider(provider, bootstrapped, introspection) {
|
|
141
|
+
if (provider.type !== 'class' || !provider.useClass) {
|
|
142
|
+
throw new Error(`Lifecycle provider ${String(provider.provide)} must use a class provider.`);
|
|
143
|
+
}
|
|
144
|
+
const dependencies = await Promise.all(provider.inject.map(entry => resolveLifecycleDependency(entry, bootstrapped, introspection)));
|
|
145
|
+
return new provider.useClass(...dependencies);
|
|
146
|
+
}
|
|
147
|
+
async function resolveMultiLifecycleProvider(provider, bootstrapped, introspection) {
|
|
148
|
+
const cache = rootContainerIntrospection(introspection).multiSingletonCache;
|
|
149
|
+
const cached = cache.get(provider);
|
|
150
|
+
if (cached) {
|
|
151
|
+
return cached;
|
|
152
|
+
}
|
|
153
|
+
const instance = instantiateLifecycleProvider(provider, bootstrapped, introspection).catch(error => {
|
|
154
|
+
cache.delete(provider);
|
|
155
|
+
throw error;
|
|
156
|
+
});
|
|
157
|
+
cache.set(provider, instance);
|
|
158
|
+
return instance;
|
|
159
|
+
}
|
|
137
160
|
async function resolveTestingLifecycleInstances(bootstrapped, overrides = []) {
|
|
138
161
|
const lifecycleProviders = [...bootstrapped.effectiveProviders.runtimeProviders, ...bootstrapped.effectiveProviders.moduleProviders, ...overrides];
|
|
139
162
|
const instances = [];
|
|
@@ -142,7 +165,11 @@ async function resolveTestingLifecycleInstances(bootstrapped, overrides = []) {
|
|
|
142
165
|
for (const provider of lifecycleProviders) {
|
|
143
166
|
const token = providerToken(provider);
|
|
144
167
|
const effectiveProviders = effectiveProvidersForToken(introspection, token);
|
|
145
|
-
for (
|
|
168
|
+
for (let index = 0; index < effectiveProviders.length; index += 1) {
|
|
169
|
+
const effectiveProvider = effectiveProviders[index];
|
|
170
|
+
if (!effectiveProvider) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
146
173
|
if (seenProviders.has(effectiveProvider)) {
|
|
147
174
|
continue;
|
|
148
175
|
}
|
|
@@ -155,6 +182,10 @@ async function resolveTestingLifecycleInstances(bootstrapped, overrides = []) {
|
|
|
155
182
|
continue;
|
|
156
183
|
}
|
|
157
184
|
try {
|
|
185
|
+
if (effectiveProvider.multi === true) {
|
|
186
|
+
instances.push(await resolveMultiLifecycleProvider(effectiveProvider, bootstrapped, introspection));
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
158
189
|
instances.push(await bootstrapped.container.resolve(token));
|
|
159
190
|
} catch (error) {
|
|
160
191
|
if (error instanceof Error && error.message.includes('Request-scoped provider')) {
|
|
@@ -195,7 +226,10 @@ function lookupProvider(target, token) {
|
|
|
195
226
|
return target.parent ? lookupProvider(target.parent, token) : undefined;
|
|
196
227
|
}
|
|
197
228
|
function hasToken(state, token) {
|
|
198
|
-
return
|
|
229
|
+
return hasTokenInContainer(state.introspection, token);
|
|
230
|
+
}
|
|
231
|
+
function hasTokenInContainer(introspection, token) {
|
|
232
|
+
return lookupProvider(introspection, token) !== undefined || collectMultiProviders(introspection, token).length > 0;
|
|
199
233
|
}
|
|
200
234
|
function dependencyToken(entry) {
|
|
201
235
|
if (isOptionalToken(entry)) {
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"override",
|
|
10
10
|
"module-builder"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.
|
|
12
|
+
"version": "1.0.4",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -80,11 +80,11 @@
|
|
|
80
80
|
"dist"
|
|
81
81
|
],
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@fluojs/core": "^1.0.3",
|
|
84
83
|
"@fluojs/config": "^1.0.2",
|
|
84
|
+
"@fluojs/core": "^1.0.3",
|
|
85
85
|
"@fluojs/http": "^1.1.0",
|
|
86
86
|
"@fluojs/di": "^1.0.3",
|
|
87
|
-
"@fluojs/runtime": "^1.1.
|
|
87
|
+
"@fluojs/runtime": "^1.1.2"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"@babel/core": ">=7.0.0",
|
|
@@ -92,12 +92,12 @@
|
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"vitest": "^3.2.4",
|
|
95
|
-
"@fluojs/platform-bun": "^1.0.
|
|
96
|
-
"@fluojs/platform-
|
|
97
|
-
"@fluojs/platform-
|
|
98
|
-
"@fluojs/platform-
|
|
99
|
-
"@fluojs/platform-
|
|
100
|
-
"@fluojs/platform-
|
|
95
|
+
"@fluojs/platform-bun": "^1.0.3",
|
|
96
|
+
"@fluojs/platform-cloudflare-workers": "^1.0.3",
|
|
97
|
+
"@fluojs/platform-deno": "^1.0.4",
|
|
98
|
+
"@fluojs/platform-nodejs": "^1.0.3",
|
|
99
|
+
"@fluojs/platform-express": "^1.0.3",
|
|
100
|
+
"@fluojs/platform-fastify": "^1.0.4"
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
103
|
"prebuild": "node ../../tooling/scripts/clean-dist.mjs",
|