reactjs - 试图在 ReactBoilerplate repo 中进行 cypress react 单元测试
问题描述
所以在过去的 5 个小时左右,我一直把头撞在墙上,试图弄清楚如何让这一切正常工作。
然后,我复制了一个内部项目的结构和部门,并将其制成公共回购,以尝试获得一些帮助。我知道这将是某种糟糕的配置问题,但我就是不知道在哪里。
有人可以帮我理解我需要做什么才能在 webpack typescript react 项目中进行 cypress react 单元测试吗?
https://github.com/glomotion/test-cypress-typescript-react
尝试运行时
yarn run cypress open
然后运行从 UI 显示的单个测试...
我似乎总是从 cypress 得到某种与 webpack/typescript 相关的构建错误:
incasse 它有帮助...这里有一些来自控制台的额外调试信息,同时尝试使用额外的 webpack 调试信息运行:
cypress:webpack stats had error(s) +8s
cypress:webpack errored bundling /Users/timpaul/Library/Application Support/Cypress/cy/production/projects/test-cypress-typescript-react-ffdf18db96b66e8934f9c769081501f9/bundles/src/components/vertical-space/vertical-space.cypress.test.tsx.js Webpack Compilation Error
./src/components/vertical-space/vertical-space.cypress.test.tsx
Module build failed (from ./node_modules/ts-loader/index.js):
Error: TypeScript emitted no output for /Users/timpaul/Desktop/GIT-Repos/test-cypress-typescript-react/src/components/vertical-space/vertical-space.cypress.test.tsx. +8ms
cypress:webpack - compile finished for /Users/timpaul/Desktop/GIT-Repos/test-cypress-typescript-react/src/components/vertical-space/vertical-space.cypress.test.tsx, initial? true +93ms
Webpack Compilation Error
./src/components/vertical-space/vertical-space.cypress.test.tsx
Module build failed (from ./node_modules/ts-loader/index.js):
Error: TypeScript emitted no output for /Users/timpaul/Desktop/GIT-Repos/test-cypress-typescript-react/src/components/vertical-space/vertical-space.cypress.test.tsx.
GET /__cypress/tests?p=src/components/vertical-space/vertical-space.cypress.test.tsx 200 8680.292 ms - 431
cypress:webpack finished bundling /Users/timpaul/Library/Application Support/Cypress/cy/production/projects/test-cypress-typescript-react-ffdf18db96b66e8934f9c769081501f9/bundles/cypress/support/index.js +432ms
cypress:webpack - compile finished for /Users/timpaul/Desktop/GIT-Repos/test-cypress-typescript-react/cypress/support/index.js, initial? true +7ms
包依赖版本:
// package.json:
...
"engines": {
"npm": ">=6.14.8",
"node": ">=12.18.4"
},
...
"cypress-react-unit-test": "^4.16.0",
"@cypress/webpack-preprocessor": "^5.4.7",
"cypress": "^5.3.0",
"typescript": "^4.0.3",
"webpack": "^4.44.2",
...
解决方案
原来这只是删除 webpack mini css 加载器的问题。
推荐阅读
- r - 在 Sparklyr 中日期偏移一天?
- javascript - 为什么我可以将 JS/Jquery 函数应用于特定于按钮的 ID,但不能链接到他的类?
- sql-server - 如何授予 MSSQL$SQL2016 写入文件夹的权限
- asp.net-mvc - 从剃须刀发布多阵列
- travis-ci - Travis-Ci 不导入实用程序
- angular - 如何创建一个只有 typescript 模型类的 npm 库?
- kubernetes - Kubernetes中具有ClusterIP服务类型的外部IP地址有什么用
- docker - Docker 信任:无法将信任轮换到新的受信任根:无法使用当前受信任的证书验证数据
- java - BeanCreationException:由 ClassNotFoundException 引起的 NoClassDefFoundError 创建名称为“entityManagerFactory”的 bean 时出错
- reactjs - 是否有可能将状态/道具值从一个组件传递到另一个组件