EnvModel: Set env value from .env files and config value with default value
Overview
These tests validate nestjs-mod EnvModel: environment variable reading, required field validation, and DI value propagation into services.
What We Do And Verify
-
We verify how
configTransformandConfigModel/ConfigModelPropertydecorators process input parameters. -
We lock the validation contract and error shape expected by configuration consumers.
-
We confirm that modules/services receive properly prepared configuration values.
-
We explicitly validate the error contract: not only failure itself, but also error shape/content expected by module consumers.
-
We confirm correct lifecycle behavior in test environment: initialization, dependency readiness, and graceful shutdown of app/modules.
GitHub Reference
- File: static-environments-model-with-boolean.spec.ts
- Line: 174
Setup Code
import {
import { DefaultTestNestApplicationCreate, DefaultTestNestApplicationInitializer } from '@nestjs-mod/testing';
import { join } from 'path';
describe('staticEnvironmentsModel', () => {
// full test in the block below
});