我正在使用摩卡,chai和sinon测试我的Chrome扩展。当我尝试从存根方法的对象,我得到:Chrome扩展单元测试与Sinon一起抛出'unsafe-eval'
EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:".
at createProxy (js/lib/sinon.js:2488:86)
at Function.create (js/lib/sinon.js:2549:29)
at Function.create (js/lib/sinon.js:3337:42)
at Object.stub (js/lib/sinon.js:3289:32)
at Context.<anonymous> (js/spec/sf-companion.spec.js:44:19)
at Test.Runnable.run (js/lib/mocha.js:4529:15)
at Runner.runTest (js/lib/mocha.js:4974:10)
at js/lib/mocha.js:5057:12
at next (js/lib/mocha.js:4899:14)
at js/lib/mocha.js:4909:7
test-runner.html
:
任何帮助,将不胜感激。提前致谢。
'chrome-extension:// hjkmpahjllmdacbcennobnfcagfdaife/test/test-runner.html'是一个本地链接到PC上的文件。 –
@TomBurris是的,它是。我如何允许这个URL?如果我打包,我会有不同的扩展ID相同的网址。 – pvnarula
我建议复制'test-runner.html'的内容并将其上传到http://www.pastebin.com或类似网站,然后在此处共享该链接。 –