Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 这个angular2单元测试设置有什么错误?_Unit Testing_Angular_Angular2 Directives_Angular2 Testing - Fatal编程技术网

Unit testing 这个angular2单元测试设置有什么错误?

Unit testing 这个angular2单元测试设置有什么错误?,unit-testing,angular,angular2-directives,angular2-testing,Unit Testing,Angular,Angular2 Directives,Angular2 Testing,我的应用程序运行良好,但单元测试不起作用。 ** 帮我解决我的问题 遵循angular2单元测试的正确程序是什么, 提前谢谢 package.json { “名称”:“角度快速启动”, “版本”:“1.0.0”, “说明”:“来自文档的QuickStart package.json,并辅以测试支持”, “脚本”:{ “开始”:“tsc&&并发\”tsc-w \“lite服务器\”, “docker构建”:“docker构建-t ng2快速启动”, “docker”:“npm运行docke

我的应用程序运行良好,但单元测试不起作用。

**

帮我解决我的问题 遵循angular2单元测试的正确程序是什么, 提前谢谢

  • package.json
{
“名称”:“角度快速启动”,
“版本”:“1.0.0”,
“说明”:“来自文档的QuickStart package.json,并辅以测试支持”,
“脚本”:{
“开始”:“tsc&&并发\”tsc-w \“lite服务器\”,
“docker构建”:“docker构建-t ng2快速启动”,
“docker”:“npm运行docker构建和运行docker-it--rm-p 3000:3000-p 3001:3001 ng2快速启动”,
“pree2e”:“npm运行webdriver:更新”,
“e2e:“tsc&&并发\”http服务器-s \“\”量角器-量角器.config.js \”-杀死其他人--先成功”,
“lint”:“tslint./app/***.ts-t详细”,
“lite”:“lite服务器”,
“postinstall”:“typings安装”,
“测试”:“tsc&&并发\”tsc-w \“karma start karma.conf.js \”,
“测试一次”:“tsc&&karma启动karma.conf.js——单次运行”,
“tsc”:“tsc”,
“tsc:w”:“tsc-w”,
“打字”:“打字”,
“webdriver:更新”:“webdriver管理器更新”
},
“关键词”:[],
“作者”:“KOC”,
“许可证”:“ISC”,
“依赖项”:{
“@angular/common”:“2.0.0”,
“@angular/compiler”:“2.0.0”,
“@angular/core”:“2.0.0”,
“@angular/forms”:“2.0.0”,
“@angular/http”:“2.0.0”,
“@angular/platform浏览器”:“2.0.0”,
“@angular/platform browser dynamic”:“2.0.0”,
“@angular/router”:“3.0.0”,
“@angular/upgrade”:“2.0.0”,
“角度-2-本地存储”:“0.0.19”,
“角度内存web api”:“~0.1.0”,
“angular2谷歌地图”:“^0.15.0”,
“angular2海图”:“^0.3.4”,
“angular2记录器”:“^0.5.0”,
“引导”:“^3.3.6”,
“核心js”:“^2.4.1”,
“ng2模式”:“0.0.21”,
“ng2分页”:“^0.5.1”,
“反映元数据”:“^0.1.3”,
“rxjs”:“5.0.0-beta.12”,
“systemjs”:“0.19.38”,
“zone.js”:“^0.6.23”
},
“依赖性”:{
“同时”:“^2.2.0”,
“精简服务器”:“^2.2.2”,
“类型脚本”:“^2.0.3”,
“打字”:“^1.4.0”,
“规范路径”:“0.0.2”,
“http服务器”:“^0.9.0”,
“tslint”:“^3.15.1”,
“lodash”:“^4.16.1”,
“茉莉花芯”:“~2.5.2”,
“因果报应”:“^1.3.0”,
“karma chrome启动器”:“^2.0.0”,
“karma cli”:“^1.0.1”,
“karma htmlfile reporter”:“^0.3.4”,
“因果报应茉莉”:“^1.0.2”,
“karma jasmine html reporter”:“^0.2.2”,
“量角器”:“^3.3.0”,
“rimraf”:“^2.5.2”,
@types/core js:“^0.9.34”
},
“存储库”:{},
“main”:“karma test shim.js”
}
**

  • karma.conf.js
**

**

  • systemjs.config.js
**

/**
*角度采样的系统配置
*根据应用程序需要进行必要的调整。
*/
(职能(全球){
System.config({
路径:{
//路径用作别名
'npm:':'node_modules/'
},
//地图告诉系统加载器在哪里查找东西
地图:{
//我们的应用程序位于应用程序文件夹中
应用程序:“应用程序”,
//角束
“@angular/core”:“npm:@angular/core/bundles/core.umd.js”,
“@angular/common”:“npm:@angular/common/bundles/common.umd.js”,
“@angular/compiler”:“npm:@angular/compiler/bundles/compiler.umd.js”,
“@angular/platform browser”:“npm:@angular/platform browser/bundles/platform browser.umd.js”,
“@angular/platform browser dynamic”:“npm:@angular/platform browser dynamic/bundles/platform browser dynamic.umd.js”,
“@angular/http”:“npm:@angular/http/bundles/http.umd.js”,
“@angular/router”:“npm:@angular/router/bundles/router.umd.js”,
“@angular/forms”:“npm:@angular/forms/bundles/forms.umd.js”,
“@angular/upgrade”:“npm:@angular/upgrade/bundles/upgrade.umd.js”,
//其他图书馆
'rxjs':'npm:rxjs',
“angular2谷歌地图/core”:“npm:angular2谷歌地图/core/core.umd.js”,
“角度内存web api”:“npm:角度内存web api”,
“angular2海图”:“npm:angular2海图”,
'highcharts/highstock.src':'npm:highcharts/highstock.js',
“highcharts/highcharts-3d”:“npm:highcharts/highcharts-3d.js”,
“highcharts”:“npm:highcharts”,
“HighchartExporting”:“npm:highcharts/modules/exporting.js”,
“HighchartCSVExporting”:“npm:highcharts/modules/export csv.js”,
'angular-2-local-storage':'npm:angular-2-local-storage',
‘angular2记录器’:‘npm:angular2记录器’,
“ng2分页”:“npm:ng2分页”,
“ng2模式”:“节点模块/ng2模式”,
//‘angular2模态’:‘npm:angular2模态’,
//“angular2模态/插件/引导”:“npm:angular2模态/插件/引导”
},
//包告诉系统加载程序在没有文件名和/或扩展名时如何加载
套餐:{
应用程序:{
main:“./main.js”,
defaultExtension:'js'
},
rxjs:{
defaultExtension:'js'
},
“内存中的角度web api”:{
main:“./index.js”,
defaultExtension:'js'
},
“angular2海图”:{
主要:"索引",,
格式:“cjs”,
defaultExtension:'js'
},
“海图”:{
defaultExtension:'js',
格式:“cjs”
},
“HighChart导出”:{
defaultExtension:'js',
格式:“cjs”
},
“HighchartCSVExporting”:{
defaultExtension:'js',
格式:“cjs”
},
'angular-2-local-storage':{main:'dist/index。
// #docregion
module.exports = function(config) {

  var appBase    = 'app/';       // transpiled app JS and map files
  var appSrcBase = 'app/';       // app source TS files
  var appAssets  = 'base/app/'; // component assets fetched by Angular's compiler

  var testBase    = 'testing/';       // transpiled test JS and map files
  var testSrcBase = 'testing/';       // test source TS files

  config.set({
    basePath: '',
    frameworks: ['jasmine'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'), // click "Debug" in browser to see it
      require('karma-htmlfile-reporter') // crashing w/ strange socket error
    ],

    customLaunchers: {
      // From the CLI. Not used here but interesting
      // chrome setup for travis CI using chromium
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },
    files: [
      // System.js for module loading
      'node_modules/systemjs/dist/system.src.js',

      // Polyfills
      'node_modules/core-js/client/shim.js',
      'node_modules/reflect-metadata/Reflect.js',

      // zone.js
      'node_modules/zone.js/dist/zone.js',
      'node_modules/zone.js/dist/long-stack-trace-zone.js',
      'node_modules/zone.js/dist/proxy.js',
      'node_modules/zone.js/dist/sync-test.js',
      'node_modules/zone.js/dist/jasmine-patch.js',
      'node_modules/zone.js/dist/async-test.js',
      'node_modules/zone.js/dist/fake-async-test.js',

      // RxJs
      { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },

      // Paths loaded via module imports:
      // Angular itself
      {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
      {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},

      {pattern: 'systemjs.config.js', included: false, watched: false},
      {pattern: 'systemjs.config.extras.js', included: false, watched: false},
      'karma-test-shim.js',

      // transpiled application & spec code paths loaded via module imports
      {pattern: appBase + '**/*.js', included: false, watched: true},
      {pattern: testBase + '**/*.js', included: false, watched: true},


      // Asset (HTML & CSS) paths loaded via Angular's component compiler
      // (these paths need to be rewritten, see proxies section)
      {pattern: appBase + '**/*.html', included: false, watched: true},
      {pattern: appBase + '**/*.css', included: false, watched: true},

      // Paths for debugging with source maps in dev tools
      {pattern: appSrcBase + '**/*.ts', included: false, watched: false},
      {pattern: appBase + '**/*.js.map', included: false, watched: false},
      {pattern: testSrcBase + '**/*.ts', included: false, watched: false},
      {pattern: testBase + '**/*.js.map', included: false, watched: false}
    ],

    // Proxied base paths for loading assets
    proxies: {
      // required for component assets fetched by Angular's compiler
      "/app/": appAssets
    },

    exclude: [],
    preprocessors: {},
    // disabled HtmlReporter; suddenly crashing w/ strange socket error
    reporters: ['progress', 'kjhtml'],//'html'],

    // HtmlReporter configuration
    htmlReporter: {
      // Open this file to see results in browser
      outputFile: '_test-output/tests.html',

      // Optional
      pageTitle: 'Unit Tests',
      subPageTitle: __dirname
    },

    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  })
}