使用ng-packagr生成的angular 6库。运行e2e测试的问题

时间:2018-08-23 15:17:00

标签: angular-cli ngx-bootstrap angular-cli-v6 ng-packagr

我用angular-cli v6和ng-packagr创建了一个角度库,其中包括ngx-bootstrap 3.0.1作为peerDependency 我运行该应用程序没有问题,但是如果我启动量角器,则会出现以下错误:

I/launcher - Running 1 instances of WebDriver
I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:12281/devtools/browser/e174b42c-8db0-494a-aba0-4366d555a98b
E/launcher - Error: ReferenceError: window is not defined
at Object. (\node_modules\ngx-bootstrap\bundles\webpack:ngx-bootstrap.umd\webpack\universalModuleDefinition:10:2)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at \dist\sg-ng-core-components\bundles\sg-ng-core-components.umd.js:2:268
at Object. (\dist\sg-ng-core-components\bundles\sg-ng-core-components.umd.js:5:2)

这是tsconfig.lib.ts:

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/lib",
    "target": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "types": [],
    "lib": [
      "dom",
      "es2015"
    ]
  },
  "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "flatModuleId": "AUTOGENERATED",
    "flatModuleOutFile": "AUTOGENERATED"
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

这似乎是由于ngx-bootstrap.umd引起的,但它在e2e测试之外无法正常工作。有谁知道这是由于ng-packagr,量角器还是ngx-bootstrap造成的?

0 个答案:

没有答案