@stratal/testing 0.0.1 → 0.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/CHANGELOG.md +107 -0
- package/README.md +332 -0
- package/dist/core/http/test-http-client.d.ts +4 -4
- package/dist/core/http/test-http-client.js +4 -4
- package/dist/core/override/provider-override-builder.d.ts +1 -1
- package/dist/core/override/provider-override-builder.d.ts.map +1 -1
- package/dist/core/test.d.ts +1 -1
- package/dist/core/test.d.ts.map +1 -1
- package/dist/core/testing-module-builder.d.ts +2 -1
- package/dist/core/testing-module-builder.d.ts.map +1 -1
- package/dist/core/testing-module-builder.js +4 -2
- package/dist/core/testing-module-builder.js.map +1 -1
- package/dist/core/testing-module.d.ts +3 -1
- package/dist/core/testing-module.d.ts.map +1 -1
- package/dist/core/testing-module.js +1 -1
- package/dist/core/testing-module.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/fake-storage.service.js +1 -1
- package/dist/storage/fake-storage.service.js.map +1 -1
- package/package.json +15 -13
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# @stratal/testing
|
|
2
|
+
|
|
3
|
+
## 0.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Build cleanup** — Removed redundant polyfills export and cleaned up the build configuration.
|
|
8
|
+
- **Relaxed vitest version** — Loosened the vitest peer dependency version constraint.
|
|
9
|
+
|
|
10
|
+
- Updated dependencies []:
|
|
11
|
+
- stratal@0.0.4
|
|
12
|
+
|
|
13
|
+
## 0.0.3
|
|
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
|
+
- Updated dependencies []:
|
|
20
|
+
- stratal@0.0.3
|
|
21
|
+
|
|
22
|
+
## 0.0.2
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
#### `stratal` (core)
|
|
27
|
+
|
|
28
|
+
##### Breaking Changes
|
|
29
|
+
|
|
30
|
+
- **`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))
|
|
31
|
+
|
|
32
|
+
- **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))
|
|
33
|
+
|
|
34
|
+
##### Features
|
|
35
|
+
|
|
36
|
+
- **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))
|
|
37
|
+
|
|
38
|
+
- **Benchmark suite** — Added benchmark functionality for measuring framework performa30438`](https://github.com/strataljs/stratal/commit/7230438))
|
|
39
|
+
|
|
40
|
+
##### Security
|
|
41
|
+
|
|
42
|
+
- **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))
|
|
43
|
+
|
|
44
|
+
##### Bug Fixes
|
|
45
|
+
|
|
46
|
+
- **`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))
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
#### `@stratal/testing`
|
|
51
|
+
|
|
52
|
+
##### Breaking Changes
|
|
53
|
+
|
|
54
|
+
- **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))
|
|
55
|
+
|
|
56
|
+
- Updated dependencies []:
|
|
57
|
+
- @stratal/testing@0.0.2
|
|
58
|
+
|
|
59
|
+
## 0.0.1
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Initial release of the Stratal framework — a modular Cloudflare Workers framework built on Hono and tsyringe.
|
|
64
|
+
|
|
65
|
+
**Core Infrastructure**
|
|
66
|
+
|
|
67
|
+
- NestJS-style module system with `@Module()` decorator, dynamic modules (`forRoot`, `forRootAsync`), and lifecycle hooks (`OnInitialize`, `OnShutdown`)
|
|
68
|
+
- Two-tier dependency injection container (global singletons + request-scoped) powered by tsyringe with conditional registration and service decoration
|
|
69
|
+
- `StratalWorker` entry point extending Cloudflare's `WorkerEntrypoint` for HTTP fetch, queue batches, and scheduled cron triggers
|
|
70
|
+
|
|
71
|
+
**Routing & API**
|
|
72
|
+
|
|
73
|
+
- Hono-based routing with `@Controller()` and `@Route()` decorators, automatic controller discovery, and route guards via `@UseGuards()`
|
|
74
|
+
- OpenAPI schema generation with `@hono/zod-openapi` and Scalar API reference integration
|
|
75
|
+
- NestJS-like middleware configuration with route-specific application and exclusion
|
|
76
|
+
|
|
77
|
+
**Background Processing**
|
|
78
|
+
|
|
79
|
+
- Queue consumerfor Cloudflare Queues with `@Consumer()` and `@QueueJob()` decorators and batch processing
|
|
80
|
+
- Cron job scheduling via `CronManager` integrated with Cloudflare's scheduled events
|
|
81
|
+
|
|
82
|
+
**Services & Integrations**
|
|
83
|
+
|
|
84
|
+
- Email module with pluggable providers (Nodemailer, Resend) and queue-based sending
|
|
85
|
+
- Storage module with AWS S3 / Cloudflare R2 support, multipart uploads, presigned URLs, and TUS resumable uploads
|
|
86
|
+
- Internationalization (i18n) module with locale detection, message compilation, and request-scoped translations
|
|
87
|
+
- Cache module with pluggable providers and Cloudflare KV integration
|
|
88
|
+
- Configuration module with `registerAs()` namespaces and Zod-based validation
|
|
89
|
+
- Structured logging with JSON and pretty formatters
|
|
90
|
+
|
|
91
|
+
**Developer Experience**
|
|
92
|
+
|
|
93
|
+
- Zod-powered request/response validation with type inference
|
|
94
|
+
- Custom `ApplicationError` class with HTTP status mapping
|
|
95
|
+
- ESM-only with full TypeScript decorator support (`emitDecoratorMetadata`)
|
|
96
|
+
- Sub-path exports for tree-shakeable imports (`stratal/di`, `stratal/router`, `stratal/cache`, etc.)
|
|
97
|
+
|
|
98
|
+
- `TestingModule` and `TestingModuleBuilder` for bootstrapping isolated module environments in tests
|
|
99
|
+
- `TestHttpClient` with request builder and response wrapper for integration testing
|
|
100
|
+
- `FetchMock` for mocking HTTP fetch calls
|
|
101
|
+
- `FakeStorageService` for in-memory storage testing without S3/R2
|
|
102
|
+
- `ProviderOverrideBuilder` for replacing providers with test doubles
|
|
103
|
+
- Nodemailer mock for email testing
|
|
104
|
+
- Test environment utilities via `getTestEnv()`
|
|
105
|
+
|
|
106
|
+
- Updated dependencies []:
|
|
107
|
+
- stratal@0.0.1
|
package/README.md
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
# @stratal/testing
|
|
2
|
+
|
|
3
|
+
Testing utilities and mocks for [Stratal](https://github.com/strataljs/stratal) framework applications.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@stratal/testing)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -D @stratal/testing
|
|
12
|
+
# or
|
|
13
|
+
yarn add -D @stratal/testing
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Peer dependencies
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -D stratal vitest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
Set up base modules once in your Vitest setup file, then create test modules in each test:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// vitest.setup.ts
|
|
28
|
+
import 'reflect-metadata'
|
|
29
|
+
import { Test } from '@stratal/testing'
|
|
30
|
+
import { CoreModule } from './src/core.module'
|
|
31
|
+
|
|
32
|
+
Test.setBaseModules([CoreModule])
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// users/__tests__/users.spec.ts
|
|
37
|
+
import { Test, type TestingModule } from '@stratal/testing'
|
|
38
|
+
import { UsersModule } from '../users.module'
|
|
39
|
+
|
|
40
|
+
describe('UsersController', () => {
|
|
41
|
+
let module: TestingModule
|
|
42
|
+
|
|
43
|
+
beforeAll(async () => {
|
|
44
|
+
module = await Test.createTestingModule({
|
|
45
|
+
imports: [UsersModule],
|
|
46
|
+
}).compile()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
afterAll(async () => {
|
|
50
|
+
await module.close()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('lists users', async () => {
|
|
54
|
+
const response = await module.http
|
|
55
|
+
.get('/api/users')
|
|
56
|
+
.send()
|
|
57
|
+
|
|
58
|
+
response.assertOk()
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Core API
|
|
64
|
+
|
|
65
|
+
### `Test`
|
|
66
|
+
|
|
67
|
+
Static entry point for creating testing modules.
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { Test } from '@stratal/testing'
|
|
71
|
+
|
|
72
|
+
// Set once in vitest.setup.ts — included in every test module
|
|
73
|
+
Test.setBaseModules([CoreModule])
|
|
74
|
+
|
|
75
|
+
// Create a test module in each test file
|
|
76
|
+
const builder = Test.createTestingModule({
|
|
77
|
+
imports: [UsersModule, AuthModule],
|
|
78
|
+
providers: [{ provide: MOCK_TOKEN, useValue: mockValue }],
|
|
79
|
+
controllers: [TestController],
|
|
80
|
+
env: { DATABASE_URL: 'test://db' },
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### `TestingModuleBuilder`
|
|
85
|
+
|
|
86
|
+
Fluent builder returned by `Test.createTestingModule()`. Chain provider overrides, then call `.compile()`.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
const module = await Test.createTestingModule({
|
|
90
|
+
imports: [OrdersModule],
|
|
91
|
+
})
|
|
92
|
+
.overrideProvider(PAYMENT_TOKEN)
|
|
93
|
+
.useValue(mockPaymentService)
|
|
94
|
+
.withEnv({ STRIPE_KEY: 'sk_test_xxx' })
|
|
95
|
+
.compile()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### `TestingModule`
|
|
99
|
+
|
|
100
|
+
The compiled test context. Provides access to services, HTTP client, storage, and lifecycle management.
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
// Resolve services from the DI container
|
|
104
|
+
const service = module.get(ORDER_TOKENS.OrderService)
|
|
105
|
+
|
|
106
|
+
// Access the HTTP test client
|
|
107
|
+
module.http
|
|
108
|
+
|
|
109
|
+
// Access fake storage for assertions
|
|
110
|
+
module.storage
|
|
111
|
+
|
|
112
|
+
// Execute code in a request-scoped container
|
|
113
|
+
await module.runInRequestScope(async () => {
|
|
114
|
+
const scoped = module.get(REQUEST_SCOPED_TOKEN)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
// Cleanup in afterAll
|
|
118
|
+
await module.close()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## HTTP Testing
|
|
122
|
+
|
|
123
|
+
The built-in HTTP client provides a fluent API for making requests and asserting responses.
|
|
124
|
+
|
|
125
|
+
### Making requests
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const response = await module.http
|
|
129
|
+
.forHost('api.example.com') // optional — defaults to localhost
|
|
130
|
+
.post('/api/v1/orders')
|
|
131
|
+
.withHeaders({ Authorization: 'Bearer token' })
|
|
132
|
+
.withBody({ item: 'Widget', qty: 3 })
|
|
133
|
+
.send()
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
All HTTP methods are supported: `.get()`, `.post()`, `.put()`, `.patch()`, `.delete()`.
|
|
137
|
+
|
|
138
|
+
### Response assertions
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
response
|
|
142
|
+
.assertCreated() // 201
|
|
143
|
+
.assertHeader('Content-Type', 'application/json')
|
|
144
|
+
|
|
145
|
+
// Status helpers
|
|
146
|
+
response.assertOk() // 200
|
|
147
|
+
response.assertNoContent() // 204
|
|
148
|
+
response.assertBadRequest() // 400
|
|
149
|
+
response.assertUnauthorized() // 401
|
|
150
|
+
response.assertForbidden() // 403
|
|
151
|
+
response.assertNotFound() // 404
|
|
152
|
+
response.assertUnprocessable() // 422
|
|
153
|
+
response.assertServerError() // 500
|
|
154
|
+
response.assertStatus(418) // any status
|
|
155
|
+
response.assertSuccessful() // 2xx range
|
|
156
|
+
|
|
157
|
+
// JSON assertions (async — chainable with await)
|
|
158
|
+
await response.assertJson({ success: true })
|
|
159
|
+
await response.assertJsonPath('data.user.id', expect.any(String))
|
|
160
|
+
await response.assertJsonPaths({ 'data.name': 'Alice', 'data.role': 'admin' })
|
|
161
|
+
await response.assertJsonStructure(['id', 'name', 'email'])
|
|
162
|
+
await response.assertJsonPathExists('data.createdAt')
|
|
163
|
+
await response.assertJsonPathMissing('data.password')
|
|
164
|
+
await response.assertJsonPathCount('data.items', 3)
|
|
165
|
+
await response.assertJsonPathContains('data.bio', 'engineer')
|
|
166
|
+
await response.assertJsonPathIncludes('data.tags', 'featured')
|
|
167
|
+
|
|
168
|
+
// Header assertions
|
|
169
|
+
response.assertHeader('X-Request-Id') // exists
|
|
170
|
+
response.assertHeader('X-Request-Id', '123') // exact value
|
|
171
|
+
response.assertHeaderMissing('X-Debug')
|
|
172
|
+
|
|
173
|
+
// Raw access
|
|
174
|
+
const json = await response.json<OrderResponse>()
|
|
175
|
+
const text = await response.text()
|
|
176
|
+
response.status // number
|
|
177
|
+
response.headers // Headers
|
|
178
|
+
response.raw // underlying Response
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Provider Overrides
|
|
182
|
+
|
|
183
|
+
Replace any provider in the DI container for testing:
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
const module = await Test.createTestingModule({
|
|
187
|
+
imports: [NotificationModule],
|
|
188
|
+
})
|
|
189
|
+
// Static value
|
|
190
|
+
.overrideProvider(EMAIL_TOKEN)
|
|
191
|
+
.useValue(mockEmailService)
|
|
192
|
+
|
|
193
|
+
// Class replacement
|
|
194
|
+
.overrideProvider(LOGGER_TOKEN)
|
|
195
|
+
.useClass(SilentLogger)
|
|
196
|
+
|
|
197
|
+
// Factory with container access
|
|
198
|
+
.overrideProvider(CACHE_TOKEN)
|
|
199
|
+
.useFactory((container) => new InMemoryCache(container.resolve(CONFIG_TOKEN)))
|
|
200
|
+
|
|
201
|
+
// Alias to existing token
|
|
202
|
+
.overrideProvider(PAYMENT_TOKEN)
|
|
203
|
+
.useExisting(MOCK_PAYMENT_TOKEN)
|
|
204
|
+
|
|
205
|
+
.compile()
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Fetch Mocking
|
|
209
|
+
|
|
210
|
+
Mock external HTTP calls with `createFetchMock()`, backed by [undici MockAgent](https://undici.nodejs.org/#/docs/api/MockAgent):
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
import { createFetchMock, type FetchMock } from '@stratal/testing'
|
|
214
|
+
|
|
215
|
+
describe('GeoService', () => {
|
|
216
|
+
let module: TestingModule
|
|
217
|
+
let fetchMock: FetchMock
|
|
218
|
+
|
|
219
|
+
beforeEach(() => {
|
|
220
|
+
fetchMock = createFetchMock()
|
|
221
|
+
fetchMock.activate()
|
|
222
|
+
fetchMock.disableNetConnect()
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
afterEach(() => {
|
|
226
|
+
fetchMock.reset()
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
it('looks up coordinates', async () => {
|
|
230
|
+
fetchMock.mockJsonResponse('https://geo.api.com/lookup', {
|
|
231
|
+
lat: 40.7128,
|
|
232
|
+
lng: -74.006,
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
const response = await module.http
|
|
236
|
+
.get('/api/geo/lookup?address=NYC')
|
|
237
|
+
.send()
|
|
238
|
+
|
|
239
|
+
response.assertOk()
|
|
240
|
+
await response.assertJsonPath('data.lat', 40.7128)
|
|
241
|
+
fetchMock.assertNoPendingInterceptors()
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
it('handles API errors', async () => {
|
|
245
|
+
fetchMock.mockError('https://geo.api.com/lookup', 503, 'Service Unavailable')
|
|
246
|
+
|
|
247
|
+
const response = await module.http
|
|
248
|
+
.get('/api/geo/lookup?address=NYC')
|
|
249
|
+
.send()
|
|
250
|
+
|
|
251
|
+
response.assertServerError()
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
For advanced scenarios, access the undici `MockPool` directly:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
fetchMock
|
|
260
|
+
.get('https://api.example.com')
|
|
261
|
+
.intercept({ path: '/users', method: 'POST' })
|
|
262
|
+
.reply(201, { id: '1' })
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Storage Testing
|
|
266
|
+
|
|
267
|
+
`FakeStorageService` is an in-memory storage implementation auto-registered in every test module. It replaces the real storage service and provides assertion helpers.
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
it('uploads a document', async () => {
|
|
271
|
+
await module.http
|
|
272
|
+
.post('/api/documents')
|
|
273
|
+
.withBody({ name: 'report.pdf' })
|
|
274
|
+
.send()
|
|
275
|
+
|
|
276
|
+
// Assert files were stored
|
|
277
|
+
module.storage.assertExists('documents/report.pdf')
|
|
278
|
+
module.storage.assertMissing('documents/old.pdf')
|
|
279
|
+
module.storage.assertCount(1)
|
|
280
|
+
|
|
281
|
+
// Inspect stored files
|
|
282
|
+
const file = module.storage.getFile('documents/report.pdf')
|
|
283
|
+
expect(file?.mimeType).toBe('application/pdf')
|
|
284
|
+
expect(file?.size).toBeGreaterThan(0)
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
afterEach(() => {
|
|
288
|
+
module.storage.clear() // reset between tests
|
|
289
|
+
})
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Deep Mocking
|
|
293
|
+
|
|
294
|
+
Create deeply-mocked instances of any interface or class with `createMock()` from [`@golevelup/ts-vitest`](https://github.com/golevelup/nestjs/tree/master/packages/ts-vitest):
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
import { createMock, type DeepMocked } from '@stratal/testing/mocks'
|
|
298
|
+
|
|
299
|
+
let mockService: DeepMocked<PaymentService>
|
|
300
|
+
|
|
301
|
+
beforeEach(() => {
|
|
302
|
+
mockService = createMock<PaymentService>()
|
|
303
|
+
mockService.charge.mockResolvedValue({ id: 'ch_123', status: 'paid' })
|
|
304
|
+
})
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Nodemailer mock
|
|
308
|
+
|
|
309
|
+
A drop-in mock for nodemailer, useful in Vitest's module mocking:
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
// vitest.config.ts (or inline vi.mock)
|
|
313
|
+
export default defineConfig({
|
|
314
|
+
test: {
|
|
315
|
+
alias: {
|
|
316
|
+
nodemailer: '@stratal/testing/mocks/nodemailer',
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
})
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Sub-path Exports
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
import { Test, TestingModule, createFetchMock } from '@stratal/testing'
|
|
326
|
+
import { createMock, type DeepMocked } from '@stratal/testing/mocks'
|
|
327
|
+
import nodemailer from '@stratal/testing/mocks/nodemailer'
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## License
|
|
331
|
+
|
|
332
|
+
MIT
|
|
@@ -8,9 +8,9 @@ import { TestHttpRequest } from './test-http-request';
|
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
10
|
* const response = await module.http
|
|
11
|
-
* .forHost('
|
|
12
|
-
* .post('/api/v1/
|
|
13
|
-
* .withBody({
|
|
11
|
+
* .forHost('example.com')
|
|
12
|
+
* .post('/api/v1/users')
|
|
13
|
+
* .withBody({ name: 'Test' })
|
|
14
14
|
* .send()
|
|
15
15
|
*
|
|
16
16
|
* response.assertCreated()
|
|
@@ -22,7 +22,7 @@ export declare class TestHttpClient {
|
|
|
22
22
|
private host;
|
|
23
23
|
constructor(module: TestingModule);
|
|
24
24
|
/**
|
|
25
|
-
* Set the host for the request
|
|
25
|
+
* Set the host for the request
|
|
26
26
|
*/
|
|
27
27
|
forHost(host: string): this;
|
|
28
28
|
/**
|
|
@@ -7,9 +7,9 @@ import { TestHttpRequest } from './test-http-request';
|
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
9
|
* const response = await module.http
|
|
10
|
-
* .forHost('
|
|
11
|
-
* .post('/api/v1/
|
|
12
|
-
* .withBody({
|
|
10
|
+
* .forHost('example.com')
|
|
11
|
+
* .post('/api/v1/users')
|
|
12
|
+
* .withBody({ name: 'Test' })
|
|
13
13
|
* .send()
|
|
14
14
|
*
|
|
15
15
|
* response.assertCreated()
|
|
@@ -23,7 +23,7 @@ export class TestHttpClient {
|
|
|
23
23
|
this.module = module;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Set the host for the request
|
|
26
|
+
* Set the host for the request
|
|
27
27
|
*/
|
|
28
28
|
forHost(host) {
|
|
29
29
|
this.host = host;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-override-builder.d.ts","sourceRoot":"","sources":["../../../src/core/override/provider-override-builder.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider-override-builder.d.ts","sourceRoot":"","sources":["../../../src/core/override/provider-override-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAErE;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,OAAO;IACjD,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;IACxB,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAA;IAChD,cAAc,EAAE,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;CACxG;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,uBAAuB,CAAC,CAAC;IAElC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC;IAG3C;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,oBAAoB;IAQxC;;;;;;;OAOG;IACH,QAAQ,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,oBAAoB;IAQlE;;;;;;;OAOG;IACH,UAAU,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,GAAG,oBAAoB;IAQtE;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,oBAAoB;CAOpE"}
|
package/dist/core/test.d.ts
CHANGED
package/dist/core/test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/core/test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/core/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAAE,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEzF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,IAAI;IACf;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW,CAAsC;IAEhE;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,WAAW,GAAG,aAAa,CAAC,EAAE,GAAG,IAAI;IAIrE;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC,EAAE;IAIxD;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,oBAAoB;CAG9E"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ApplicationConfig,
|
|
1
|
+
import { ApplicationConfig, type StratalEnv } from 'stratal';
|
|
2
|
+
import { InjectionToken, ModuleOptions } from 'stratal/module';
|
|
2
3
|
import { ProviderOverrideBuilder, type ProviderOverrideConfig } from './override';
|
|
3
4
|
import { TestingModule } from './testing-module';
|
|
4
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module-builder.d.ts","sourceRoot":"","sources":["../../src/core/testing-module-builder.ts"],"names":[],"mappings":"
|
|
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,MAAM,gBAAgB,CAAA;AAInF,OAAO,EAAE,uBAAuB,EAAE,KAAK,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,qCAAqC;IACrC,GAAG,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;IACzB,qEAAqE;IACrE,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,oBAAoB;IAGnB,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,SAAS,CAAuC;gBAEpC,MAAM,EAAE,mBAAmB;IAE/C;;;;;;;OAOG;IACH,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAC,CAAC;IAIzE;;;;OAIG;IACH,mBAAmB,CAAC,CAAC,EAAE,QAAQ,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,IAAI;IAKjE;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI;IAKvC;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAmEvC;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAK7B"}
|
|
@@ -4,9 +4,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Application, LogLevel, Module, } from 'stratal';
|
|
8
|
-
import { STORAGE_TOKENS } from 'stratal/storage';
|
|
9
7
|
import { createExecutionContext } from 'cloudflare:test';
|
|
8
|
+
import { Application, } from 'stratal';
|
|
9
|
+
import { LogLevel } from 'stratal/logger';
|
|
10
|
+
import { Module } from 'stratal/module';
|
|
11
|
+
import { STORAGE_TOKENS } from 'stratal/storage';
|
|
10
12
|
import { FakeStorageService } from '../storage';
|
|
11
13
|
import { getTestEnv } from './env';
|
|
12
14
|
import { ProviderOverrideBuilder } from './override';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module-builder.js","sourceRoot":"","sources":["../../src/core/testing-module-builder.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,
|
|
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;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,uBAAuB,EAA+B,MAAM,YAAY,CAAA;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAuBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAO,oBAAoB;IAGX;IAFZ,SAAS,GAAqC,EAAE,CA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EG;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"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { Application,
|
|
1
|
+
import type { Application, StratalEnv } from 'stratal';
|
|
2
|
+
import { type Container } from 'stratal/di';
|
|
3
|
+
import { type InjectionToken } from 'stratal/module';
|
|
2
4
|
import type { FakeStorageService } from '../storage';
|
|
3
5
|
import { TestHttpClient } from './http/test-http-client';
|
|
4
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module.d.ts","sourceRoot":"","sources":["../../src/core/testing-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"testing-module.d.ts","sourceRoot":"","sources":["../../src/core/testing-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,aAAa;IAItB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAJtB,OAAO,CAAC,KAAK,CAA8B;gBAGxB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,UAAU;IAGlC;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC;IAInC;;OAEG;IACH,IAAI,IAAI,IAAI,cAAc,CAGzB;IAED;;;;;;;;;;;OAWG;IACH,IAAI,OAAO,IAAI,kBAAkB,CAEhC;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,WAAW,CAE7B;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED;;;;OAIG;IACG,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKhD;;OAEG;IACG,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtE;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module.js","sourceRoot":"","sources":["../../src/core/testing-module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing-module.js","sourceRoot":"","sources":["../../src/core/testing-module.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAsB,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,aAAa;IAIL;IACA;IAJX,KAAK,GAA0B,IAAI,CAAA;IAE3C,YACmB,GAAgB,EAChB,GAAe;QADf,QAAG,GAAH,GAAG,CAAa;QAChB,QAAG,GAAH,GAAG,CAAY;IAC9B,CAAC;IAEL;;OAEG;IACH,GAAG,CAAI,KAAwB;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,IAAI,CAAC,KAAK,KAAK,IAAI,cAAc,CAAC,IAAI,CAAC,CAAA;QACvC,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,GAAG,CAAqB,cAAc,CAAC,cAAc,CAAC,CAAA;IACpE,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAA;IAC3B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CAAC,OAAgB;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAgB,aAAa,CAAC,aAAa,CAAC,CAAA;QACnE,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACtD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CAAI,QAA8B;QACvD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAA;QACtD,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;IACpE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;IAC3B,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
export { ProviderOverrideBuilder, type ProviderOverrideConfig } from './core/override';
|
|
2
2
|
export { Test } from './core/test';
|
|
3
3
|
export { TestingModule } from './core/testing-module';
|
|
4
4
|
export { TestingModuleBuilder, type TestingModuleConfig } from './core/testing-module-builder';
|
|
5
|
-
export {
|
|
5
|
+
export { createFetchMock, FetchMock } from './core/http/fetch-mock';
|
|
6
|
+
export type { MockErrorOptions, MockJsonOptions } from './core/http/fetch-mock.types';
|
|
6
7
|
export { TestHttpClient } from './core/http/test-http-client';
|
|
7
8
|
export { TestHttpRequest } from './core/http/test-http-request';
|
|
8
9
|
export { TestResponse } from './core/http/test-response';
|
|
9
|
-
export { FetchMock, createFetchMock } from './core/http/fetch-mock';
|
|
10
|
-
export type { MockJsonOptions, MockErrorOptions } from './core/http/fetch-mock.types';
|
|
11
10
|
export { FakeStorageService, type StoredFile } from './storage';
|
|
12
11
|
export { getTestEnv } from './core/env';
|
|
13
12
|
export { TestError, TestSetupError } from './errors';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAG9F,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACnE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAGxD,OAAO,EAAE,kBAAkB,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import 'stratal/polyfills';
|
|
2
1
|
// Core Testing
|
|
2
|
+
export { ProviderOverrideBuilder } from './core/override';
|
|
3
3
|
export { Test } from './core/test';
|
|
4
4
|
export { TestingModule } from './core/testing-module';
|
|
5
5
|
export { TestingModuleBuilder } from './core/testing-module-builder';
|
|
6
|
-
export { ProviderOverrideBuilder } from './core/override';
|
|
7
6
|
// HTTP Testing
|
|
7
|
+
export { createFetchMock, FetchMock } from './core/http/fetch-mock';
|
|
8
8
|
export { TestHttpClient } from './core/http/test-http-client';
|
|
9
9
|
export { TestHttpRequest } from './core/http/test-http-request';
|
|
10
10
|
export { TestResponse } from './core/http/test-response';
|
|
11
|
-
export { FetchMock, createFetchMock } from './core/http/fetch-mock';
|
|
12
11
|
// Storage
|
|
13
12
|
export { FakeStorageService } from './storage';
|
|
14
13
|
// Environment utilities
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,uBAAuB,EAA+B,MAAM,iBAAiB,CAAA;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAA4B,MAAM,+BAA+B,CAAA;AAE9F,eAAe;AACf,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,UAAU;AACV,OAAO,EAAE,kBAAkB,EAAmB,MAAM,WAAW,CAAA;AAE/D,wBAAwB;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,SAAS;AACT,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
|
-
import {
|
|
13
|
+
import { Transient, inject } from 'stratal/di';
|
|
14
14
|
import { FileNotFoundError, STORAGE_TOKENS, StorageManagerService, StorageService, } from 'stratal/storage';
|
|
15
15
|
import { expect } from 'vitest';
|
|
16
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-storage.service.js","sourceRoot":"","sources":["../../src/storage/fake-storage.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fake-storage.service.js","sourceRoot":"","sources":["../../src/storage/fake-storage.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,cAAc,GAOf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAa/B;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,cAAc;IAK/B;IAEA;IANb,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAA;IAE7C,YAEqB,cAAqC,EAErC,OAAsB;QAEzC,KAAK,CAAC,cAAc,EAAE,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,IAAI,CAAC,CAAA;QACvC,CAAC;QAED,IAAI,IAAI,YAAY,IAAI,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;YACvC,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;QAC/B,CAAC;QAED,IAAI,IAAI,YAAY,cAAc,EAAE,CAAC;YACnC,OAAO,IAAI,UAAU,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;QAC/D,CAAC;QAED,qDAAqD;QACrD,IAAI,IAAI,YAAY,QAAQ,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;YAChE,OAAO,IAAI,UAAU,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;QAC/D,CAAC;QAED,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF,CAAA;AAtQY,kBAAkB;IAD9B,SAAS,CAAC,cAAc,CAAC,cAAc,CAAC;IAKpC,WAAA,MAAM,CAAC,cAAc,CAAC,cAAc,CAAC,CAAA;IAErC,WAAA,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;qCADI,qBAAqB;GAL/C,kBAAkB,CAsQ9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stratal/testing",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Testing utilities and mocks for Stratal framework applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=18.0.0"
|
|
26
26
|
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public",
|
|
29
|
+
"provenance": true
|
|
30
|
+
},
|
|
27
31
|
"files": [
|
|
28
32
|
"dist",
|
|
29
33
|
"README.md"
|
|
@@ -44,26 +48,24 @@
|
|
|
44
48
|
},
|
|
45
49
|
"scripts": {
|
|
46
50
|
"build": "tsc -p tsconfig.build.json",
|
|
47
|
-
"clean": "rm -rf dist",
|
|
48
|
-
"prebuild": "yarn clean",
|
|
49
51
|
"typecheck": "tsc --noEmit",
|
|
50
52
|
"lint": "npx eslint .",
|
|
51
53
|
"lint:fix": "npx eslint --fix ."
|
|
52
54
|
},
|
|
53
55
|
"dependencies": {
|
|
54
|
-
"@faker-js/faker": "^
|
|
55
|
-
"@golevelup/ts-vitest": "^2.
|
|
56
|
+
"@faker-js/faker": "^10.3.0",
|
|
57
|
+
"@golevelup/ts-vitest": "^2.2.0"
|
|
56
58
|
},
|
|
57
59
|
"peerDependencies": {
|
|
58
|
-
"stratal": "^0.0.
|
|
60
|
+
"stratal": "^0.0.4",
|
|
59
61
|
"vitest": "^3.2.0"
|
|
60
62
|
},
|
|
61
63
|
"devDependencies": {
|
|
62
|
-
"@cloudflare/vitest-pool-workers": "^0.
|
|
63
|
-
"@cloudflare/workers-types": "
|
|
64
|
-
"@types/node": "^
|
|
65
|
-
"stratal": "
|
|
66
|
-
"typescript": "^5.
|
|
67
|
-
"vitest": "
|
|
64
|
+
"@cloudflare/vitest-pool-workers": "^0.12.18",
|
|
65
|
+
"@cloudflare/workers-types": "4.20260228.1",
|
|
66
|
+
"@types/node": "^25.3.2",
|
|
67
|
+
"stratal": "0.0.4",
|
|
68
|
+
"typescript": "^5.9.3",
|
|
69
|
+
"vitest": "~3.2.0"
|
|
68
70
|
}
|
|
69
|
-
}
|
|
71
|
+
}
|