Ibt*_*bti 7 javascript phantomjs
我本来希望(10000).toLocaleString('de-DE')回来,"10.000"但我得到了"10000".
有没有理由不支持这个?是否有更好的数字格式化方法?
这是一个 webkit 问题,PhantomJS 不想维持国际化……所以不幸的是,我们在一段未公开的时间里陷入了这个困境。
https://github.com/ariya/phantomjs/issues/12581
我最终做的是编写一个自定义匹配器来检查两者,因为我在 Chrome 和 PhantomJS 中运行。
jasmine.addMatchers({
isAnyOf: (util, customEqualityTesters) => {
return {
compare: (actual, expected) => {
let result = {};
for (let expect of expected) {
console.log(actual == expect);
if (expect == actual) {
result.pass = true;
return result;
}
}
result.pass = false
return result;
}
}
}
})
Run Code Online (Sandbox Code Playgroud)
然后你可以像这样使用它
expect(actual).isAnyOf(['10000', '10.000']);
Run Code Online (Sandbox Code Playgroud)