0

我正在为我的项目安装业力,我做了以下事情,但是当我运行“npm run test-karma”时,我得到了以下错误,

“您需要包含一些实现karma .start 方法的适配器!”

包.json,

       "jasmine": "^3.3.1",
       "jasmine-core": "^3.1.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~4.0.0",
        "karma-chrome-launcher": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~2.0.1",
       "karma-jasmine": "~1.1.2",

Karma.conf.js,

const { join } = require('path');
const { constants } = require('karma');

module.exports = () => {
 return {
  basePath: '',
  frameworks: ['jasmine', '@angular-devkit/build-angular'],
  plugins: [
  require('karma-jasmine'),
  require('karma-spec-reporter'),
  require('karma-chrome-launcher'),
  require('karma-jasmine-html-reporter'),
  require('karma-mocha-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: {
  reports: ['json-summary', 'html', 'lcovonly', 'text-summary'],
  fixWebpackSourcePaths: true,
  thresholds: {
    emitWarning: false,
    global: {
      statements: 100,
      lines: 100,
      branches: 100,
      functions: 100
    }
  }
},
// reporters: ['mocha', 'spec', 'progress', 'kjhtml'],
reporters: ['mocha', 'kjhtml'],
mochaReporter: {

  colors: {
     success: 'green',
     info: 'bgGreen',
     warning: 'cyan',
     error: 'red'
  },
   symbols: {
    success: '',
    info: 'ℹ️',
    warning: '☣️',
    error: '❌'
  }
},
   port: 9876,
  colors: true,
 autoWatch: true,
 browsers: ['Chrome'],
customLaunchers: {
  Chrome_without_security: {
    base: 'Chrome',
    flags: [
      '--no-sandbox',
      '--disable-setuid-sandbox',
      '--disable-gpu',
      '--remote-debugging-port=9222'
    ]
  }
},
singleRun: true
};
};

测试.ts,

import 'core-js';
import 'rxjs/Rx';
import 'zone.js/dist/zone';
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/proxy';
import 'zone.js/dist/jasmine-patch';
import { TestBed } from '@angular/core/testing';

import {
   BrowserDynamicTestingModule,
   platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';

declare const require: any;

TestBed.initTestEnvironment(
  BrowserDynamicTestingModule,

 platformBrowserDynamicTesting()
  );

const testsContext: any = require.context('./', true, /\.spec/);

testsContext.keys().forEach(testsContext);

我是新来的。

4

0 回答 0