jestjs - 在 IDE 或命令行中运行 E2E 测试
问题描述
我正在使用 Stencil.js 创建一个 Web 组件库,并且我非常依赖 E2E 测试。由于它们相当慢,因此在开发新组件时运行整个测试套件(使用 Stencil.js CLI)变得越来越麻烦。
但是,我无法在我的 IDE (IntelliJ IDEA) 中或通过命令行运行单个测试。不过,它对于单元测试非常有效。
我的 Jest 配置如下所示:
module.exports = {
"roots": [
"<rootDir>/src"
],
"preset": "@stencil/core/testing"
}
当我尝试在单个文件中运行测试时 ( jest --config jest.config.js --testPathPattern src/components/button/button.e2e.ts$
)
它失败了,因为
newE2EPage() 仅在 E2E 测试中可用,并使用 --e2e cmd 行标志运行。
newE2EPage() 带有 Stencil.js,我不知道 Stencil.js 的 CLI 在后台做了什么。此外,我克隆了 Stencil.js 存储库,只是为了查看它是否与他们的 E2E 测试(https://github.com/ionic-team/stencil/tree/master/test/end-to-end)一起工作,但它也不行。
知道如何配置 Jest 以便它能够从命令行运行 Stencil.js-E2E 测试吗?
解决方案
该--e2e
标志用于 package.json 中的 npm 脚本。要开始 e2e 测试,您可以在 package.json 中添加:
"scripts": {
"test:e2e": "stencil test --e2e"
}
并运行npm run test:e2e
。对于特定文件,您可以在末尾添加它,如下所示:
npm run test:e2e src/components/button/button.e2e.ts
有关更多信息,请参阅 StencilJS 文档:https ://stenciljs.com/docs/end-to-end-testing
推荐阅读
- r - 如何取双打向量的平均值
- azure - Azure 容器定期同步
- cordova - Cordova 文件选择器允许多种 Mime 类型
- timestamp - Instagram 媒体文件名到时间戳的转换
- java - 使用包 xyz 时出现 java.lang.NoClassDefFoundError;在上面。否则工作
- visual-studio - 如何在 VSTO 解决方案上运行 Roslyn 代码分析?
- python - QML Connections 目标:参考 Connections 父级
- gcc - 在 GNU Linux 中产生很少我们的短暂延迟
- javascript - 为什么这个 SVG 异物没有在 Firefox 中显示,但它在 chrome 中?
- jenkins - jenkins 安装:无法创建临时文件