Javascript Cypress在CI期间失败,但在本地传递
我正在为我的React应用程序编写Cypress测试 测试在我的本地计算机上通过,但在CI期间失败,并显示以下消息:Javascript Cypress在CI期间失败,但在本地传递,javascript,reactjs,cypress,e2e-testing,Javascript,Reactjs,Cypress,E2e Testing,我正在为我的React应用程序编写Cypress测试 测试在我的本地计算机上通过,但在CI期间失败,并显示以下消息: npx cypress run "--config" "baseUrl=http://localhost:12361" It looks like this is your first time using Cypress: 4.4.0 [09:13:50] Verifying Cypress can run /root/.cache/Cypress/4.4.0/Cypre
npx cypress run "--config" "baseUrl=http://localhost:12361"
It looks like this is your first time using Cypress: 4.4.0
[09:13:50] Verifying Cypress can run /root/.cache/Cypress/4.4.0/Cypress [started]
[09:13:52] Verifying Cypress can run /root/.cache/Cypress/4.4.0/Cypress [completed]
Opening Cypress...
====================================================================================================
tput: No value for $TERM and no -T specified
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 4.4.0 │
│ Browser: Electron 80 (headless) │
│ Specs: 1 found (subscription.js) │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: subscription.js (1 of 1)
Validate subscriptions screens
1) "before each" hook for "my test"
0 passing (1s)
1 failing
1) Validate subscriptions screens "before each" hook for "my test":
Uncaught ReferenceError: UIC is not defined
This error originated from your application code, not from Cypress.
When Cypress detects uncaught errors originating from your application it will automatically fail the current test.
This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.
https://on.cypress.io/uncaught-exception-from-application
Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `Validate subscriptions screens`
at eval (webpack:///external_%22UIC%22?:1:18)
at Object.@dds-uicore/all (http://localhost:12361/main.934edbcaff2f713bd900.js:907:1)
at __webpack_require__ (http://localhost:12361/main.934edbcaff2f713bd900.js:80:30)
at eval (webpack:///./src/App.js?:24:74)
at Module../src/App.js (http://localhost:12361/main.934edbcaff2f713bd900.js:221:1)
at __webpack_require__ (http://localhost:12361/main.934edbcaff2f713bd900.js:80:30)
at eval (webpack:///./src/index.js?:7:62)
at Module../src/index.js (http://localhost:12361/main.934edbcaff2f713bd900.js:336:1)
at __webpack_require__ (http://localhost:12361/main.934edbcaff2f713bd900.js:80:30)
at eval (webpack:///multi_(webpack)-dev-server/client?:5:18)
看起来有两个错误:
/// <reference types="Cypress" />
describe('E2E tests', function() {
beforeEach(() => {
cy.server();
cy.route('/subscriptions').as('getSubscriptions');
cy.visit('/', {
//needed in order to mock the 'fetch' requests
onBeforeLoad (win) {
delete win.fetch
},
});
cy.contains('Sign In').click();
});
it('my test', function() {
cy.get('table');
cy.wait('@getSubscriptions');
cy.contains('item 1');
});
});
//
描述('E2E测试',函数(){
在每个之前(()=>{
cy.server();
cy.route('/subscriptions')。as('getSubscriptions');
cy.visit(“/”{
//需要模拟“获取”请求
加载前加载(win){
删除win.fetch
},
});
cy.contains('登录')。单击();
});
它('我的测试',函数(){
cy.get(‘表’);
cy.wait(“@getSubscriptions”);
cy.contains(“第1项”);
});
});
请帮忙。
谢谢 请添加一些代码以了解更多详细信息可能无法从您共享的内容中判断问题所在。正如@nmDat所说,请分享一些代码。如果你不愿意为处理这个问题提供一些建议。如果在Docker映像中构建CI,请在本地打开Docker映像并进行调试。如果可能,请使用Cypress docker图像。还要检查泄漏状态和并发操作,根据我的经验,通常是这样的,特别是如果与Cucumber或类似的BDD框架一起使用,并且还需要与开发人员一起检查此错误
未捕获引用错误:UIC未定义
,因为源于应用程序的错误
谢谢@evgenibazhanov,问题出在测试的应用程序上。