首页 > 解决方案 > Salesforce LWC Jest 测试对 Apex 代码覆盖率的影响

问题描述

关于 Salesforce Jest 测试的问题:

1) JavaScript 代码覆盖率是否需要开玩笑测试,或者只是为了将照明网络组件转移到生产环境而需要进行测试?

2) 一旦 jest 测试编写并运行,它们是否会启动相关的流程构建器(例如,LWC 有一个提交新记录的照明编辑记录表单,并且有一个流程构建器正在寻找新的记录创建然后运行Apex 可调用方法)?如果是,是否涵盖了那些 Apex 可调用方法?

谢谢!

标签: jestjssalesforceapexlwc

解决方案


  1. Are jest test required for JavaScript code coverage or just nice-to-have in order to move lighting web components to production?

Answer: For LWC, Jest are optional, not required for Production deployments either.

  1. Once jest test are written and running, do they kick off dependent process builders (e.g. a LWC has a lighting-edit-record-form that submits a new record and there is a process builder looking for a new record creation and then runs Apex invocable methods)? If yes, are those Apex invocable methods covered?

Answer: The Jest tests might "click a button" which would invoke the apex code and if there's a DML involved, the related Process Builders will also execute. However they will not cover any of the Apex code & this also means one should not execute the Jests for Prod environments.


推荐阅读