首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用TestCafe直接将vite服务应用程序运行到: error,给出代理错误

使用TestCafe直接将vite服务应用程序运行到: error,给出代理错误
EN

Stack Overflow用户
提问于 2022-08-24 14:38:19
回答 1查看 91关注 0票数 0

我正在将我们的前端从create-react-app转换到vite,我突然注意到,基于某种奇怪的原因,vite的developmentpreview构建并不能与Test咖啡馆协同工作。

我得到的确切错误是:

代码语言:javascript
复制
 yarn testcafe .\src\tests\main\desktop\helppagina.test.ts
 Running tests in:
 - Chrome 104.0.5112.102 / Windows 10

 My Fixture
 × My Test

   1) undefinedFailed to load the page at "http://localhost:3000/gms/app/help".
      Increase the value of the "pageRequestTimeout" variable, enable the "retryTestPages" option, or use quarantine mode to perform additional attempts to execute this test.
      You can find troubleshooting information for this issue at "https://go.devexpress.com/TestCafe_FAQ_ARequestHasFailed.aspx".

      Error details:
      Failed to find a DNS-record for the resource at "http://localhost:3000/gms/app/help".

      Browser: Chrome 104.0.5112.102 / Windows 10

  // 4 more snipped for length

 5/5 failed (50s)

 Warnings (1):
 --
  Was unable to take a screenshot due to an error.

  Error: WebSocket is not open: readyState 3 (CLOSED)
      at sendAfterClose (C:\Users\j.claassens\Documents\workspace\wlis\gms\mmi-end-to-end-test\node_modules\ws\lib\websocket.js:979:17)
      at WebSocket.send (C:\Users\j.claassens\Documents\workspace\wlis\gms\mmi-end-to-end-test\node_modules\ws\lib\websocket.js:405:7)
      at Chrome._enqueueCommand (C:\Users\j.claassens\Documents\workspace\wlis\gms\mmi-end-to-end-test\node_modules\chrome-remote-interface\lib\chrome.js:286:18)
      at C:\Users\j.claassens\Documents\workspace\wlis\gms\mmi-end-to-end-test\node_modules\chrome-remote-interface\lib\chrome.js:88:22
      at new Promise (<anonymous>)
      at Chrome.send (C:\Users\j.claassens\Documents\workspace\wlis\gms\mmi-end-to-end-test\node_modules\chrome-remote-interface\lib\chrome.js:87:20)
      at Object.handler [as captureScreenshot] (C:\Users\j.claassens\Documents\workspace\wlis\gms\mmi-end-to-end-test\node_modules\chrome-remote-interface\lib\api.js:32:23)
      at BrowserClient.getScreenshotData (C:\Users\j.claassens\Documents\workspace\wlis\gms\mmi-end-to-end-test\node_modules\testcafe\src\browser\provider\built-in\dedicated\chrome\cdp-client\index.ts:312:50)
      at BrowserProviderPluginHost.takeScreenshot (C:\Users\j.claassens\Documents\workspace\wlis\gms\mmi-end-to-end-test\node_modules\testcafe\src\browser\provider\built-in\dedicated\base.js:87:32)
      at BrowserProvider.takeScreenshot (C:\Users\j.claassens\Documents\workspace\wlis\gms\mmi-end-to-end-test\node_modules\testcafe\src\browser\provider\index.ts:409:13)

我的Vite dev服务器正在运行,因为http://localhost:3000/gms

  • My http://localhost:<port_from_testcafe>/<some_random_id_from_testcafe>/

  • Google 104.0.5112.102 (Official Build) (64-bit) (cohort: Stable)

  • This服务器是在Test咖啡馆发布的http://localhost:<port_from_testcafe>/<some_random_id_from_testcafe>/

  • Google Chrome版本上启动的:104.0.5112.102 (Official Build) (64-bit) (cohort: Stable)

  • This问题也发生在为TestCafe配置的firefoxedge上,而create-react-app.

没有发生这种情况

我有更多关于这个gist的信息(两个项目的Package.json,文件/文件夹截图以及testcaferc和vite配置文件):https://gist.github.com/favna/38c0358a9827da176d4ccf02cfffe502

EN

回答 1

Stack Overflow用户

发布于 2022-08-24 15:13:34

解决方案是将server.host设置为vite.config.ts中的true,而不是以前的'localhost'值。

我不知道为什么考虑到TestCafe也会使用'localhost'来解决这个问题,但是不管是什么原因,解决这个问题的目标已经实现了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73475104

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档