我正在尝试使用Windows版本的Google Chrome从WSL启动业力。
在karma.conf.js中,我仅使用Chrome浏览器:
[...],
browsers: ['Chrome'],
[...]
Run Code Online (Sandbox Code Playgroud)
然后像这样导出CHROME_BIN环境变量:
export CHROME_BIN='/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
Run Code Online (Sandbox Code Playgroud)
业力成功找到Google Chrome,并且在业力启动时在正确的URL上打开一个新标签。但是,我收到此错误:
Google chrome can't read and write to its data directory /tmp/karma-XXXX
Run Code Online (Sandbox Code Playgroud)
我尝试以管理员身份启动chrome并将缓存文件夹更改为项目的根目录,但是它不起作用。
我认为Karma提供给Chrome的路径格式存在问题(WSL路径与Windows路径)。
因此,我创建了一个自定义的因果启动程序,并指定了chromeDataDir:
browsers: ['WindowsChrome'],
customLaunchers: {
WindowsChrome: {
base: 'Chrome',
chromeDataDir: 'D:\\'
}
}
Run Code Online (Sandbox Code Playgroud)
这样,我没有上一个错误,启动了一个新的Chrome实例,但Chrome似乎无法解析URL和业力超时。此外,在我的项目中创建了很多Chrome文件夹。
是否有人已经使用Chrome在WSL中使业力起作用,或者对正在发生的事情有任何暗示?
google-chrome karma-runner karma-jasmine windows-subsystem-for-linux
我每天使用 MongoDB 聚合 API 来聚合一些数据。此聚合的结果采用以下格式:
[
{
aggDate: '2019-05-23',
results: [
{
foo: 0.58,
bar: 0.42
}, {
foo: 0.32,
bar: 0.98
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
日期上的聚合很好,但现在我想聚合results数组中的对象。
此聚合的结果应采用以下格式:
[
{
aggDate: '2019-05-23',
result: {
foo: 0.45 // avg of all the `foo`, here: (0.58 + 0.32) / 2
bar: 0.7 // avg of all the `bar`, here: (0.42 + 0.98) / 2
}
}
]
Run Code Online (Sandbox Code Playgroud)
我的问题是可以在对象中添加键foo和bar可以更改/新字段results。为了避免每次发生时重新编码查询,我想使用一些通用的方式来对 MongoDB 说
获取这个对象数组并将其缩减为单个对象,其中每个值是所有对象中相同字段的平均值。
我知道$reduceMongoDB …
我正在扩展Angular Http对象以全局处理状态代码.
如果此状态为201,则响应对象包含用于身份验证的新令牌,并且由于它不包含已订阅该请求的组件所期望的结果,因此它还包含再次发出此请求的所有内容.
基本上,我遵循这些方案(在Http扩展类中):
return request(url, options).map((res: Response) => {
if (res.status === 201) {
this._authService.updateAuth(res.token);
const newRequest = this.createNewRequest(res); // returns an Observable<Response> created with the Http.get or Http.post method
newRequest.map((res2: Response) => {
return res2; // I want res2 to replace res through the first map, but there is a scope problem
});
} else {
return res; // In non 201 case I keep the first response (res)
}
});
Run Code Online (Sandbox Code Playgroud)
问题在于,由于范围我不知道如何在第一个映射中返回res2,因此返回给订阅者的响应是它所期望的响应.
请求成功启动,服务器返回200,因此一切正常,但订阅者没有收到回复.