Angular console.log以VS Code打印测试

时间:2019-10-14 05:27:42

标签: angular visual-studio-code jasmine karma-jasmine

我正在使用Jasmine / Karma对Angular应用程序进行单元测试,并且正在使用Visual Studio Code作为IDE。

在测试中执行console.log时,无法找到输出的打印位置。

我的测试代码是:

it('verify filter changes', () => {

    let nameInput = fixture.debugElement.query(By.css('#name-input'));
    console.log(nameInput);
    nameInput.nativeElement.value = 'dummyName';
    nameInput.nativeElement.dispatchEvent(new Event('input'));
    fixture.detectChanges();
    expect(component.name).toBe('dummyName');
  });

我的karma.conf.json:

process.env.CHROME_BIN = require('puppeteer').executablePath();

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: {
      jasmine: {
        random: true,
      },
      clearContext: false, // leave Jasmine Spec Runner output visible in browser
      captureConsole: true,
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, 'coverage'),
      reports: ['html', 'lcovonly'],
      fixWebpackSourcePaths: true,
    },

    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_DEBUG,
    autoWatch: true,
    browsers: ['Chrome'],
    //browsers: ['ChromeHeadless'],
    browserConsoleLogOptions: {
      level: 'log',
      format: '%b %T: %m',
      terminal: true
    }
  });
};

在Visual Studio Code中打印console.log的输出在哪里?

0 个答案:

没有答案