[英]Inject external javascript into html script tag for cobertura code coverage results
与此类似,我想注入html外部的js文件。
问题背景-我正在使用cobertura为Angular6应用程序生成代码覆盖率。 在我的vsts构建中,我正在发布代码覆盖率结果,但是当逐步执行文件链接时需要触发.js文件时,浏览器出现错误:
Blocked script execution in '<URL>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
我认为最好的解决方案是执行一个脚本,将javascript代码直接注入html,而不是从外部链接到html。
因此,例如说html是这样的:
<html>
<script src="code.js"></script>
...
</html>
然后运行脚本等之后injector.js
:像这样node ./injector.js
该html将变为:
<html>
<script>
function hello() {
console.log('hello');
}
</script>
</html>
你该怎么做?
还是有解决这个问题的更好方法?
由于您的开发是完全基于的NodeJS。
你可以简单地写一个剧本的NodeJS
继NPM模块不正是确实与一些优化的内联工作https://www.npmjs.com/package/vsts-coverage-styles
免责声明: 我写了上面提到的简单重复使用的NPM包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.