本文介绍了ember测试通过chrome,而不是phantomjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我对一个插件进行了测试,该插件传递了chrome,但在phantomjs中失败。 / p> 似乎是一个类似于。但是,我在那里尝试了解决方案,对我来说并不奏效。 代码全部在上面链接的public repo中可用。这些故障在github上发生故障的travis。任何有关如何更好地诊断和修复的想法? 编辑 - 实际错误消息 在http:// localhost:7357 / assets / test-support.js:3062 在测试(http:// localhost:7357 / assets / test-support.js:1945)在测试(http:// localhost:7357 / assets / dummy.js:2090)在http :// localhost:7357 / assets / dummy.js:2885 at http:// localhost:7357 / assets / vendor.js:150 at tryFinally(http:// localhost:7357 / assets /vendor.js:30)在http:// localhost:7357 / assets / vendor.js:156 在http:// localhost:7357 / assets / test-loader.js:29 在http:// localhost:7357 / assets / test-loader.js:21 在http:// localhost:7357 / assets / test-loader.js:40 at http: //localhost:7357/assets/test-support.js:6775:找不到变量:符号 更新 从@knownasilya提示后,我尝试强制可选的babel变换 es6.spec.symbols on:in ember-cli-build.js : module.exports = function(defaults){ var app = new EmberAddon(defaults,{ // Add options here + babel:{ + optional: 'es6.spec.symbols'] +} }); 然而 - 没有运气。它看起来像一个es6的转换问题,但是。我没有成功通过该选项吗?还有什么提示?如果您不想查看回购,我将很乐意发布代码段。 :) 更新2 包括: + includePolyfill:true 工作! 现在我来: ReferenceError:找不到变量:requestAnimationFrame 我也在寻找一个polyfill。 ..但是查看 ember-collection 的testem配置,似乎有类似的配置,我注意到phantomjs测试已关闭!现在的问题是:在phantomjs中测试 requestAnimationFrame 的最佳方法解决方案违规的罪魁祸首是找不到变量:Symbol ,这是一个ES2015(ES6)功能,这就是为什么es5垫片不适合你的。 p> 由于默认情况下,babel不包括polyfill,因此您需要强制ember-cli-babel包含polyfill。 // ember-cli-build.js const EmberApp = require('ember-cli / lib / broccoli /余烬应用内'); module.exports = function(defaults){ const app = new EmberApp(defaults,{'ember-cli-babel':{ includePolyfill:true } }); return app.toTree(); }; 有关可用选项的详细信息,请参阅 https://github.com/babel/ember-cli-babel#options 要获得更全面的解决方案,请给babel6( https:// github。 com / ember-cli / ember-cli / pull / 6828 )和目标( https://github.com/ember-cli/ember-cli/pull/6776 )尝试。 注意:polyfill包含core.js包含符号。 I have tests for an addon which pass in chrome, but fail in phantomjs.It seems to be a problem similar to this question. However, I tried the solution there and it didn't work for me.The code is all available in the public repo linked above. The failures are exhibited in the failing travis build on github. Any ideas on how to diagnose better and fix?EDIT -- actual error message Died on test #1 at http://localhost:7357/assets/test-support.js:3062 at test (http://localhost:7357/assets/test-support.js:1945) at test (http://localhost:7357/assets/dummy.js:2090) at http://localhost:7357/assets/dummy.js:2885 at http://localhost:7357/assets/vendor.js:150 at tryFinally (http://localhost:7357/assets/vendor.js:30) at http://localhost:7357/assets/vendor.js:156 at http://localhost:7357/assets/test-loader.js:29 at http://localhost:7357/assets/test-loader.js:21 at http://localhost:7357/assets/test-loader.js:40 at http://localhost:7357/assets/test-support.js:6775: Can't find variable: SymbolUPDATEFollowing up on a hint from @knownasilya, I tried forcing optional babel transform es6.spec.symbols on: in ember-cli-build.js: module.exports = function(defaults) { var app = new EmberAddon(defaults, { // Add options here+ babel: {+ optional: ['es6.spec.symbols']+ } });However -- no luck. It does look like an es6 transpilation problem, though. Did I not pass the option successfully? Any other hints? I'll be happy to post code snippets if you don't want to look in the repo. :)UPDATE 2Including as well:+ includePolyfill: trueworks!Now I'm on to: ReferenceError: Can't find variable: requestAnimationFrameI'm looking for a polyfill for this as well... but looking at the testem configuration for ember-collection, which seems to have a similar configuration, I notice that phantomjs testing is turned off! Now the question is: best way to test requestAnimationFrame in phantomjs? 解决方案 The offending culprit is Can't find variable: Symbol, which is an ES2015 (ES6) feature, which is why the es5 shim didn't work for you.Since babel doesn't include polyfills by default, you need to force ember-cli-babel to include the polyfills. // ember-cli-build.jsconst EmberApp = require('ember-cli/lib/broccoli/ember-app');module.exports = function(defaults) { const app = new EmberApp(defaults, { 'ember-cli-babel': { includePolyfill: true } }); return app.toTree();};For details of the available options, see https://github.com/babel/ember-cli-babel#optionsFor a more comprehensive solution, give babel6 (https://github.com/ember-cli/ember-cli/pull/6828) and targets (https://github.com/ember-cli/ember-cli/pull/6776) a try.Note: The polyfill includes core.js which includes Symbols. 这篇关于ember测试通过chrome,而不是phantomjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 17:06