@stratal/testing 0.0.5 → 0.0.7
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/dist/core/testing-module-builder.d.ts +0 -42
- package/dist/core/testing-module-builder.d.ts.map +1 -1
- package/dist/core/testing-module-builder.js +9 -56
- package/dist/core/testing-module-builder.js.map +1 -1
- package/dist/core/testing-module.d.ts +8 -6
- package/dist/core/testing-module.d.ts.map +1 -1
- package/dist/core/testing-module.js +42 -55
- package/dist/core/testing-module.js.map +1 -1
- package/package.json +11 -11
- package/CHANGELOG.md +0 -117
|
@@ -24,37 +24,6 @@ export interface TestingModuleConfig extends ModuleOptions {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Builder for creating test modules with provider overrides
|
|
27
|
-
*
|
|
28
|
-
* Provides a NestJS-style fluent API for configuring test modules.
|
|
29
|
-
* Supports all ModuleOptions properties (imports, providers, controllers, consumers, jobs).
|
|
30
|
-
*
|
|
31
|
-
* @example Basic usage
|
|
32
|
-
* ```typescript
|
|
33
|
-
* const module = await Test.createTestingModule({
|
|
34
|
-
* imports: [RegistrationModule],
|
|
35
|
-
* }).compile()
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @example Provider override
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const module = await Test.createTestingModule({
|
|
41
|
-
* imports: [RegistrationModule, GeoModule],
|
|
42
|
-
* })
|
|
43
|
-
* .overrideProvider(EMAIL_TOKENS.EmailService)
|
|
44
|
-
* .useValue(mockEmailService)
|
|
45
|
-
* .compile()
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @example Full ModuleOptions
|
|
49
|
-
* ```typescript
|
|
50
|
-
* const module = await Test.createTestingModule({
|
|
51
|
-
* imports: [RegistrationModule],
|
|
52
|
-
* providers: [{ provide: MOCK_TOKEN, useValue: mockValue }],
|
|
53
|
-
* controllers: [TestController],
|
|
54
|
-
* consumers: [TestConsumer],
|
|
55
|
-
* jobs: [TestJob],
|
|
56
|
-
* }).compile()
|
|
57
|
-
* ```
|
|
58
27
|
*/
|
|
59
28
|
export declare class TestingModuleBuilder {
|
|
60
29
|
private config;
|
|
@@ -62,11 +31,6 @@ export declare class TestingModuleBuilder {
|
|
|
62
31
|
constructor(config: TestingModuleConfig);
|
|
63
32
|
/**
|
|
64
33
|
* Override a provider with a custom implementation
|
|
65
|
-
*
|
|
66
|
-
* Returns a ProviderOverrideBuilder for specifying the override type.
|
|
67
|
-
*
|
|
68
|
-
* @param token - The injection token to override
|
|
69
|
-
* @returns ProviderOverrideBuilder for chaining useValue/useClass/useFactory
|
|
70
34
|
*/
|
|
71
35
|
overrideProvider<T>(token: InjectionToken<T>): ProviderOverrideBuilder<T>;
|
|
72
36
|
/**
|
|
@@ -77,18 +41,12 @@ export declare class TestingModuleBuilder {
|
|
|
77
41
|
addProviderOverride<T>(override: ProviderOverrideConfig<T>): this;
|
|
78
42
|
/**
|
|
79
43
|
* Merge additional environment bindings
|
|
80
|
-
*
|
|
81
|
-
* @param env - Partial environment to merge
|
|
82
|
-
* @returns This builder for chaining
|
|
83
44
|
*/
|
|
84
45
|
withEnv(env: Partial<StratalEnv>): this;
|
|
85
46
|
/**
|
|
86
47
|
* Compile the testing module
|
|
87
48
|
*
|
|
88
49
|
* Creates the Application, applies overrides, initializes, and returns TestingModule.
|
|
89
|
-
* The ModuleRegistry handles all module registrations automatically.
|
|
90
|
-
*
|
|
91
|
-
* @returns Promise<TestingModule> - The compiled testing module
|
|
92
50
|
*/
|
|
93
51
|
compile(): Promise<TestingModule>;
|
|
94
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module-builder.d.ts","sourceRoot":"","sources":["../../src/core/testing-module-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,iBAAiB,EAEjB,KAAK,UAAU,EAChB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,cAAc,EAAuB,aAAa,EAAE,MA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AAC,GAAG,IAAI;IAKjE;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI;IAKvC;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IA6DvC;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAK7B"}
|
|
@@ -16,37 +16,6 @@ import { Test } from './test';
|
|
|
16
16
|
import { TestingModule } from './testing-module';
|
|
17
17
|
/**
|
|
18
18
|
* Builder for creating test modules with provider overrides
|
|
19
|
-
*
|
|
20
|
-
* Provides a NestJS-style fluent API for configuring test modules.
|
|
21
|
-
* Supports all ModuleOptions properties (imports, providers, controllers, consumers, jobs).
|
|
22
|
-
*
|
|
23
|
-
* @example Basic usage
|
|
24
|
-
* ```typescript
|
|
25
|
-
* const module = await Test.createTestingModule({
|
|
26
|
-
* imports: [RegistrationModule],
|
|
27
|
-
* }).compile()
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @example Provider override
|
|
31
|
-
* ```typescript
|
|
32
|
-
* const module = await Test.createTestingModule({
|
|
33
|
-
* imports: [RegistrationModule, GeoModule],
|
|
34
|
-
* })
|
|
35
|
-
* .overrideProvider(EMAIL_TOKENS.EmailService)
|
|
36
|
-
* .useValue(mockEmailService)
|
|
37
|
-
* .compile()
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @example Full ModuleOptions
|
|
41
|
-
* ```typescript
|
|
42
|
-
* const module = await Test.createTestingModule({
|
|
43
|
-
* imports: [RegistrationModule],
|
|
44
|
-
* providers: [{ provide: MOCK_TOKEN, useValue: mockValue }],
|
|
45
|
-
* controllers: [TestController],
|
|
46
|
-
* consumers: [TestConsumer],
|
|
47
|
-
* jobs: [TestJob],
|
|
48
|
-
* }).compile()
|
|
49
|
-
* ```
|
|
50
19
|
*/
|
|
51
20
|
export class TestingModuleBuilder {
|
|
52
21
|
config;
|
|
@@ -56,11 +25,6 @@ export class TestingModuleBuilder {
|
|
|
56
25
|
}
|
|
57
26
|
/**
|
|
58
27
|
* Override a provider with a custom implementation
|
|
59
|
-
*
|
|
60
|
-
* Returns a ProviderOverrideBuilder for specifying the override type.
|
|
61
|
-
*
|
|
62
|
-
* @param token - The injection token to override
|
|
63
|
-
* @returns ProviderOverrideBuilder for chaining useValue/useClass/useFactory
|
|
64
28
|
*/
|
|
65
29
|
overrideProvider(token) {
|
|
66
30
|
return new ProviderOverrideBuilder(this, token);
|
|
@@ -76,9 +40,6 @@ export class TestingModuleBuilder {
|
|
|
76
40
|
}
|
|
77
41
|
/**
|
|
78
42
|
* Merge additional environment bindings
|
|
79
|
-
*
|
|
80
|
-
* @param env - Partial environment to merge
|
|
81
|
-
* @returns This builder for chaining
|
|
82
43
|
*/
|
|
83
44
|
withEnv(env) {
|
|
84
45
|
this.config.env = { ...this.config.env, ...env };
|
|
@@ -88,20 +49,13 @@ export class TestingModuleBuilder {
|
|
|
88
49
|
* Compile the testing module
|
|
89
50
|
*
|
|
90
51
|
* Creates the Application, applies overrides, initializes, and returns TestingModule.
|
|
91
|
-
* The ModuleRegistry handles all module registrations automatically.
|
|
92
|
-
*
|
|
93
|
-
* @returns Promise<TestingModule> - The compiled testing module
|
|
94
52
|
*/
|
|
95
53
|
async compile() {
|
|
96
|
-
// 1. Create environment (cloudflare:test base + overrides)
|
|
97
54
|
const env = getTestEnv(this.config.env);
|
|
98
|
-
// 2. Create ExecutionContext
|
|
99
55
|
const ctx = createExecutionContext();
|
|
100
|
-
//
|
|
56
|
+
// Build root module from config
|
|
101
57
|
const baseModules = Test.getBaseModules();
|
|
102
|
-
const
|
|
103
|
-
const allImports = [...baseModules, ...configImports];
|
|
104
|
-
// Create root module with all config properties
|
|
58
|
+
const allImports = [...baseModules, ...(this.config.imports ?? [])];
|
|
105
59
|
const rootModule = this.createTestRootModule({
|
|
106
60
|
imports: allImports,
|
|
107
61
|
providers: this.config.providers,
|
|
@@ -109,20 +63,18 @@ export class TestingModuleBuilder {
|
|
|
109
63
|
consumers: this.config.consumers,
|
|
110
64
|
jobs: this.config.jobs,
|
|
111
65
|
});
|
|
112
|
-
|
|
113
|
-
const app = new Application(env, ctx, {
|
|
66
|
+
const app = new Application({
|
|
114
67
|
module: rootModule,
|
|
115
68
|
logging: {
|
|
116
69
|
level: this.config.logging?.level ?? LogLevel.ERROR,
|
|
117
70
|
formatter: this.config.logging?.formatter ?? 'pretty',
|
|
118
71
|
},
|
|
72
|
+
env,
|
|
73
|
+
ctx,
|
|
119
74
|
});
|
|
120
|
-
//
|
|
121
|
-
await app.initialize();
|
|
122
|
-
// 5. Auto-register FakeStorageService as singleton (can be overridden by user)
|
|
123
|
-
// Must be singleton so files uploaded in setup are available when consumers run
|
|
75
|
+
// Auto-register FakeStorageService (can be overridden by user)
|
|
124
76
|
app.container.registerSingleton(STORAGE_TOKENS.StorageService, FakeStorageService);
|
|
125
|
-
//
|
|
77
|
+
// Apply user overrides BEFORE initialize
|
|
126
78
|
for (const override of this.overrides) {
|
|
127
79
|
switch (override.type) {
|
|
128
80
|
case 'value':
|
|
@@ -139,7 +91,8 @@ export class TestingModuleBuilder {
|
|
|
139
91
|
break;
|
|
140
92
|
}
|
|
141
93
|
}
|
|
142
|
-
|
|
94
|
+
await app.initialize();
|
|
95
|
+
return new TestingModule(app, env, ctx);
|
|
143
96
|
}
|
|
144
97
|
/**
|
|
145
98
|
* Create a test root module with the given options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module-builder.js","sourceRoot":"","sources":["../../src/core/testing-module-builder.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EACL,WAAW,GAIZ,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAkB,MAAM,EAA8B,MAAM,gBAAgB,CAAA;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA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BAAkB,CAAC,CAAA;QAElF,yCAAyC;QACzC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACtB,KAAK,OAAO;oBACV,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAA;oBACpE,MAAK;gBACP,KAAK,OAAO;oBACV,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAC7B,QAAQ,CAAC,KAAK,EACd,QAAQ,CAAC,cAA6B,CACvC,CAAA;oBACD,MAAK;gBACP,KAAK,SAAS;oBACZ,GAAG,CAAC,SAAS,CAAC,eAAe,CAC3B,QAAQ,CAAC,KAAK,EACd,QAAQ,CAAC,cAA0C,CACpD,CAAA;oBACD,MAAK;gBACP,KAAK,UAAU;oBACb,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAC5B,QAAQ,CAAC,KAAK,EACd,QAAQ,CAAC,cAAwC,CAClD,CAAA;oBACD,MAAK;YACT,CAAC;QACH,CAAC;QAED,MAAM,GAAG,CAAC,UAAU,EAAE,CAAA;QAEtB,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IACzC,CAAC;IAED;;OAEG;IACK,oBAAoB,CAAC,OAAsB;QAEjD,IAAM,cAAc,GAApB,MAAM,cAAc;SAAI,CAAA;QAAlB,cAAc;YADnB,MAAM,CAAC,OAAO,CAAC;WACV,cAAc,CAAI;QACxB,OAAO,cAAc,CAAA;IACvB,CAAC;CACF"}
|
|
@@ -37,8 +37,10 @@ import { TestHttpClient } from './http/test-http-client';
|
|
|
37
37
|
export declare class TestingModule {
|
|
38
38
|
private readonly app;
|
|
39
39
|
private readonly env;
|
|
40
|
+
private readonly ctx;
|
|
40
41
|
private _http;
|
|
41
|
-
|
|
42
|
+
private readonly _requestContainer;
|
|
43
|
+
constructor(app: Application, env: StratalEnv, ctx: ExecutionContext);
|
|
42
44
|
/**
|
|
43
45
|
* Resolve a service from the container
|
|
44
46
|
*/
|
|
@@ -56,22 +58,22 @@ export declare class TestingModule {
|
|
|
56
58
|
*/
|
|
57
59
|
get application(): Application;
|
|
58
60
|
/**
|
|
59
|
-
* Get DI Container
|
|
61
|
+
* Get DI Container (request-scoped)
|
|
60
62
|
*/
|
|
61
63
|
get container(): Container;
|
|
62
64
|
/**
|
|
63
|
-
* Execute an HTTP request through
|
|
65
|
+
* Execute an HTTP request through HonoApp
|
|
64
66
|
*/
|
|
65
67
|
fetch(request: Request): Promise<Response>;
|
|
66
68
|
/**
|
|
67
69
|
* Run callback in request scope (for DB operations, service access)
|
|
68
70
|
*/
|
|
69
|
-
runInRequestScope<T>(callback: () => T | Promise<T>): Promise<T>;
|
|
71
|
+
runInRequestScope<T>(callback: (container: Container) => T | Promise<T>): Promise<T>;
|
|
70
72
|
/**
|
|
71
73
|
* Get database service instance (resolved in request scope)
|
|
72
74
|
*/
|
|
73
|
-
getDb():
|
|
74
|
-
getDb<K extends ConnectionName>(name: K):
|
|
75
|
+
getDb(): DatabaseService;
|
|
76
|
+
getDb<K extends ConnectionName>(name: K): DatabaseService<K>;
|
|
75
77
|
/**
|
|
76
78
|
* Truncate all non-prisma tables in the database
|
|
77
79
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module.d.ts","sourceRoot":"","sources":["../../src/core/testing-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAElF,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"testing-module.d.ts","sourceRoot":"","sources":["../../src/core/testing-module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AAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAK1F;;OAEG;IACH,KAAK,IAAI,eAAe;IACxB,KAAK,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;IAM5D;;OAEG;IACG,UAAU,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAYtD;;OAEG;IACG,IAAI,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IACzC,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBrE;;OAEG;IACG,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3G;;OAEG;IACG,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/G;;OAEG;IACG,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhG;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { connectionSymbol } from '@stratal/framework/database';
|
|
2
2
|
import { DI_TOKENS } from 'stratal/di';
|
|
3
|
-
import { ROUTER_TOKENS } from 'stratal/router';
|
|
4
3
|
import { STORAGE_TOKENS } from 'stratal/storage';
|
|
5
4
|
import { TestHttpClient } from './http/test-http-client';
|
|
6
5
|
/**
|
|
@@ -35,16 +34,21 @@ import { TestHttpClient } from './http/test-http-client';
|
|
|
35
34
|
export class TestingModule {
|
|
36
35
|
app;
|
|
37
36
|
env;
|
|
37
|
+
ctx;
|
|
38
38
|
_http = null;
|
|
39
|
-
|
|
39
|
+
_requestContainer;
|
|
40
|
+
constructor(app, env, ctx) {
|
|
40
41
|
this.app = app;
|
|
41
42
|
this.env = env;
|
|
43
|
+
this.ctx = ctx;
|
|
44
|
+
const mockContext = this.app.createMockRouterContext();
|
|
45
|
+
this._requestContainer = this.app.container.createRequestScope(mockContext);
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* Resolve a service from the container
|
|
45
49
|
*/
|
|
46
50
|
get(token) {
|
|
47
|
-
return this.
|
|
51
|
+
return this._requestContainer.resolve(token);
|
|
48
52
|
}
|
|
49
53
|
/**
|
|
50
54
|
* Get HTTP test client for making requests
|
|
@@ -66,17 +70,16 @@ export class TestingModule {
|
|
|
66
70
|
return this.app;
|
|
67
71
|
}
|
|
68
72
|
/**
|
|
69
|
-
* Get DI Container
|
|
73
|
+
* Get DI Container (request-scoped)
|
|
70
74
|
*/
|
|
71
75
|
get container() {
|
|
72
|
-
return this.
|
|
76
|
+
return this._requestContainer;
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
75
|
-
* Execute an HTTP request through
|
|
79
|
+
* Execute an HTTP request through HonoApp
|
|
76
80
|
*/
|
|
77
81
|
async fetch(request) {
|
|
78
|
-
|
|
79
|
-
return router.fetch(request, this.env, this.app.ctx);
|
|
82
|
+
return this.app.hono.fetch(request, this.env, this.ctx);
|
|
80
83
|
}
|
|
81
84
|
/**
|
|
82
85
|
* Run callback in request scope (for DB operations, service access)
|
|
@@ -85,29 +88,24 @@ export class TestingModule {
|
|
|
85
88
|
const mockContext = this.app.createMockRouterContext();
|
|
86
89
|
return this.app.container.runInRequestScope(mockContext, callback);
|
|
87
90
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return this.get(token);
|
|
92
|
-
});
|
|
91
|
+
getDb(name) {
|
|
92
|
+
const token = name ? connectionSymbol(name) : DI_TOKENS.Database;
|
|
93
|
+
return this._requestContainer.resolve(token);
|
|
93
94
|
}
|
|
94
95
|
/**
|
|
95
96
|
* Truncate all non-prisma tables in the database
|
|
96
97
|
*/
|
|
97
98
|
async truncateDb(name) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const tableList = tables.map((t) => `"${t.tablename}"`).join(', ');
|
|
109
|
-
await db.$executeRawUnsafe(`TRUNCATE ${tableList} RESTART IDENTITY CASCADE`);
|
|
110
|
-
});
|
|
99
|
+
const db = this.getDb(name);
|
|
100
|
+
const tables = await db.$queryRaw `
|
|
101
|
+
SELECT tablename::text as tablename FROM pg_tables
|
|
102
|
+
WHERE schemaname = current_schema()
|
|
103
|
+
AND tablename NOT LIKE '_prisma%'
|
|
104
|
+
`;
|
|
105
|
+
if (tables.length === 0)
|
|
106
|
+
return;
|
|
107
|
+
const tableList = tables.map((t) => `"${t.tablename}"`).join(', ');
|
|
108
|
+
await db.$executeRawUnsafe(`TRUNCATE ${tableList} RESTART IDENTITY CASCADE`);
|
|
111
109
|
}
|
|
112
110
|
async seed(...args) {
|
|
113
111
|
let name;
|
|
@@ -119,14 +117,11 @@ export class TestingModule {
|
|
|
119
117
|
else {
|
|
120
118
|
seeders = args;
|
|
121
119
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
await seeder.run(tx);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
120
|
+
const db = this.getDb(name);
|
|
121
|
+
await db.$transaction(async (tx) => {
|
|
122
|
+
for (const seeder of seeders) {
|
|
123
|
+
await seeder.run(tx);
|
|
124
|
+
}
|
|
130
125
|
});
|
|
131
126
|
}
|
|
132
127
|
/**
|
|
@@ -134,44 +129,36 @@ export class TestingModule {
|
|
|
134
129
|
*/
|
|
135
130
|
async assertDatabaseHas(table, data, name) {
|
|
136
131
|
const { expect } = await import('vitest');
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const result = await model.findFirst({ where: data });
|
|
142
|
-
expect(result, `Expected ${table} with ${JSON.stringify(data)}`).not.toBeNull();
|
|
143
|
-
});
|
|
132
|
+
const db = this.getDb(name);
|
|
133
|
+
const model = db[table];
|
|
134
|
+
const result = await model.findFirst({ where: data });
|
|
135
|
+
expect(result, `Expected ${table} with ${JSON.stringify(data)}`).not.toBeNull();
|
|
144
136
|
}
|
|
145
137
|
/**
|
|
146
138
|
* Assert that a record does not exist in the database
|
|
147
139
|
*/
|
|
148
140
|
async assertDatabaseMissing(table, data, name) {
|
|
149
141
|
const { expect } = await import('vitest');
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const result = await model.findFirst({ where: data });
|
|
155
|
-
expect(result, `Expected ${table} NOT to have ${JSON.stringify(data)}`).toBeNull();
|
|
156
|
-
});
|
|
142
|
+
const db = this.getDb(name);
|
|
143
|
+
const model = db[table];
|
|
144
|
+
const result = await model.findFirst({ where: data });
|
|
145
|
+
expect(result, `Expected ${table} NOT to have ${JSON.stringify(data)}`).toBeNull();
|
|
157
146
|
}
|
|
158
147
|
/**
|
|
159
148
|
* Assert the number of records in a table
|
|
160
149
|
*/
|
|
161
150
|
async assertDatabaseCount(table, expected, name) {
|
|
162
151
|
const { expect } = await import('vitest');
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const actual = await model.count();
|
|
168
|
-
expect(actual, `Expected ${table} count ${expected}, got ${actual}`).toBe(expected);
|
|
169
|
-
});
|
|
152
|
+
const db = this.getDb(name);
|
|
153
|
+
const model = db[table];
|
|
154
|
+
const actual = await model.count();
|
|
155
|
+
expect(actual, `Expected ${table} count ${expected}, got ${actual}`).toBe(expected);
|
|
170
156
|
}
|
|
171
157
|
/**
|
|
172
158
|
* Cleanup - call in afterAll
|
|
173
159
|
*/
|
|
174
160
|
async close() {
|
|
161
|
+
await this._requestContainer.dispose();
|
|
175
162
|
await this.app.shutdown();
|
|
176
163
|
}
|
|
177
164
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module.js","sourceRoot":"","sources":["../../src/core/testing-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAkB,MAAM,YAAY,CAAA;AAEtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"testing-module.js","sourceRoot":"","sources":["../../src/core/testing-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAE9D,OAAO,EAAE,SAAS,EAAkB,MAAM,YAAY,CAAA;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAGhD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,aAAa;IAKL;IACA;IACA;IANX,KAAK,GAA0B,IAAI,CAAA;IAC1B,iBAAiB,CAAW;IAE7C,YACmB,GAAgB,EAChB,GAAe,EACf,GAAqB;QAFrB,QAAG,GAAH,GAAG,CAAa;QAChB,QAAG,GAAH,GAAG,CAAY;QACf,QAAG,GAAH,GAAG,CAAkB;QAEtC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAA;QACtD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;IAC7E,CAAC;IAED;;OAEG;IACH,GAAG,CAAI,KAAwB;QAC7B,OAAO,IAAI,CAAC,iBAA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AAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAA;QACtC,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;IAC3B,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stratal/testing",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Testing utilities and mocks for Stratal framework applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"vitest"
|
|
23
23
|
],
|
|
24
24
|
"engines": {
|
|
25
|
-
"node": ">=
|
|
25
|
+
"node": ">=22.0.0"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"@golevelup/ts-vitest": "^2.2.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@stratal/framework": "^0.0.
|
|
63
|
+
"@stratal/framework": "^0.0.7",
|
|
64
64
|
"better-auth": "^1.4.9",
|
|
65
|
-
"stratal": "^0.0.
|
|
65
|
+
"stratal": "^0.0.7",
|
|
66
66
|
"vitest": "^3.2.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@cloudflare/vitest-pool-workers": "^0.12.
|
|
78
|
-
"@cloudflare/workers-types": "4.
|
|
79
|
-
"@stratal/framework": "
|
|
80
|
-
"@types/node": "^25.3.
|
|
81
|
-
"better-auth": "^1.5.
|
|
82
|
-
"stratal": "
|
|
77
|
+
"@cloudflare/vitest-pool-workers": "^0.12.20",
|
|
78
|
+
"@cloudflare/workers-types": "4.20260307.1",
|
|
79
|
+
"@stratal/framework": "workspace:*",
|
|
80
|
+
"@types/node": "^25.3.5",
|
|
81
|
+
"better-auth": "^1.5.4",
|
|
82
|
+
"stratal": "workspace:*",
|
|
83
83
|
"typescript": "^5.9.3",
|
|
84
84
|
"vitest": "~3.2.0"
|
|
85
85
|
}
|
|
86
|
-
}
|
|
86
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
# @stratal/testing
|
|
2
|
-
|
|
3
|
-
## 0.0.5
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [#66](https://github.com/strataljs/stratal/pull/66) [`c8ea964`](https://github.com/strataljs/stratal/commit/c8ea964e272b09ebc6619843e77d2b51178f9423) Thanks [@adesege](https://github.com/adesege)! - Add `actingAs` auth test helper, `TestHttpRequest` builder, ZenStack language mock, and enhanced `TestingModule` utilities with new exports and types.
|
|
8
|
-
|
|
9
|
-
- Updated dependencies [[`c8ea964`](https://github.com/strataljs/stratal/commit/c8ea964e272b09ebc6619843e77d2b51178f9423), [`c8ea964`](https://github.com/strataljs/stratal/commit/c8ea964e272b09ebc6619843e77d2b51178f9423)]:
|
|
10
|
-
- stratal@0.0.5
|
|
11
|
-
- @stratal/framework@0.0.5
|
|
12
|
-
|
|
13
|
-
## 0.0.4
|
|
14
|
-
|
|
15
|
-
### Patch Changes
|
|
16
|
-
|
|
17
|
-
- **Build cleanup** — Removed redundant polyfills export and cleaned up the build configuration.
|
|
18
|
-
- **Relaxed vitest version** — Loosened the vitest peer dependency version constraint.
|
|
19
|
-
|
|
20
|
-
- Updated dependencies []:
|
|
21
|
-
- stratal@0.0.4
|
|
22
|
-
|
|
23
|
-
## 0.0.3
|
|
24
|
-
|
|
25
|
-
### Patch Changes
|
|
26
|
-
|
|
27
|
-
- - **Build cleanup** — Removed redundant polyfills export and cleaned up the build configuration.
|
|
28
|
-
- **Relaxed vitest version** — Loosened the vitest peer dependency version constraint.
|
|
29
|
-
- Updated dependencies []:
|
|
30
|
-
- stratal@0.0.3
|
|
31
|
-
|
|
32
|
-
## 0.0.2
|
|
33
|
-
|
|
34
|
-
### Patch Changes
|
|
35
|
-
|
|
36
|
-
#### `stratal` (core)
|
|
37
|
-
|
|
38
|
-
##### Breaking Changes
|
|
39
|
-
|
|
40
|
-
- **`withRoot`/`withRootAsync` renamed to `forRoot`/`forRootAsync`** — All dynamic module configuration methods have been renamed for consistency. Update every `SomeModule.withRoot(...)` call to `SomeModule.forRoot(...)` and `SomeModule.withRootAsync(...)` to `SomeModule.forRootAsync(...)`. ([`152913a`](https://github.com/strataljs/stratal/commit/152913a))
|
|
41
|
-
|
|
42
|
-
- **Barrel export removed — use sub-path imports** — The top-level `stratal` barrel export has been removed. Consumers must now import from sub-paths (`stratal/di`, `stratal/router`, `stratal/cache`, `stratal/validation`, etc.). ([`af073d8`](https://github.com/strataljs/stratal/commit/af073d8))
|
|
43
|
-
|
|
44
|
-
##### Features
|
|
45
|
-
|
|
46
|
-
- **DOM polyfill for Cloudflare Workers** — Added a DOM polyfill to support AWS SDK v3 XML parsing in Cloudflare Workers environments. ([`f3b2cb9`](https://github.com/strataljs/stratal/commit/f3b2cb9))
|
|
47
|
-
|
|
48
|
-
- **Benchmark suite** — Added benchmark functionality for measuring framework performa30438`](https://github.com/strataljs/stratal/commit/7230438))
|
|
49
|
-
|
|
50
|
-
##### Security
|
|
51
|
-
|
|
52
|
-
- **ConfigService blocks prototype pollution** — `ConfigService` now rejects dangerous keys (`__proto__`, `constructor`, `prototype`) to prevent prototype pollution attacks. ([`567139c`](https://github.com/strataljs/stratal/commit/567139c), [`e64b4e7`](https://github.com/strataljs/stratal/commit/e64b4e7))
|
|
53
|
-
|
|
54
|
-
##### Bug Fixes
|
|
55
|
-
|
|
56
|
-
- **`reflect-metadata` import moved to vitest setup** — Removed unused `reflect-metadata` imports from example files and centralized the import in `vitest.setup.ts`. ([`f3b2cb9`](https://github.com/strataljs/stratal/commit/f3b2cb9))
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
#### `@stratal/testing`
|
|
61
|
-
|
|
62
|
-
##### Breaking Changes
|
|
63
|
-
|
|
64
|
-
- **Import paths updated** — Import paths updated to match the new core sub-path exports (e.g. `stratal/di` instead of the barrel `stratal`). ([`af073d8`](https://github.com/strataljs/stratal/commit/af073d8))
|
|
65
|
-
|
|
66
|
-
- Updated dependencies []:
|
|
67
|
-
- @stratal/testing@0.0.2
|
|
68
|
-
|
|
69
|
-
## 0.0.1
|
|
70
|
-
|
|
71
|
-
### Patch Changes
|
|
72
|
-
|
|
73
|
-
- Initial release of the Stratal framework — a modular Cloudflare Workers framework built on Hono and tsyringe.
|
|
74
|
-
|
|
75
|
-
**Core Infrastructure**
|
|
76
|
-
|
|
77
|
-
- NestJS-style module system with `@Module()` decorator, dynamic modules (`forRoot`, `forRootAsync`), and lifecycle hooks (`OnInitialize`, `OnShutdown`)
|
|
78
|
-
- Two-tier dependency injection container (global singletons + request-scoped) powered by tsyringe with conditional registration and service decoration
|
|
79
|
-
- `StratalWorker` entry point extending Cloudflare's `WorkerEntrypoint` for HTTP fetch, queue batches, and scheduled cron triggers
|
|
80
|
-
|
|
81
|
-
**Routing & API**
|
|
82
|
-
|
|
83
|
-
- Hono-based routing with `@Controller()` and `@Route()` decorators, automatic controller discovery, and route guards via `@UseGuards()`
|
|
84
|
-
- OpenAPI schema generation with `@hono/zod-openapi` and Scalar API reference integration
|
|
85
|
-
- NestJS-like middleware configuration with route-specific application and exclusion
|
|
86
|
-
|
|
87
|
-
**Background Processing**
|
|
88
|
-
|
|
89
|
-
- Queue consumerfor Cloudflare Queues with `@Consumer()` and `@QueueJob()` decorators and batch processing
|
|
90
|
-
- Cron job scheduling via `CronManager` integrated with Cloudflare's scheduled events
|
|
91
|
-
|
|
92
|
-
**Services & Integrations**
|
|
93
|
-
|
|
94
|
-
- Email module with pluggable providers (Nodemailer, Resend) and queue-based sending
|
|
95
|
-
- Storage module with AWS S3 / Cloudflare R2 support, multipart uploads, presigned URLs, and TUS resumable uploads
|
|
96
|
-
- Internationalization (i18n) module with locale detection, message compilation, and request-scoped translations
|
|
97
|
-
- Cache module with pluggable providers and Cloudflare KV integration
|
|
98
|
-
- Configuration module with `registerAs()` namespaces and Zod-based validation
|
|
99
|
-
- Structured logging with JSON and pretty formatters
|
|
100
|
-
|
|
101
|
-
**Developer Experience**
|
|
102
|
-
|
|
103
|
-
- Zod-powered request/response validation with type inference
|
|
104
|
-
- Custom `ApplicationError` class with HTTP status mapping
|
|
105
|
-
- ESM-only with full TypeScript decorator support (`emitDecoratorMetadata`)
|
|
106
|
-
- Sub-path exports for tree-shakeable imports (`stratal/di`, `stratal/router`, `stratal/cache`, etc.)
|
|
107
|
-
|
|
108
|
-
- `TestingModule` and `TestingModuleBuilder` for bootstrapping isolated module environments in tests
|
|
109
|
-
- `TestHttpClient` with request builder and response wrapper for integration testing
|
|
110
|
-
- `FetchMock` for mocking HTTP fetch calls
|
|
111
|
-
- `FakeStorageService` for in-memory storage testing without S3/R2
|
|
112
|
-
- `ProviderOverrideBuilder` for replacing providers with test doubles
|
|
113
|
-
- Nodemailer mock for email testing
|
|
114
|
-
- Test environment utilities via `getTestEnv()`
|
|
115
|
-
|
|
116
|
-
- Updated dependencies []:
|
|
117
|
-
- stratal@0.0.1
|