@geekmidas/envkit 9.0.2 → 10.0.0-alpha.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 (50) hide show
  1. package/README.md +2 -2
  2. package/dist/{EnvironmentBuilder-DDgLJAAo.cjs → EnvironmentBuilder-15SdFJdK.cjs} +2 -2
  3. package/dist/EnvironmentBuilder-15SdFJdK.cjs.map +1 -0
  4. package/dist/{EnvironmentBuilder-CFen3oIg.mjs → EnvironmentBuilder-C-2fViCT.mjs} +2 -2
  5. package/dist/EnvironmentBuilder-C-2fViCT.mjs.map +1 -0
  6. package/dist/{EnvironmentBuilder-DHfDXJUm.d.mts → EnvironmentBuilder-CoBQ9Xp2.d.mts} +2 -2
  7. package/dist/{EnvironmentBuilder-CNgcdzSR.d.cts.map → EnvironmentBuilder-CoBQ9Xp2.d.mts.map} +1 -1
  8. package/dist/{EnvironmentBuilder-CNgcdzSR.d.cts → EnvironmentBuilder-DeIle4QN.d.cts} +2 -2
  9. package/dist/{EnvironmentBuilder-DHfDXJUm.d.mts.map → EnvironmentBuilder-DeIle4QN.d.cts.map} +1 -1
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +1 -1
  14. package/dist/sst.cjs +13 -6
  15. package/dist/sst.cjs.map +1 -1
  16. package/dist/sst.d.cts +15 -4
  17. package/dist/sst.d.cts.map +1 -1
  18. package/dist/sst.d.mts +15 -4
  19. package/dist/sst.d.mts.map +1 -1
  20. package/dist/sst.mjs +13 -6
  21. package/dist/sst.mjs.map +1 -1
  22. package/package.json +6 -2
  23. package/CHANGELOG.md +0 -115
  24. package/dist/EnvironmentBuilder-CFen3oIg.mjs.map +0 -1
  25. package/dist/EnvironmentBuilder-DDgLJAAo.cjs.map +0 -1
  26. package/docs/api-reference.md +0 -302
  27. package/docs/async-secrets-design.md +0 -355
  28. package/examples/basic-usage.ts +0 -386
  29. package/src/EnvironmentBuilder.ts +0 -192
  30. package/src/EnvironmentParser.ts +0 -330
  31. package/src/SnifferEnvironmentParser.ts +0 -334
  32. package/src/SstEnvValidator.ts +0 -369
  33. package/src/SstEnvironmentBuilder.ts +0 -343
  34. package/src/__tests__/ConfigParser.spec.ts +0 -394
  35. package/src/__tests__/EnvironmentBuilder.spec.ts +0 -254
  36. package/src/__tests__/EnvironmentParser.spec.ts +0 -839
  37. package/src/__tests__/SnifferEnvironmentParser.spec.ts +0 -644
  38. package/src/__tests__/SstEnvValidator.spec.ts +0 -236
  39. package/src/__tests__/SstEnvironmentBuilder.spec.ts +0 -397
  40. package/src/__tests__/credentials.integration.spec.ts +0 -239
  41. package/src/__tests__/credentials.spec.ts +0 -136
  42. package/src/__tests__/formatter.spec.ts +0 -268
  43. package/src/__tests__/sst.spec.ts +0 -437
  44. package/src/credentials.ts +0 -112
  45. package/src/formatter.ts +0 -146
  46. package/src/index.ts +0 -24
  47. package/src/sst.ts +0 -76
  48. package/sst-env.d.ts +0 -8
  49. package/tsconfig.json +0 -9
  50. package/tsdown.config.ts +0 -18
