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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ahuigo
Copy link

@ahuigo ahuigo commented Dec 27, 2022

For #661

This new new option codeLens.testEnvs is used to custom environment variables for deno test

@CLAassistant
Copy link

CLAassistant commented Dec 27, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's reasonable solution, @crowlKats thoughts?

@crowlKats
Copy link
Member

Yea, think so too. Will test it to see if it works properly

@bartlomieju
Copy link
Member

@crowlKats any update?

README.md Outdated
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These docs should be updated to provide more information about its purpose

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've provided more information about its purpose.

docs/testing.md Outdated
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## deno.unstable
## `deno.unstable`

@crowlKats
Copy link
Member

@bartlomieju apologies; I tried however no luck getting it to work

@bartlomieju
Copy link
Member

@bartlomieju apologies; I tried however no luck getting it to work

Okay, I'll investigate it myself after NYE

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't get it to work either, putting variables in deno.codeLens.testEnvs has no effect on me. @ahuigo how were you able to make it work?

@ahuigo
Copy link
Author

ahuigo commented Jan 4, 2023

I can't get it to work either, putting variables in deno.codeLens.testEnvs has no effect on me. @ahuigo how were you able to make it work?

@bartlomieju @crowlKats

My test code

import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";

Deno.test("test deno testEnvs", async (t) => {
  await t.step("test 1", async () => {
    console.error("env ULTRA_MODE:",Deno.env.get('ULTRA_MODE'))
    assertEquals(Deno.env.get('ULTRA_MODE'), 'debug')
  });
});

Reproduce my test

0. Start this dev Deno plugin.

Press F5 with this PR code.

1. Set testEnvs

In my test, I set ULTRA_MODE to be development123:

image
image

2. Then click Debug or Run Test

Though the testEnvs is not visible in the cli line, we can read the correct value development123
in the following figure(See DEBUG CONSOLE and TERMINAL tab)

image
image

My device

macOsx: 12.6
cpu: Darwin 21.6.0 arm64 core(10) Apple M1 Pro
vscode: 1.71.2 74b1f979648cc44d385a2286793c226e611f59e7 arm64
deno 1.29.1 (release, aarch64-apple-darwin)
v8 10.9.194.5
typescript 4.9.4
deno extensions: [email protected]

@bartlomieju
Copy link
Member

@ahuigo when I do the same steps I get following output:

Screenshot 2023-01-04 at 13 37 04

One difference is that I don't see anything in "Debug console" or "Terminal" tabs.

To be honest I'm a bit at loss why that happens. Everything looks correct in the PR.

@ahuigo
Copy link
Author

ahuigo commented Jan 4, 2023

@bartlomieju

  1. Have you set testEnvs correctly in workspace .vscode/settings.json?
{
  "deno.codeLens.testEnvs": {
    "ULTRA_MODE": "development123"
  }
}
  1. Could you show me your plugin's debug info like this {...config.get("codeLens.testEnvs", {})} ?
    image

What's weird to me is that in breakpoint debugging, I can't read the value of env directly, but I can read its value via definition.env.

Perhaps the env is vscode's keyword. https://code.visualstudio.com/docs/editor/variables-reference#_environment-variables

  1. What's your version of Vscode?
    I guess it could be a problem with Vscode

@bartlomieju
Copy link
Member

I think something is wrong with my setup - I can't hit any debug breakpoints I set in the client code :/ I'm looking into it

@ahuigo
Copy link
Author

ahuigo commented Jan 4, 2023

Try turning off the Deno plugin. @bartlomieju

@bartlomieju
Copy link
Member

Try turning off the Deno plugin. @bartlomieju

I tried that, including removing Deno extension completely and it doesn't really help. No breakpoints are ever hit for the "test" command.

@ahuigo
Copy link
Author

ahuigo commented Jan 4, 2023

I don't know if it has anything to do with this problem: #708

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants