Skip to content

Commit

Permalink
feat: support codeLens.testEnvs
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuigo committed Dec 27, 2022
1 parent 5ab30d8 commit e161934
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ 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 process environments
- `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 @@ -279,7 +279,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 @@ -220,6 +220,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

0 comments on commit e161934

Please sign in to comment.