简介
testcafe-reporter-invision-slack是一个npm包,可以将 testcafe 的测试结果以 Slack bot 的方式发送到InVision Slack。
安装
使用 npm 安装:
npm install testcafe-reporter-invision-slack
配置
在 testcafe 的配置文件中加入如下代码,即可配置 reporter:
-- -------------------- ---- ------- ----- --------------------- - -------------------------------------------- --- --------- -- ------------------------------------- -- ----------------------------------- - -------- - ------------------------ -------------- ------------------------------------- -- ---- ----- --- ----- -------- ----------------------------------- -- --- ------- --- ---- -- ---- --- ------- ---- - ---- - -------- - --------- - -------------- - - --------- -- --- ---- -- ---- ------------- -展开代码
同时,设置环境变量 INVISION_SLACK_BOT_TOKEN
和 INVISION_SLACK_CHANNEL
:
export INVISION_SLACK_BOT_TOKEN=xoxb-xxx-xxx-xxx... export INVISION_SLACK_CHANNEL=test-results
示例代码
这里提供一段简单的示例代码:
-- -------------------- ---- ------- ------ - -------- - ---- ----------- ------- --- -------- ----- --------------------- -------- ------ ----- - -- - ----- - ------------------- ------- ----------------- ------------------------------------------------------ ---展开代码
其他注意事项
在执行测试时,需要带上 NODE_ENV=production
参数,否则不会触发 reporter:
testcafe chrome tests/example.js --env="production"
此外,在通过 testcafe-live 进行测试时,需要在 index.html
中额外引入 env 参数:
<script> window.testcafe.closeAfterTestRun = true; window.testcafe.integrationProvider .cleanSnapshot() .runTests({ selectorTimeout: 300000 }, { env: { production: true } }); </script>
结语
testcafe-reporter-invision-slack 提供了一种方便而高效的测试结果输出方式,能够帮助开发人员及时发现问题并进行修复。希望本文能够帮助大家进行相关操作,提高项目质量和交付效率。
来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/60056be981e8991b448e5a54