debugger: Fix a few issues with JS debugging (#32918)
- Don't assume all located tasks come from our test runnables - Run tests from the right working directory - Scope forking behavior customization for jest and vitest more tightly, to just our test runnables - Standardize on `$PACKAGE_MANAGER exec -- $TEST_LIBRARY ...` to fix runnables not working with npm Release Notes: - Debugger Beta: Fixed issues with debugging tasks from package.json and test runnables.
This commit is contained in:
parent
3e8a07f496
commit
2f52e2d285
2 changed files with 48 additions and 45 deletions
|
@ -1,4 +1,4 @@
|
|||
use std::{borrow::Cow, path::PathBuf};
|
||||
use std::borrow::Cow;
|
||||
|
||||
use anyhow::{Result, bail};
|
||||
use async_trait::async_trait;
|
||||
|
@ -31,38 +31,14 @@ impl DapLocator for NodeLocator {
|
|||
if build_config.command != TYPESCRIPT_RUNNER_VARIABLE.template_value() {
|
||||
return None;
|
||||
}
|
||||
let test_library = build_config.args.first()?;
|
||||
let program_path_base: PathBuf = match test_library.as_str() {
|
||||
"jest" => "${ZED_CUSTOM_TYPESCRIPT_JEST_PACKAGE_PATH}".to_owned(),
|
||||
"mocha" => "${ZED_CUSTOM_TYPESCRIPT_MOCHA_PACKAGE_PATH}".to_owned(),
|
||||
"vitest" => "${ZED_CUSTOM_TYPESCRIPT_VITEST_PACKAGE_PATH}".to_owned(),
|
||||
"jasmine" => "${ZED_CUSTOM_TYPESCRIPT_JASMINE_PACKAGE_PATH}".to_owned(),
|
||||
_ => VariableName::WorktreeRoot.template_value(),
|
||||
}
|
||||
.into();
|
||||
|
||||
let program_path = program_path_base
|
||||
.join("node_modules")
|
||||
.join(".bin")
|
||||
.join(test_library);
|
||||
|
||||
let mut args = if test_library == "jest" {
|
||||
vec!["--runInBand".to_owned()]
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
args.extend(build_config.args[1..].iter().cloned());
|
||||
|
||||
let config = serde_json::json!({
|
||||
"request": "launch",
|
||||
"type": "pwa-node",
|
||||
"runtimeExecutable": program_path,
|
||||
"args": args,
|
||||
"args": build_config.args.clone(),
|
||||
"cwd": build_config.cwd.clone(),
|
||||
"env": {
|
||||
"VITEST_MIN_FORKS": "0",
|
||||
"VITEST_MAX_FORKS": "1"
|
||||
},
|
||||
"runtimeExecutable": build_config.command.clone(),
|
||||
"env": build_config.env.clone(),
|
||||
"runtimeArgs": ["--inspect-brk"],
|
||||
"console": "integratedTerminal",
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue