UNPKG

nested-env-schema

Version:

Validate & extract your env variables using nested JSON schema, Ajv and dotenvx

39 lines (34 loc) 764 B
'use strict'; const { test } = require('tap'); const envSchema = require('../lib/index'); test('no globals', (t) => { t.plan(2); const options = { confKey: 'secrets', data: { MONGO_URL: 'good', }, schema: { $id: 'schema:dotenv', type: 'object', required: ['MONGO_URL'], properties: { PORT: { type: 'integer', default: 3000, }, MONGO_URL: { type: 'string', }, }, }, }; { const conf = envSchema(JSON.parse(JSON.stringify(options))); t.strictSame(conf, { MONGO_URL: 'good', PORT: 3000 }); } { const conf = envSchema(JSON.parse(JSON.stringify(options))); t.strictSame(conf, { MONGO_URL: 'good', PORT: 3000 }); } });