【问题标题】:Trying to get cypress react unit testing working within a ReactBoilerplate repo试图在 ReactBoilerplate repo 中进行 cypress react 单元测试
【发布时间】:2020-10-14 10:54:48
【问题描述】:

因此,在过去的 5 个小时左右时间里,我一直在用头撞墙,试图弄清楚如何让这一切正常工作。

然后,我复制了一个内部项目的结构和部门,并将其放入公共回购中,以尝试获得一些帮助。我知道这将是某种糟糕的配置问题,但我就是不知道在哪里。

有人可以帮我了解我需要做什么才能在 webpack typescript react 项目中进行 cypress react 单元测试吗?

https://github.com/glomotion/test-cypress-typescript-react

尝试运行时

yarn run cypress open

然后运行从 UI 显示的单个测试...

我似乎总是从 cypress: 得到某种与 webpack/typescript 相关的构建错误。

它有帮助...这里有一些来自控制台的额外调试信息,同时尝试使用额外的 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",
...

【问题讨论】:

  • 你能检查你的Node JS版本node --version
  • @AlapanDas npm: 6.14.8 & node:12.18.4

标签: reactjs typescript unit-testing cypress


【解决方案1】:

原来这只是删除 webpack mini css 加载器的问题。

【讨论】:

    猜你喜欢
    • 2021-03-11
    • 1970-01-01
    • 2021-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多