Skip to content
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

feat: support codeLens.testEnvs #776

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ extension has the following configuration options:
- `deno.codeLens.testArgs`: Provides additional arguments that should be set
when invoking the Deno CLI test from a code lens. _array of strings, default
`[ "--allow-all" ]`_.
- `deno.codeLens.testEnvs`: Provides additional environments that should be set
when invoking the Deno CLI test from a code lens. Its value type should be
`Record<string, string>`, e.g., `{"APP_MODE":"debug"}`.
- `deno.config`: The file path to a configuration file. This is the equivalent
to using `--config` on the command line. The path can be either be relative to
the workspace, or an absolute path. It is recommended you name this file
Expand Down
2 changes: 1 addition & 1 deletion client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export function test(
testArgs.push("--import-map", importMap.trim());
}
}
const env = {} as Record<string, string>;
const env = config.get("codeLens.testEnvs", {}) as Record<string, string>;
const cacheDir: string | undefined | null = config.get("cache");
if (cacheDir?.trim()) {
env["DENO_DIR"] = cacheDir.trim();
Expand Down
1 change: 1 addition & 0 deletions client/src/shared_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface Settings {
referencesAllFunctions: boolean;
test: boolean;
testArgs: string[];
testEnvs: Record<string, string>;
} | null;
/** A path to a configuration file that should be applied. */
config: string | null;
Expand Down
12 changes: 9 additions & 3 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ The code lenses are enabled by default. To disable them, set
`deno.codeLens.test` to `false` in your settings.

Additional arguments, outside of just the module to test and the test filter,
are supplied when executing the Deno CLI. These are configured via
`deno.codeLens.testArgs`. They default to `[ "--allow-all" ]`. In addition, when
executing the test, the extension will reflect the `deno.unstable` setting in
are supplied when executing the Deno CLI.

Deno plugin supports these configration:

1. `deno.codeLens.testArgs`. They default to `[ "--allow-all" ]`.
2. `deno.codeLens.testEnvs`. This envs will be passed to cli as process enviroments.

## `deno.unstable`
In addition, when executing the test, the extension will reflect the `deno.unstable` setting in
the command line, meaning that if it is `true` then the `--unstable` flag will
be sent as an argument to the test command.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@
"markdownDescription": "Additional arguments to use with the run test code lens. Defaults to `[ \"--allow-all\", \"--no-check\" ]`.",
"scope": "resource"
},
"deno.codeLens.testEnvs": {
"type": "object",
"default": {},
"description": "Environment variables that will be passed to the process that runs the Deno tests",
"scope": "resource"
},
"deno.config": {
"type": "string",
"default": null,
Expand Down