react-code-dataset / next.js /packages /next /src /server /lib /experimental /create-env-definitions.test.ts
Download next.js/packages/next/src/server/lib/experimental/create-env-definitions.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.65 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/server/lib/experimental/create-env-definitions.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/server/lib/experimental/create-env-definitions.test.ts
-
curl -L -o create-env-definitions.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/server/lib/experimental/create-env-definitions.test.ts
2.65 kB
| import { createEnvDefinitions } from './create-env-definitions' | |
| describe('create-env-definitions', () => { | |
| it('should create env definitions', async () => { | |
| const loadedEnvFiles = [ | |
| { | |
| path: '.env.local', | |
| contents: '', | |
| env: { | |
| FROM_ENV_LOCAL: 'FROM_ENV_LOCAL', | |
| }, | |
| }, | |
| { | |
| path: '.env.development.local', | |
| contents: '', | |
| env: { | |
| FROM_ENV_DEV_LOCAL: 'FROM_ENV_DEV_LOCAL', | |
| }, | |
| }, | |
| { | |
| path: 'next.config.js', | |
| contents: '', | |
| env: { | |
| FROM_NEXT_CONFIG: 'FROM_NEXT_CONFIG', | |
| }, | |
| }, | |
| ] | |
| const definitionStr = await createEnvDefinitions({ | |
| distDir: '/dist', | |
| loadedEnvFiles, | |
| }) | |
| expect(definitionStr).toMatchInlineSnapshot(` | |
| "// Type definitions for Next.js environment variables | |
| declare global { | |
| namespace NodeJS { | |
| interface ProcessEnv { | |
| /** Loaded from \`.env.local\` */ | |
| FROM_ENV_LOCAL?: string | |
| /** Loaded from \`.env.development.local\` */ | |
| FROM_ENV_DEV_LOCAL?: string | |
| /** Loaded from \`next.config.js\` */ | |
| FROM_NEXT_CONFIG?: string | |
| } | |
| } | |
| } | |
| export {}" | |
| `) | |
| }) | |
| it('should allow empty env', async () => { | |
| const definitionStr = await createEnvDefinitions({ | |
| distDir: '/dist', | |
| loadedEnvFiles: [], | |
| }) | |
| expect(definitionStr).toMatchInlineSnapshot(` | |
| "// Type definitions for Next.js environment variables | |
| declare global { | |
| namespace NodeJS { | |
| interface ProcessEnv { | |
| } | |
| } | |
| } | |
| export {}" | |
| `) | |
| }) | |
| it('should dedupe env definitions in order of priority', async () => { | |
| const loadedEnvFiles = [ | |
| { | |
| path: '.env.local', | |
| contents: '', | |
| env: { | |
| DUPLICATE_ENV: 'DUPLICATE_ENV', | |
| }, | |
| }, | |
| { | |
| path: '.env.development.local', | |
| contents: '', | |
| env: { | |
| DUPLICATE_ENV: 'DUPLICATE_ENV', | |
| }, | |
| }, | |
| { | |
| path: 'next.config.js', | |
| contents: '', | |
| env: { | |
| DUPLICATE_ENV: 'DUPLICATE_ENV', | |
| }, | |
| }, | |
| ] | |
| const definitionStr = await createEnvDefinitions({ | |
| distDir: '/dist', | |
| loadedEnvFiles, | |
| }) | |
| expect(definitionStr).toMatchInlineSnapshot(` | |
| "// Type definitions for Next.js environment variables | |
| declare global { | |
| namespace NodeJS { | |
| interface ProcessEnv { | |
| /** Loaded from \`.env.local\` */ | |
| DUPLICATE_ENV?: string | |
| } | |
| } | |
| } | |
| export {}" | |
| `) | |
| }) | |
| }) | |