测试覆盖率 前端测试覆盖率 Jscover 如何配置代理

EasilyTest · 2020年06月16日 · 1247 次阅读

😈 通过作者给出的 doc:

3.2.1Proxy Mode

In proxy mode, JSCover operates as a HTTP proxy server and instruments the specified JavaScript served through it.
3.2.1.1Translating a URI to a File Path

When operating as a proxy, it is possible to have a URI which doesn't match the file system path. This is normally not a problem, as the JavaScript contents will be saved to the file-system using the URI. However, there a two potential problems to be handled:

The URI contains characters not compatible with the file-system
If the --include-unloaded-js option has been specified, the actual file represented by the URI will not be detected as having already been included, and will appear a second time with no coverage.

An example to convert '/exclude/include/code.js' to '/include/code.js' would be: --uri-to-file-matcher=/exclude(.*) --uri-to-file-replace=$1

我们去配置了代理模式,使用默认的 127.0.0.1:3128 作为代理端口,实现本地插桩 js 的功能,但是出现了一些问题,当 js 内容有异常的时候报错了,console 提示了以下信息
SEVERE,"Semi-colon expected, sourceName: /project/mod_list.js, line: 2 lineOffset: 16",jscover.instrument.SourceProcessor,
20200615 11:23:02.335,434,SEVERE,"'}' expected, sourceName: /project/mod_list.js, line: 2 lineOffset: 16",jscover.instrument.SourceProcessor,

该如何过滤呢?有人用过 jscover 吗

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册