@@ -1,644 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { z } from 'zod/v4';
3
- import {
4
- SnifferEnvironmentParser,
5
- sniffWithFireAndForget,
6
- } from '../SnifferEnvironmentParser';
7
-
8
- describe('SnifferEnvironmentParser', () => {
9
- describe('Environment variable tracking', () => {
10
- it('should track accessed environment variables', () => {
11
- const sniffer = new SnifferEnvironmentParser();
12
-
13
- sniffer.create((get) => ({
14
- appName: get('APP_NAME').string(),
15
- port: get('PORT').string().transform(Number),
16
- }));
17
-
18
- const envVars = sniffer.getEnvironmentVariables();
19
- expect(envVars).toEqual(['APP_NAME', 'PORT']);
20
- });
21
-
22
- it('should track variables in nested configurations', () => {
23
- const sniffer = new SnifferEnvironmentParser();
24
-
25
- sniffer.create((get) => ({
26
- database: {
27
- host: get('DB_HOST').string(),
28
- port: get('DB_PORT').string().transform(Number),
29
- },
30
- api: {
31
- key: get('API_KEY').string(),
32
- },
33
- }));
34
-
35
- const envVars = sniffer.getEnvironmentVariables();
36
- expect(envVars).toEqual(['API_KEY', 'DB_HOST', 'DB_PORT']);
37
- });
38
-
39
- it('should return sorted environment variable names', () => {
40
- const sniffer = new SnifferEnvironmentParser();
41
-
42
- sniffer.create((get) => ({
43
- zValue: get('Z_VALUE').string(),
44
- aValue: get('A_VALUE').string(),
45
- mValue: get('M_VALUE').string(),
46
- }));
47
-
48
- const envVars = sniffer.getEnvironmentVariables();
49
- expect(envVars).toEqual(['A_VALUE', 'M_VALUE', 'Z_VALUE']);
50
- });
51
-
52
- it('should deduplicate environment variable names', () => {
53
- const sniffer = new SnifferEnvironmentParser();
54
-
55
- sniffer.create((get) => ({
56
- value1: get('SHARED_VAR').string(),
57
- value2: get('SHARED_VAR').string(),
58
- value3: get('SHARED_VAR').string(),
59
- }));
60
-
61
- const envVars = sniffer.getEnvironmentVariables();
62
- expect(envVars).toEqual(['SHARED_VAR']);
63
- });
64
-
65
- it('should track variables accessed through coerce', () => {
66
- const sniffer = new SnifferEnvironmentParser();
67
-
68
- sniffer.create((get) => ({
69
- workers: get('NUM_WORKERS').coerce.number(),
70
- timeout: get('TIMEOUT').coerce.number(),
71
- }));
72
-
73
- const envVars = sniffer.getEnvironmentVariables();
74
- expect(envVars).toEqual(['NUM_WORKERS', 'TIMEOUT']);
75
- });
76
- });
77
-
78
- describe('Mock value parsing', () => {
79
- it('should never throw when parsing - returns mock values', () => {
80
- const sniffer = new SnifferEnvironmentParser();
81
-
82
- const config = sniffer.create((get) => ({
83
- required: get('REQUIRED_VAR').string(),
84
- alsoRequired: get('ALSO_REQUIRED').string(),
85
- }));
86
-
87
- // Should not throw even though env vars are not set
88
- expect(() => config.parse()).not.toThrow();
89
- });
90
-
91
- it('should return empty string for string schemas', () => {
92
- const sniffer = new SnifferEnvironmentParser();
93
-
94
- const config = sniffer
95
- .create((get) => ({
96
- value: get('STRING_VAR').string(),
97
- }))
98
- .parse();
99
-
100
- expect(config.value).toBe('');
101
- });
102
-
103
- it('should return 0 for number schemas', () => {
104
- const sniffer = new SnifferEnvironmentParser();
105
-
106
- const config = sniffer
107
- .create((get) => ({
108
- value: get('NUMBER_VAR').coerce.number(),
109
- }))
110
- .parse();
111
-
112
- expect(config.value).toBe(0);
113
- });
114
-
115
- it('should return false for boolean schemas', () => {
116
- const sniffer = new SnifferEnvironmentParser();
117
-
118
- const config = sniffer
119
- .create((get) => ({
120
- value: get('BOOL_VAR').coerce.boolean(),
121
- }))
122
- .parse();
123
-
124
- expect(config.value).toBe(false);
125
- });
126
-
127
- it('should return empty array for array schemas', () => {
128
- const sniffer = new SnifferEnvironmentParser();
129
-
130
- const config = sniffer
131
- .create((get) => ({
132
- value: get('ARRAY_VAR').array(z.string()),
133
- }))
134
- .parse();
135
-
136
- expect(config.value).toEqual([]);
137
- });
138
-
139
- it('should return undefined for optional schemas', () => {
140
- const sniffer = new SnifferEnvironmentParser();
141
-
142
- const config = sniffer
143
- .create((get) => ({
144
- value: get('OPTIONAL_VAR').string().optional(),
145
- }))
146
- .parse();
147
-
148
- expect(config.value).toBeUndefined();
149
- });
150
-
151
- it('should return null for nullable schemas', () => {
152
- const sniffer = new SnifferEnvironmentParser();
153
-
154
- const config = sniffer
155
- .create((get) => ({
156
- value: get('NULLABLE_VAR').string().nullable(),
157
- }))
158
- .parse();
159
-
160
- expect(config.value).toBeNull();
161
- });
162
-
163
- it('should handle object schemas with default values', () => {
164
- const sniffer = new SnifferEnvironmentParser();
165
-
166
- const objectSchema = z.object({
167
- name: z.string(),
168
- count: z.number(),
169
- });
170
-
171
- const config = sniffer
172
- .create((_get) => ({
173
- value: objectSchema,
174
- }))
175
- .parse();
176
-
177
- expect(config.value).toEqual({
178
- name: '',
179
- count: 0,
180
- });
181
- });
182
-
183
- it('should handle nested object schemas', () => {
184
- const sniffer = new SnifferEnvironmentParser();
185
-
186
- const nestedSchema = z.object({
187
- outer: z.object({
188
- inner: z.string(),
189
- }),
190
- });
191
-
192
- const config = sniffer
193
- .create((_get) => ({
194
- nested: nestedSchema,
195
- }))
196
- .parse();
197
-
198
- expect(config.nested).toEqual({
199
- outer: {
200
- inner: '',
201
- },
202
- });
203
- });
204
-
205
- it('should handle nested configurations', () => {
206
- const sniffer = new SnifferEnvironmentParser();
207
-
208
- const config = sniffer
209
- .create((get) => ({
210
- database: {
211
- host: get('DB_HOST').string(),
212
- port: get('DB_PORT').coerce.number(),
213
- },
214
- cache: {
215
- enabled: get('CACHE_ENABLED').coerce.boolean(),
216
- },
217
- }))
218
- .parse();
219
-
220
- expect(config).toEqual({
221
- database: {
222
- host: '',
223
- port: 0,
224
- },
225
- cache: {
226
- enabled: false,
227
- },
228
- });
229
- });
230
-
231
- it('should track variables with transforms', () => {
232
- const sniffer = new SnifferEnvironmentParser();
233
-
234
- sniffer.create((get) => ({
235
- origins: get('ALLOWED_ORIGINS')
236
- .string()
237
- .transform((v) => v.split(',')),
238
- port: get('PORT').string().transform(Number),
239
- }));
240
-
241
- // Should track the env vars even with transforms
242
- expect(sniffer.getEnvironmentVariables()).toEqual([
243
- 'ALLOWED_ORIGINS',
244
- 'PORT',
245
- ]);
246
- });
247
- });
248
-
249
- describe('Service registration simulation', () => {
250
- it('should allow simulated service registration to succeed', () => {
251
- const sniffer = new SnifferEnvironmentParser();
252
-
253
- // Simulate a service that would normally fail without env vars
254
- const mockService = {
255
- serviceName: 'database' as const,
256
- register(envParser: SnifferEnvironmentParser) {
257
- const config = envParser
258
- .create((get) => ({
259
- url: get('DATABASE_URL').string(),
260
- poolSize: get('DB_POOL_SIZE').coerce.number(),
261
- }))
262
- .parse();
263
-
264
- // Service uses parsed values to create connection
265
- return { url: config.url, poolSize: config.poolSize };
266
- },
267
- };
268
-
269
- // Should not throw
270
- expect(() => mockService.register(sniffer)).not.toThrow();
271
-
272
- // Should have tracked the env vars
273
- expect(sniffer.getEnvironmentVariables()).toEqual([
274
- 'DATABASE_URL',
275
- 'DB_POOL_SIZE',
276
- ]);
277
- });
278
-
279
- it('should work with multiple services', () => {
280
- const sniffer = new SnifferEnvironmentParser();
281
-
282
- const databaseService = {
283
- serviceName: 'db' as const,
284
- register(envParser: SnifferEnvironmentParser) {
285
- return envParser
286
- .create((get) => ({
287
- host: get('DB_HOST').string(),
288
- port: get('DB_PORT').coerce.number(),
289
- }))
290
- .parse();
291
- },
292
- };
293
-
294
- const cacheService = {
295
- serviceName: 'cache' as const,
296
- register(envParser: SnifferEnvironmentParser) {
297
- return envParser
298
- .create((get) => ({
299
- url: get('REDIS_URL').string(),
300
- ttl: get('CACHE_TTL').coerce.number(),
301
- }))
302
- .parse();
303
- },
304
- };
305
-
306
- // Register both services
307
- databaseService.register(sniffer);
308
- cacheService.register(sniffer);
309
-
310
- // Should have tracked all env vars from both services
311
- expect(sniffer.getEnvironmentVariables()).toEqual([
312
- 'CACHE_TTL',
313
- 'DB_HOST',
314
- 'DB_PORT',
315
- 'REDIS_URL',
316
- ]);
317
- });
318
-
319
- it('should handle async service registration', async () => {
320
- const sniffer = new SnifferEnvironmentParser();
321
-
322
- const asyncService = {
323
- serviceName: 'async' as const,
324
- async register(envParser: SnifferEnvironmentParser) {
325
- const config = envParser
326
- .create((get) => ({
327
- apiKey: get('API_KEY').string(),
328
- endpoint: get('API_ENDPOINT').string(),
329
- }))
330
- .parse();
331
-
332
- // Simulate async initialization
333
- await Promise.resolve();
334
- return config;
335
- },
336
- };
337
-
338
- await expect(asyncService.register(sniffer)).resolves.not.toThrow();
339
- expect(sniffer.getEnvironmentVariables()).toEqual([
340
- 'API_ENDPOINT',
341
- 'API_KEY',
342
- ]);
343
- });
344
- });
345
-
346
- describe('Optional variable tracking', () => {
347
- it('should track variables accessed with .optional() as optional', () => {
348
- const sniffer = new SnifferEnvironmentParser();
349
-
350
- sniffer.create((get) => ({
351
- required: get('REQUIRED_VAR').string(),
352
- optional: get('OPTIONAL_VAR').string().optional(),
353
- }));
354
-
355
- expect(sniffer.getOptionalVariables()).toEqual(['OPTIONAL_VAR']);
356
- });
357
-
358
- it('should track variables accessed with .default() as optional', () => {
359
- const sniffer = new SnifferEnvironmentParser();
360
-
361
- sniffer.create((get) => ({
362
- required: get('REQUIRED_VAR').string(),
363
- withDefault: get('DEFAULT_VAR').string().default('fallback'),
364
- }));
365
-
366
- expect(sniffer.getOptionalVariables()).toEqual(['DEFAULT_VAR']);
367
- });
368
-
369
- it('should track variables with .default() after .transform() as optional', () => {
370
- const sniffer = new SnifferEnvironmentParser();
371
-
372
- sniffer.create((get) => ({
373
- port: get('PORT').string().transform(Number).default(3000),
374
- }));
375
-
376
- expect(sniffer.getOptionalVariables()).toEqual(['PORT']);
377
- });
378
-
379
- it('should not include required variables in getOptionalVariables()', () => {
380
- const sniffer = new SnifferEnvironmentParser();
381
-
382
- sniffer.create((get) => ({
383
- required: get('DATABASE_URL').string(),
384
- optional: get('LOG_LEVEL').string().optional(),
385
- }));
386
-
387
- expect(sniffer.getOptionalVariables()).toEqual(['LOG_LEVEL']);
388
- expect(sniffer.getOptionalVariables()).not.toContain('DATABASE_URL');
389
- });
390
-
391
- it('getEnvironmentVariables({ markOptional: true }) suffixes optional vars with ?', () => {
392
- const sniffer = new SnifferEnvironmentParser();
393
-
394
- sniffer.create((get) => ({
395
- required: get('DATABASE_URL').string(),
396
- apiKey: get('API_KEY').string(),
397
- logLevel: get('LOG_LEVEL').string().optional(),
398
- port: get('PORT').string().default('3000'),
399
- }));
400
-
401
- expect(sniffer.getEnvironmentVariables({ markOptional: true })).toEqual([
402
- 'API_KEY',
403
- 'DATABASE_URL',
404
- 'LOG_LEVEL?',
405
- 'PORT?',
406
- ]);
407
- });
408
-
409
- it('getEnvironmentVariables() without option returns plain names', () => {
410
- const sniffer = new SnifferEnvironmentParser();
411
-
412
- sniffer.create((get) => ({
413
- required: get('DATABASE_URL').string(),
414
- optional: get('PORT').string().default('3000'),
415
- }));
416
-
417
- expect(sniffer.getEnvironmentVariables()).toEqual([
418
- 'DATABASE_URL',
419
- 'PORT',
420
- ]);
421
- });
422
-
423
- it('getEnvironmentVariables({ markOptional: false }) returns plain names', () => {
424
- const sniffer = new SnifferEnvironmentParser();
425
-
426
- sniffer.create((get) => ({
427
- required: get('DATABASE_URL').string(),
428
- optional: get('PORT').string().default('3000'),
429
- }));
430
-
431
- expect(sniffer.getEnvironmentVariables({ markOptional: false })).toEqual([
432
- 'DATABASE_URL',
433
- 'PORT',
434
- ]);
435
- });
436
-
437
- it('should return empty getOptionalVariables() when all vars are required', () => {
438
- const sniffer = new SnifferEnvironmentParser();
439
-
440
- sniffer.create((get) => ({
441
- url: get('DATABASE_URL').string(),
442
- key: get('API_KEY').string(),
443
- }));
444
-
445
- expect(sniffer.getOptionalVariables()).toEqual([]);
446
- });
447
-
448
- it('should handle mix of optional and default across nested config', () => {
449
- const sniffer = new SnifferEnvironmentParser();
450
-
451
- sniffer.create((get) => ({
452
- database: {
453
- url: get('DATABASE_URL').string(),
454
- poolSize: get('DB_POOL_SIZE').string().transform(Number).default(10),
455
- },
456
- cache: {
457
- url: get('REDIS_URL').string().optional(),
458
- ttl: get('CACHE_TTL').string(),
459
- },
460
- }));
461
-
462
- expect(sniffer.getOptionalVariables().sort()).toEqual([
463
- 'DB_POOL_SIZE',
464
- 'REDIS_URL',
465
- ]);
466
- expect(sniffer.getEnvironmentVariables({ markOptional: true })).toEqual([
467
- 'CACHE_TTL',
468
- 'DATABASE_URL',
469
- 'DB_POOL_SIZE?',
470
- 'REDIS_URL?',
471
- ]);
472
- });
473
- });
474
-
475
- describe('Edge cases', () => {
476
- it('should return empty array when no variables accessed', () => {
477
- const sniffer = new SnifferEnvironmentParser();
478
-
479
- sniffer.create(() => ({}));
480
-
481
- expect(sniffer.getEnvironmentVariables()).toEqual([]);
482
- });
483
-
484
- it('should handle deeply nested objects', () => {
485
- const sniffer = new SnifferEnvironmentParser();
486
-
487
- sniffer.create((get) => ({
488
- level1: {
489
- level2: {
490
- level3: {
491
- value: get('DEEP_VALUE').string(),
492
- },
493
- },
494
- },
495
- }));
496
-
497
- expect(sniffer.getEnvironmentVariables()).toEqual(['DEEP_VALUE']);
498
- });
499
-
500
- it('should handle multiple create calls', () => {
501
- const sniffer = new SnifferEnvironmentParser();
502
-
503
- sniffer.create((get) => ({
504
- first: get('FIRST_VAR').string(),
505
- }));
506
-
507
- sniffer.create((get) => ({
508
- second: get('SECOND_VAR').string(),
509
- }));
510
-
511
- // Should accumulate vars from both create calls
512
- expect(sniffer.getEnvironmentVariables()).toEqual([
513
- 'FIRST_VAR',
514
- 'SECOND_VAR',
515
- ]);
516
- });
517
- });
518
- });
519
-
520
- describe('sniffWithFireAndForget', () => {
521
- it('should capture environment variables from synchronous operations', async () => {
522
- const sniffer = new SnifferEnvironmentParser();
523
-
524
- const result = await sniffWithFireAndForget(sniffer, () => {
525
- sniffer.create((get) => ({
526
- dbUrl: get('DATABASE_URL').string(),
527
- apiKey: get('API_KEY').string(),
528
- }));
529
- });
530
-
531
- expect(result.envVars).toEqual(['API_KEY', 'DATABASE_URL']);
532
- expect(result.error).toBeUndefined();
533
- expect(result.unhandledRejections).toEqual([]);
534
- });
535
-
536
- it('should capture environment variables from async operations', async () => {
537
- const sniffer = new SnifferEnvironmentParser();
538
-
539
- const result = await sniffWithFireAndForget(sniffer, async () => {
540
- await Promise.resolve();
541
- sniffer.create((get) => ({
542
- redisUrl: get('REDIS_URL').string(),
543
- }));
544
- });
545
-
546
- expect(result.envVars).toEqual(['REDIS_URL']);
547
- expect(result.error).toBeUndefined();
548
- });
549
-
550
- it('should capture error when operation throws synchronously', async () => {
551
- const sniffer = new SnifferEnvironmentParser();
552
-
553
- const result = await sniffWithFireAndForget(sniffer, () => {
554
- sniffer.create((get) => ({
555
- value: get('CAPTURED_BEFORE_ERROR').string(),
556
- }));
557
- throw new Error('Sync error');
558
- });
559
-
560
- // Should still capture env vars accessed before the error
561
- expect(result.envVars).toEqual(['CAPTURED_BEFORE_ERROR']);
562
- expect(result.error).toBeInstanceOf(Error);
563
- expect(result.error?.message).toBe('Sync error');
564
- });
565
-
566
- it('should capture error when async operation rejects', async () => {
567
- const sniffer = new SnifferEnvironmentParser();
568
-
569
- const result = await sniffWithFireAndForget(sniffer, async () => {
570
- sniffer.create((get) => ({
571
- value: get('CAPTURED_BEFORE_REJECT').string(),
572
- }));
573
- throw new Error('Async rejection');
574
- });
575
-
576
- expect(result.envVars).toEqual(['CAPTURED_BEFORE_REJECT']);
577
- expect(result.error).toBeInstanceOf(Error);
578
- expect(result.error?.message).toBe('Async rejection');
579
- });
580
-
581
- it('should convert non-Error throws to Error objects', async () => {
582
- const sniffer = new SnifferEnvironmentParser();
583
-
584
- const result = await sniffWithFireAndForget(sniffer, () => {
585
- throw 'string error';
586
- });
587
-
588
- expect(result.error).toBeInstanceOf(Error);
589
- expect(result.error?.message).toBe('string error');
590
- });
591
-
592
- it('should use custom settle time', async () => {
593
- const sniffer = new SnifferEnvironmentParser();
594
- const startTime = Date.now();
595
-
596
- await sniffWithFireAndForget(sniffer, () => {}, { settleTimeMs: 50 });
597
-
598
- const elapsed = Date.now() - startTime;
599
- // Should wait approximately 50ms (allow small timing variance)
600
- expect(elapsed).toBeGreaterThanOrEqual(45);
601
- expect(elapsed).toBeLessThan(200);
602
- });
603
-
604
- it('should return empty arrays when no vars accessed and no errors', async () => {
605
- const sniffer = new SnifferEnvironmentParser();
606
-
607
- const result = await sniffWithFireAndForget(sniffer, () => {
608
- // Do nothing
609
- });
610
-
611
- expect(result.envVars).toEqual([]);
612
- expect(result.error).toBeUndefined();
613
- expect(result.unhandledRejections).toEqual([]);
614
- });
615
-
616
- it('should include optionalEnvVars in result', async () => {
617
- const sniffer = new SnifferEnvironmentParser();
618
-
619
- const result = await sniffWithFireAndForget(sniffer, () => {
620
- sniffer.create((get) => ({
621
- required: get('DATABASE_URL').string(),
622
- optional: get('PORT').string().default('3000'),
623
- alsoOptional: get('LOG_LEVEL').string().optional(),
624
- }));
625
- });
626
-
627
- expect(result.envVars).toEqual(['DATABASE_URL', 'LOG_LEVEL', 'PORT']);
628
- expect(result.optionalEnvVars).toEqual(['LOG_LEVEL', 'PORT']);
629
- expect(result.error).toBeUndefined();
630
- });
631
-
632
- it('should return empty optionalEnvVars when all vars are required', async () => {
633
- const sniffer = new SnifferEnvironmentParser();
634
-
635
- const result = await sniffWithFireAndForget(sniffer, () => {
636
- sniffer.create((get) => ({
637
- url: get('DATABASE_URL').string(),
638
- key: get('API_KEY').string(),
639
- }));
640
- });
641
-
642
- expect(result.optionalEnvVars).toEqual([]);
643
- });
644
- });