Phantom js 不支持箭头函数 (=>)
Phantom js doesn't support Arrow function ( => )
我正在使用 Jasmine 对 Angular 应用程序进行单元测试。
在 Chrome 上一切正常,直到我开始使用 PhantomJs 进行无头浏览器测试或在控制台上测试输出。
2天后发现PhantomJs不支持lambda表达式。
单元测试没有任何问题,但 lambda 表达式和 PhantomJs 有问题。
我正在使用-
AngularJs - 1.6.6
茉莉花 - 2.9.1
PhantomJs - 2.1.1
谁能帮我解决这个问题?
提前致谢。
PhantomJs doesn't support arrow functions yet. In fact, it supports very little of ES2015. See this comment from pixiuPL (the maintainer) from this issue 在他们的仓库中:
Introducing ECMA will require nearly-complete rewrite and - keeping in m8ind I seem to be the only active dev of PJS now - will need to wait till other - more urgent - issues are solved.
In the meantime, if you feel skilled enough - feel free to start working on it, but on the separate branch.
改用函数表达式。如果要捕获 this
值,请添加 bind
。
例如
变化:
(foo, bar) => this.example(bar, foo);
到
(function (foo, bar) { return this.example(bar, foo); }).bind(this)
我正在使用 Jasmine 对 Angular 应用程序进行单元测试。 在 Chrome 上一切正常,直到我开始使用 PhantomJs 进行无头浏览器测试或在控制台上测试输出。
2天后发现PhantomJs不支持lambda表达式。 单元测试没有任何问题,但 lambda 表达式和 PhantomJs 有问题。
我正在使用-
AngularJs - 1.6.6
茉莉花 - 2.9.1
PhantomJs - 2.1.1
谁能帮我解决这个问题?
提前致谢。
PhantomJs doesn't support arrow functions yet. In fact, it supports very little of ES2015. See this comment from pixiuPL (the maintainer) from this issue 在他们的仓库中:
Introducing ECMA will require nearly-complete rewrite and - keeping in m8ind I seem to be the only active dev of PJS now - will need to wait till other - more urgent - issues are solved.
In the meantime, if you feel skilled enough - feel free to start working on it, but on the separate branch.
改用函数表达式。如果要捕获 this
值,请添加 bind
。
例如
变化:
(foo, bar) => this.example(bar, foo);
到
(function (foo, bar) { return this.example(bar, foo); }).bind(this)