Skip to main content

JSCoverageOptions 接口

🌐 JSCoverageOptions interface

JS 覆盖率的一组可配置选项。

🌐 Set of configurable options for JS coverage.

语法​

🌐 Signature

export interface JSCoverageOptions

属性​

🌐 Properties

属性

🌐 Property

修饰符

🌐 Modifiers

类型

🌐 Type

描述

🌐 Description

默认

🌐 Default

includeRawScriptCoverage

optional

boolean

结果是否包含原始 V8 脚本覆盖条目。

🌐 Whether the result includes raw V8 script coverage entries.

reportAnonymousScripts

optional

boolean

是否应报告页面生成的匿名脚本。

🌐 Whether anonymous scripts generated by the page should be reported.

resetOnNavigation

optional

boolean

是否重置每次导航的覆盖范围。

🌐 Whether to reset coverage on every navigation.

将此设置为 false 并不能保证覆盖率在导航时得以保留。Chrome 在导航时可能会丢弃前一个页面的 JavaScript 执行环境,包括它的覆盖率数据。为了保留覆盖率,请在导航前调用 Coverage.stopJSCoverage(),然后为下一页开始新的收集并合并报告。

🌐 Setting this to false does not guarantee that coverage survives a navigation. Chrome may discard the previous page's JavaScript execution environment, including its coverage data, when navigating. To preserve coverage, call Coverage.stopJSCoverage() before navigating away, then start a new collection for the next page and merge the reports.

useBlockCoverage

optional

boolean

是否在块级收集覆盖信息。如果为真,则在块级收集覆盖信息(这是默认设置)。如果为假,则在函数级收集覆盖信息。

🌐 Whether to collect coverage information at the block level. If true, coverage will be collected at the block level (this is the default). If false, coverage will be collected at the function level.