Cypress потерпел неудачу во время CI, но прошел локально - PullRequest
1 голос
/ 19 апреля 2020

Я пишу тесты Cypress в свое приложение React.

Тесты, пройденные на моем локальном компьютере, но не выполненные во время 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/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)

Похоже, что есть 2 ошибки:

  1. tput: не указано значение для $ TERM и не указано -T
  2. Проверять экраны подписок "перед каждым" хуком для "моего теста": Uncaught ReferenceError: UI C не определено.

Тест Cypress:

/// <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');
    });
});

Помогите пожалуйста. Спасибо!

...