首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不包括karma.js中的带有幻影和angular2的文件夹

不包括karma.js中的带有幻影和angular2的文件夹
EN

Stack Overflow用户
提问于 2017-03-14 11:32:22
回答 1查看 646关注 0票数 0

当我试图用幻影运行业力测试时,如果我有另一个node_modules的例子的话,我就有问题了。

例如:

代码语言:javascript
复制
MyComponent
└── node_modules
└── examples
    └── node_modules
    └── src
        └── app
            └── app.component.ts
            └── app.component.html
            └── app.component.css
            └── app.component.spec
            └── app.module.ts
        └── assets
        └── index.html
        └── angular-cli.json
        └── karma.conf.js
        └── package.json
└── src
    └── app
        └── my.component.ts
        └── my.component.html
        └── my.component.css
        └── my.component.spec.ts
    └── assets
    └── base.spec.ts
    └── karma.conf.js
    └── package.json

package.json

代码语言:javascript
复制
  "dependencies": {
    "@angular/common": "2.4.9",
    "@angular/compiler": "2.4.9",
    "@angular/core": "2.4.9",
    "@angular/http": "2.4.9",
    "@angular/platform-browser": "2.4.9",
    "@angular/platform-browser-dynamic": "2.4.9",
    "@angular/router": "3.4.9",
    "@types/core-js": "0.9.36",
    "@types/echarts": "0.0.5",
    "angular-in-memory-web-api": "0.3.1",
    "core-js": "2.4.1",
    "echarts": "3.4.0",
    "rxjs": "5.0.1",
    "systemjs": "0.19.40",
    "zone.js": "0.7.4"
  },
  "devDependencies": {
    "@types/jasmine": "2.5.44",
    "@types/node": "6.0.65",
    "typescript": "2.2.1",
    "jasmine-core": "2.5.2",
    "karma": "1.5.0",
    "karma-chrome-launcher": "2.0.0",
    "karma-jasmine": "1.1.0",
    "karma-typescript": "3.0.0-beta.1",
    "karma-typescript-angular2-transform": "1.0.0-beta.5",
    "karma-phantomjs-launcher": "1.0.4"
  }

karma.conf.js

代码语言:javascript
复制
module.exports = function(config) {
    config.set({

        frameworks: ["jasmine", "karma-typescript"],

        files: [
            { pattern: "base.spec.ts" },
            { pattern: "src/app/**/*.+(ts|html)" }
        ],

        exclude: [
            'examples/**/*.js',
            'examples/**/*.ts'
        ],

        preprocessors: {
            "**/*.ts": ["karma-typescript"]
        },

        karmaTypescriptConfig: {
            bundlerOptions: {
                entrypoints: /\.spec\.ts$/,
                transforms: [
                    require("karma-typescript-angular2-transform")
                ]
            },
            coverageOptions: {
                instrumentation: true
            }
        },

        reporters: ["progress", "karma-typescript"],

        browsers: ["Chrome"]
    });
};

当我在没有示例文件夹的情况下运行测试时,一切都正常,但是如果我尝试使用内部的示例来运行测试,而忽略它,它就无法工作。

我得到了下一个错误:

14 03 2017 11:15:07.881:错误因果报应:(/workspace/node_modules/typescript/lib/typescript.js:25122:46):TypeError:无法读取未定义的属性“名称”在/workspace/node_modules/typescript/lib/typescript.js:25146:21 at Map.forEach at mergeSymbol Map.forEach(原生)

EN

回答 1

Stack Overflow用户

发布于 2017-03-14 11:39:58

我发现你错了。

我必须排除预处理器配置中的文件夹:

代码语言:javascript
复制
     `karmaTypescriptConfig: {             bundlerOptions: {                 entrypoints: /\.spec\.ts$/,                 transforms: [                     require("karma-typescript-angular2-transform")                 ]             },             coverageOptions: {                 instrumentation: true             },             exclude: ['examples']         },`
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42784849

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档