import { testEnvironment } from "https://deno.land/x/enzastdlib@v0.0.4/environment/mod.ts";
Returns Error
objects of any validation errors that have occured regarding the
specified environment variables, if any.
NOTE: To specify environment variables to test you MUST supply a JSON Schema that defines a top-level object.
NOTE: Only second-level keys are used for testing environment variables.
Examples
terminal
terminal
export MY_STRING='Hello World!'
schema.ts
import type { JSONSchema } from 'https://deno.land/x/enzastdlib/schema/mod.ts';
export const MY_STRING_SCHEMA = {
type: 'object',
properties: {
MY_STRING: {
type: 'string',
minLength: 1,
},
},
} as const satisfies JSONSchema;
mod.ts
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts';
import { testEnvironment } from 'https://deno.land/x/enzastdlib/environment/mod.ts';
import { MY_STRING_SCHEMA } from './schema.ts';
assertEquals(
testEnvironment(MY_STRING_SCHEMA),
undefined,
);
Parameters
schema: JSONSchemaObject