Тест проходит локально, но не выполняется в конвейере gitlab

#javascript #reactjs #jestjs #react-testing-library

#javascript #reactjs #jestjs #react-testing-library

Вопрос:

Я написал несколько тестов, которые проходят локально, но терпят неудачу в конвейере.

Вот тест:

 async displaysMachineTypeWhenOtherMachineIsSelected () {  const { asFragment } = render(  FunctionsFactory.componentFactory({ fetchedState: { machine: mockedMachineState } }),  );   // Functions is an object. It's used in other tests and they all pass  await Functions.selectMachineState1();   Functions.clickEditText();   await Functions.clickOnSelect(DetailsNames.Category);   screen.getByText('Other machine').click();   await waitFor(() =gt; {  expect(screen.getByText(DetailsLabels.MachineType)).toBeInTheDocument();  });   expect(Array.from(document.querySelectorAll('input')).length).toEqual(10);   expect(asFragment()).toMatchSnapshot(); }  it(  'should display machine type dropdown when other machine is selected',  displaysMachineTypeWhenOtherMachineIsSelected, );  

И, как я уже сказал, он проходит локально, но терпит неудачу в конвейере gitlab.

Ошибка из gitlab:

 ● States › Testing machine view › Testing behavior › should display machine type dropdown when other machine is selected  thrown: "Exceeded timeout of 5000 ms for a test.  Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."  64 | machineBehavior(sharedArgs);  65 |  gt; 66 | it(  | ^  67 | 'should display machine type dropdown when other machine is selected',  68 | displaysMachineTypeWhenOtherMachineIsSelected,  69 | );  at components/pages/states/tests/States.test.tsx:66:7  at components/pages/states/tests/States.test.tsx:62:5  at components/pages/states/tests/States.test.tsx:49:3  at Object.lt;anonymousgt; (components/pages/states/tests/States.test.tsx:25:1)  ● States › Testing machine view › Testing behavior › should return to machine view on Cancel click  expect(received).toMatchSnapshot()  Snapshot name: `States Testing machine view Testing behavior should return to machine view on Cancel click 1`  - Snapshot - 1    Received   0  @@ -782,11  782,10 @@  Layers  lt;/divgt;  lt;/divgt;  lt;div  class="ant-tabs-ink-bar ant-tabs-ink-bar-animated"  - style="left: 0px; width: 0px;"  /gt;  lt;/divgt;  lt;/divgt;  lt;div  class="ant-tabs-nav-operations ant-tabs-nav-operations-hidden"  85 |  86 | Functions.checkIfLabelsArePresent(machineLabels);  gt; 87 | expect(asFragment()).toMatchSnapshot();  | ^  88 | },  89 | };  90 | };  at Object.returnsToMachineViewOnCancelClick (components/pages/states/tests/testFunctions/machine-view/machineView.ts:87:28)  › 1 snapshot failed.  

зависимости от package.json :

 "jest": "^27.0.5", "babel-jest": "^27.0.5", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^12.0.0", "jest-cli": "^27.0.5",  

Any idea what I’m doing wrong here?