"Ctrl+click to follow link" in VSCode terminal doesn't jump to source file but opens new browser tab


uminder

I'm working on an Angular 8 project using Visual Studio Code (version 1.40.1) and running Karma/Jasmine tests from its terminal via commands . When a test fails, I'm always able to jump to the relevant source file via the terminal link embedded in the stack trace . For a few days this no longer works, instead a new Chrome browser tab is opened.ng testCtrl + click

enter image description here

I think the problem might be related to any recently updated npmpackages. So I created a brand new Angular 8 project ( ng new), made minor changes to app.component.spec.tsit and started ng test. Unfortunately, the same problem occurs here. Completely uninstalling and reinstalling VSCode didn't help either.

Any ideas on how to get the original functionality (jump to source)?

package.json

{
  "name": "app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~8.2.13",
    "@angular/common": "~8.2.13",
    "@angular/compiler": "~8.2.13",
    "@angular/core": "~8.2.13",
    "@angular/forms": "~8.2.13",
    "@angular/platform-browser": "~8.2.13",
    "@angular/platform-browser-dynamic": "~8.2.13",
    "@angular/router": "~8.2.13",
    "rxjs": "~6.4.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.18",
    "@angular/cli": "~8.3.18",
    "@angular/compiler-cli": "~8.2.13",
    "@angular/language-service": "~8.2.13",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.5.3"
  }
}

karma.config.js

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, './coverage/app'),
      reports: ['html', 'lcovonly', 'text-summary'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false,
    restartOnFileChange: true
  });
};
David

You ctrl+click doesn't navigate directly to the file, because the error stack is displayed, http://localhost:9876/_karma_webpack_/src/app/app.component.spec.tsnot src/app/app.component.spec.ts.

You can use the option suggested in this answer , which consists of specifying a function in configformatErrorkarma.conf.js

 formatError: (msg) =>
  msg.replace(/http:\/\/localhost:9876\/_karma_webpack_\//g, '')

This will cause karma to use the above method http://localhost:9876/_karma_webpack_when formatting the error stack ( completely removed from the stack trace ).

Now, why this is happening, I'm not sure. I checked out an old angular 7 project which had an old dependency of karma/jasmine/...and it worked as before (ie the error stack pointed directly to the file in src).

Then I upgraded karma, jasmine, karma jasmine... to the latest version and it still works.

I also started having the same problem when I upgraded to angular 8. So there must be a change somewhere, but I don't know where

Related


File browser terminal in VSCode

Ryan Quinn Terminal only covers the editor part of VSCode, not the file browser. Is there a setting that tells VSCode that you want the terminal to be the full width of the screen even if the file browser is visible? Also, do you know what the keyboard shortcu

VSCode opens new view in file

ADIN We can combine the two views into one file using the Split Editor option. I'm looking for an option to open the same file in a separate tab as in Sublime Text (open a new view of the file). Is that possible? Note: I want to do this without splitting the v

Xpages link opens New Browser tab

federation I found some questions similar to this in stackoverflow, but no exact match. I'm trying to modify a Xpagesproject to display search results in a "Dynamic View Panel". The first column of the search results is a link that opens the record in the same

Xpages link opens New Browser tab

federation I found some questions similar to this in stackoverflow, but no exact match. I'm trying to modify a Xpagesproject to display search results in a "Dynamic View Panel". The first column of the search results is a link that opens the record in the same

VS used to open browser in new tab, now it opens new browser

Sam: I've been updating to the latest version of Visual Studio Preview and I think the settings have changed. When I start debugging an ASP.NET web application in Visual Studio 2017 15.7.0 Preview 4, VS will open a new browser. I had a similar problem before a

VS used to open browser in new tab, now it opens new browser

Sam: I've been updating to the latest version of Visual Studio Preview and I think the settings have changed. When I start debugging an ASP.NET web application in Visual Studio 2017 15.7.0 Preview 4, VS will open a new browser. I had a similar problem before a

VS used to open browser in new tab, now it opens new browser

Sam: I've been updating to the latest version of Visual Studio Preview and I think the settings have changed. When I start debugging an ASP.NET web application in Visual Studio 2017 15.7.0 Preview 4, VS will open a new browser. I had a similar problem before a

VS used to open browser in new tab, now it opens new browser

Sam: I've been updating to the latest version of Visual Studio Preview and I think the settings have changed. When I start debugging an ASP.NET web application in Visual Studio 2017 15.7.0 Preview 4, VS will open a new browser. I had a similar problem before a

HTML 5 a Tag doesn't download file but opens a new page

Vian Ojeda Garcia I am trying to make a downloadable file on my webpage with this <a href="http://ir-devtestsvr/4ms/media/e54d5f61-7375-405a-a6af-bb37f2447991.PNG" download>View file here</a> But when I click on the element, it just opens a page to view the f

HTML 5 a Tag doesn't download file but opens a new page

Vian Ojeda Garcia I am trying to make a downloadable file on my webpage with this <a href="http://ir-devtestsvr/4ms/media/e54d5f61-7375-405a-a6af-bb37f2447991.PNG" download>View file here</a> But when I click on the element, it just opens a page to view the f

HTML 5 a Tag doesn't download file but opens a new page

Vian Ojeda Garcia I am trying to make a downloadable file on my webpage with this <a href="http://ir-devtestsvr/4ms/media/e54d5f61-7375-405a-a6af-bb37f2447991.PNG" download>View file here</a> But when I click on the element, it just opens a page to view the f

HTML 5 a Tag doesn't download file but opens a new page

Vian Ojeda Garcia I am trying to make a downloadable file on my webpage with this <a href="http://ir-devtestsvr/4ms/media/e54d5f61-7375-405a-a6af-bb37f2447991.PNG" download>View file here</a> But when I click on the element, it just opens a page to view the f

HTML 5 a Tag doesn't download file but opens a new page

Vian Ojeda Garcia I am trying to make a downloadable file on my webpage with this <a href="http://ir-devtestsvr/4ms/media/e54d5f61-7375-405a-a6af-bb37f2447991.PNG" download>View file here</a> But when I click on the element, it just opens a page to view the f

When I run python in vscode it opens a tab in my browser

Sadman When I run python in VSCODE it opens a tab in my browser. Even I do the simplest code. For example, print("hello world"). The same happens when I run the html file. The new tab says localhost refused the connection. I solved the html problem by opening

VSCode doesn't consider tab size when formatting Dart file

Hahnemann When I select "Format Document", I want VSCode on Mac to use 4 spaces instead of 2. Here's what's in my user settings: { "editor.fontFamily": "Andale Mono", "editor.fontSize": 13, "editor.renderWhitespace": "all", "editor.tabSize": 4,

VSCode doesn't consider tab size when formatting Dart file

Hahnemann When I select "Format Document", I want VSCode on Mac to use 4 spaces instead of 2. Here's what's in my user settings: { "editor.fontFamily": "Andale Mono", "editor.fontSize": 13, "editor.renderWhitespace": "all", "editor.tabSize": 4,

VSCode doesn't consider tab size when formatting Dart file

Hahnemann When I select "Format Document", I want VSCode on Mac to use 4 spaces instead of 2. Here's what's in my user settings: { "editor.fontFamily": "Andale Mono", "editor.fontSize": 13, "editor.renderWhitespace": "all", "editor.tabSize": 4,

VSCode doesn't consider tab size when formatting Dart file

Hahnemann When I select "Format Document", I want VSCode on Mac to use 4 spaces instead of 2. Here's what's in my user settings: { "editor.fontFamily": "Andale Mono", "editor.fontSize": 13, "editor.renderWhitespace": "all", "editor.tabSize": 4,