简体   繁体   English

运行`ng test`时,浏览器输出中没有显示的Jasmine测试列表

[英]List of Jasmine tests not showing in browser output when running `ng test`

I inherited an Angular app that was first worked on a couple of years ago. 我继承了几年前首次使用的Angular应用程序。 One of the tasks I've been given is to get our testing going - as tests haven't been run over the last year or more. 我给出的任务之一就是让我们的测试继续进行 - 因为过去一年或更长时间没有进行过测试。 This was originally an Angular 2 app, and has been updated to be around 2.3.1. 这最初是一个Angular 2应用程序,并已更新为大约2.3.1。 At the moment we can't do a further update because it would involve substantial refactoring that we need to tackle at a later time. 目前我们无法进行进一步的更新,因为它将涉及我们需要在以后解决的大量重构。

Here's the issue, when I run ng test it does generate some initial tests. 这是问题,当我运行ng test它会生成一些初始测试。 However, when the browser window opens, while I see the Karma details, showing Karma v1.20 - connected (see pic), I don't see any of the listing of actual files that are failing or passing via Jasmine. 但是,当浏览器窗口打开时,我看到Karma详细信息,显示Karma v1.20 - connected (参见图片),我没有看到任何失败或通过Jasmine传递的实际文件列表。

在此输入图像描述

It's like the Jasmine portion has been disabled. 这就像Jasmine部分被禁用了。 Or hidden from showing here? 或隐藏在这里展示? Not sure. 不确定。 This is what I would expect to see (screenshot from another app's test results): 这是我期望看到的(从另一个应用程序的测试结果截图):

在此输入图像描述

FYI, in the command line I see the tests have run (all are passing): 仅供参考,在命令行中我看到测试已经运行(所有测试都已通过):

04 04 2019 13:14:48.834:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
04 04 2019 13:14:48.836:INFO [launcher]: Launching browser Chrome with unlimited concurrency
04 04 2019 13:14:48.851:INFO [launcher]: Starting browser Chrome
04 04 2019 13:15:15.529:WARN [karma]: No captured browser, open http://localhost:9876/    
Chrome 73.0.3683 (Mac OS X 10.14.4): Executed 5 of 5 SUCCESS (0.199 secs / 0.188 secs)

I have searched through various files, but so far have been unable to find a portion of Jasmine code that's been disabled or commented-out. 我搜索了各种文件,但到目前为止一直无法找到已被禁用或注释掉的Jasmine代码的一部分。 So how can I go about finding how to re-enable the Jasmine printout as part of my test run? 那么我怎样才能找到如何重新启用Jasmine打印输出作为我的测试运行的一部分? Can I uninstall and reinstall just a testing package? 我可以卸载并重新安装一个测试包吗? What's recommended in a situation like this? 在这种情况下推荐什么?

I'm also wondering if it could be a problem with my karma.conf.js file. 我也想知道我的karma.conf.js文件是否有问题。 This is what mine looks like: 这就是我的样子:

// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

    module.exports = function (config) {
      config.set({
        basePath: '',
        frameworks: ['jasmine', '@angular/cli'],
        plugins: [
          require('karma-jasmine'),
          require('karma-chrome-launcher'),
          require('karma-jasmine-html-reporter'),
          require('karma-remap-istanbul'),
          require('@angular/cli/plugins/karma')
        ],
        files: [
          { pattern: './src/test.ts', watched: false }
        ],
        preprocessors: {
          './src/test.ts': ['@angular/cli']
        },
        mime: {
          'text/x-typescript': ['ts','tsx']
        },
        remapIstanbulReporter: {
          reports: {
            html: 'coverage',
            lcovonly: './coverage/coverage.lcov'
          }
        },
        angularCli: {
          config: './angular-cli.json',
          environment: 'dev'
        },
        reporters: config.angularCli && config.angularCli.codeCoverage
                  ? ['progress', 'karma-remap-istanbul']
                  : ['progress'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['Chrome'],
        singleRun: false
      });
    };

try to add the following lines to the karma.conf.js 尝试karma.conf.js添加到karma.conf.js

client: {
    clearContext: false
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jasmine Test Explorer 在 VS Code 中显示了 typescript jasmine 测试 - Jasmine Test Explorer is showing typescript jasmine tests in VS Code ng测试关闭茉莉花 - ng test close jasmine Angular cli 显示错误“发生未处理的异常:没有项目支持‘测试’目标。” 运行 ng test 或 ng serve 命令时 - Angular cli showing error "An unhandled exception occurred: No projects support the 'test' target." when running ng test or ng serve command 使用 Jasmine 弹珠运行测试时未执行 NGRX 效果 - NGRX effect not executing when running tests using Jasmine marbles 运行茉莉花测试时无法查看kjhtml报告 - unable to see kjhtml report when running jasmine tests 对Angular 2组件(angular2-seed)运行Jasmine测试时出错 - Error when running Jasmine tests for Angular 2 Component (angular2-seed) “语法错误:无效或意外的令牌在<Jasmine> &quot; 运行 Angular 测试时 - "SyntaxError: Invalid or unexpected token at <Jasmine>" when running Angular tests Angular 7:ng 测试挂起,不断重复运行测试 - Angular 7 : ng test hangs , keeps running tests repeatedly NG 测试中的调试测试 - Debug Tests in NG Test 错误:运行ng测试时出现StaticInjectorError [FormBuilder] - Error: StaticInjectorError[FormBuilder] when running ng test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM