-
Notifications
You must be signed in to change notification settings - Fork 198
Unable to debug rules using the Run TSLint Tests template #703
Comments
Hi @reduckted , exactly as you describe. Can you share the test folder content that's associated with what your'e showing? Thanks 🏆 |
What file are you putting the breakpoint in? Here's the file listing of the
Here's the output in the debug console:
|
I was able to reproduce this issue. For example I tried to place 3 breakpoints in public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (Rule.isWarningShown === false) { // <- Doesn't work (never hit).
console.warn('Warning: valid-typeof rule is deprecated. Replace your usage with the TSLint typeof-compare rule.');
Rule.isWarningShown = true; // <- Inconsistent (few hits, but rarely)
}
return this.applyWithFunction(sourceFile, walk); // <- Works almost always (after few rebuilds stopped to work)
} These are simple lines that should definitely hit at least once, but e.g. first line never worked for me. As workaround I've added import { ExtendedMetadata } from './utils/ExtendedMetadata';
debugger;
export class Rule extends Lint.Rules.AbstractRule { rebuild sources and sourcemaps ( @noamyogev84 could you please try same steps and see if this workaround works for you? UPD. Just to clarify - I will continue investigation to determine root cause. At this time it may be quick workaround and check some theories. |
Nice find! I guess I got lucky with what I tried out. I can confirm that it doesn't hit the breakpoints when I put them in any of those places in I took a look at what tslint uses for its debugging of tests, and it appears that the {
"type": "node",
"request": "launch",
"name": "Run TSLint Tests",
"program": "${workspaceFolder}/node_modules/tslint/bin/tslint",
"args": ["--test", "-r", "dist/src", "tests/**"],
"outputCapture": "std",
"outFiles": ["${workspaceRoot}/dist/src/**/*.js"],
"cwd": "${workspaceFolder}",
"runtimeArgs": ["--nolazy"]
} I've also added the |
/cc @roblourens - good case study in why VS Code debuggering is still a bit confusing. |
Indeed. Not sure why it worked for some files, but failed for others. I also discovered that, without |
Glad you figured it out. Any ideas on how I could have made it more obvious? outFiles is not required but it is recommended to be used when possible. vscode will still load the script's sourcemaps when the script loads, but there is a race between loading the sourcemap and running the line of code with the breakpoint. outFiles lets us pre-load sourcemaps off disk before running the program. |
How about a suggestion for this particular case of not including the Right now we just get a generic "breakpoint won't be loaded" complaint without any indication of why., or easy access to the list of files that would be included. Just a quick thought - seems rather hardcoded to this scenario, and it'd be nice to have a more general solution. |
Yeah but I don't know whether anything has actually gone wrong yet, it may be that the file is just not loaded. And if the breakpoint was supposed to be hit, that describes many possible issues with the setup or the sourcemaps. |
Is there a way we could detect our use case? Suppose you have
|
The breakpoints will be in If we want to hint that the outFiles field could have been used, maybe we would want to detect when a sourcemap is loaded from disk but was not preloaded, then show a hint. But it is kind of specific. |
Bug Report
tslint-microsoft-contrib
version: latestTrying to debug tests under
tests
folder with no success.Command:
node.exe --inspect-brk=27157 node_modules\tslint\bin\tslint --test -r dist/src tests/**
Output:
Debugger listening on ws://127.0.0.1:27157/da6329d9-5a8f-4729-965a-9339e2d17953
Debug console lists all tests with
passed
, no breakpoint is being hit.The text was updated successfully, but these errors were encountered: