-
Notifications
You must be signed in to change notification settings - Fork 76
feat: Support .env files by default via dotenv/config #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "evalite": minor | ||
| --- | ||
|
|
||
| Support .env files by default via dotenv/config. Environment variables from .env files are now automatically loaded without any configuration needed. Users no longer need to manually add `setupFiles: ["dotenv/config"]` to their evalite.config.ts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/evalite-tests/tests/fixtures/config-setupfiles-precedence/evalite-setup.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Setup file from evalite.config.ts - should override vitest | ||
| process.env.SETUP_ORDER = "evalite"; |
5 changes: 5 additions & 0 deletions
5
packages/evalite-tests/tests/fixtures/config-setupfiles-precedence/evalite.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { defineConfig } from "evalite/config"; | ||
|
|
||
| export default defineConfig({ | ||
| setupFiles: ["./evalite-setup.ts"], | ||
| }); |
15 changes: 15 additions & 0 deletions
15
packages/evalite-tests/tests/fixtures/config-setupfiles-precedence/test.eval.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { evalite } from "evalite"; | ||
| import { Levenshtein } from "autoevals"; | ||
|
|
||
| evalite("Precedence Test", { | ||
| data: () => [ | ||
| { | ||
| input: "test", | ||
| expected: "evalite", | ||
| }, | ||
| ], | ||
| task: async (input) => { | ||
| return process.env.SETUP_ORDER as string; | ||
| }, | ||
| scorers: [Levenshtein], | ||
| }); |
2 changes: 2 additions & 0 deletions
2
packages/evalite-tests/tests/fixtures/config-setupfiles-precedence/vitest-setup.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Setup file from vitest.config.ts | ||
| process.env.SETUP_ORDER = "vitest"; |
7 changes: 7 additions & 0 deletions
7
packages/evalite-tests/tests/fixtures/config-setupfiles-precedence/vitest.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| setupFiles: ["./vitest-setup.ts"], | ||
| }, | ||
| }); |
15 changes: 15 additions & 0 deletions
15
packages/evalite-tests/tests/fixtures/config-setupfiles-vitest/test.eval.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { evalite } from "evalite"; | ||
| import { Levenshtein } from "autoevals"; | ||
|
|
||
| evalite("Vitest Setup Test", { | ||
| data: () => [ | ||
| { | ||
| input: "test", | ||
| expected: process.env.VITEST_SETUP_VAR, | ||
| }, | ||
| ], | ||
| task: async (input) => { | ||
| return process.env.VITEST_SETUP_VAR as string; | ||
| }, | ||
| scorers: [Levenshtein], | ||
| }); |
2 changes: 2 additions & 0 deletions
2
packages/evalite-tests/tests/fixtures/config-setupfiles-vitest/vitest-setup.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Setup file from vitest.config.ts | ||
| process.env.VITEST_SETUP_VAR = "from_vitest_config"; |
7 changes: 7 additions & 0 deletions
7
packages/evalite-tests/tests/fixtures/config-setupfiles-vitest/vitest.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| setupFiles: ["./vitest-setup.ts"], | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // This file is automatically loaded by Evalite to support .env files | ||
| // It loads environment variables from .env files using dotenv | ||
| import "dotenv/config"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { defineConfig } from "evalite/config"; | ||
|
|
||
| export default defineConfig({ | ||
| setupFiles: ["dotenv/config"], | ||
| // .env files are now loaded automatically! | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Vitest Setup Files Override Vite Configuration
The
setupFilesarray is now always initialized with"evalite/env-setup-file", even when not specified inevalite.config.ts. This unconditionally sets Vitest'ssetupFiles, overriding any values configured invite.config.tsthat would otherwise apply.