protractor - protractor + angular 6 库抛出错误:ReferenceError:未定义窗口
问题描述
我可以问你为什么我的应用程序可以与 ng serve 和 ng build 一起使用,但是如果我运行量角器,我的 e2e 测试会失败并显示此消息?
[16:35:07] I/launcher - Running 1 instances of WebDriver
[16:35:07] I/direct - Using ChromeDriver directly...
[16:35:13] E/launcher - Error: ReferenceError: window is not defined
at Object.<anonymous> (\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.<anonymous> (\dist\sg-ng-core-components\bundles\sg-ng-core-components.umd.js:5:2)
遵循 tsconfig.e2e
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es2017",
"types": [
"jasmine",
"node"
]
}
}
这是我的 tsconfig.app
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": [
"node"
]
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
解决方案
推荐阅读
- python - 用python3读取txt文件
- reactjs - React 使用 RouteComponentProps - 类型“{}”缺少“只读”类型的以下属性
我正在使用带有 Typescript 的 React,并且需要使用历史记录,因为我需要有 RouteComponentProps 接口
export default class Routes extends Component<RouteComponentProps, a
- python - Python Pyinstaller没有生成exe文件
- android - Recyclerview 在 AppBarLayout 中不可见
- python - 我使用pymysql在MySQL中执行查询,但是为什么关闭连接后进程仍然存在?
- c# - 从基方法调用派生方法的主体
- json - ERROR 错误:未捕获(承诺中):SyntaxError:JSON 中位置 0 处的意外标记 u
- javascript - VueJS 从 axios 承诺中获得价值
- python - 有没有办法在检测屏幕上显示检测到的物体数量?
- android - TextToSpeech API 中的 speak 方法是否将数据发送到 Google 服务器?