Skip to content

Commit 825be62

Browse files
authored
Fix flaky test (#1192)
* Wait for view to be actionable in test. * Be precise with node-version and add ssh debug * Remove noise
1 parent 9778bb7 commit 825be62

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

.github/workflows/cd-test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ jobs:
1111
test:
1212
strategy:
1313
matrix:
14-
node-version: [16.x]
14+
node-version: [16.17.0]
1515
os: [ubuntu-latest, windows-latest]
1616
runs-on: ${{ matrix.os }}
1717

1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020

2121
- name: Use Node.js ${{ matrix.node-version }}
22-
uses: actions/setup-node@v2
22+
uses: actions/setup-node@v3
2323
with:
2424
node-version: ${{ matrix.node-version }}
2525
cache: "yarn"

packages/fhir-location-management/src/components/AddEditLocationUnit/tests/index.test.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { locationHierarchyResourceType } from '../../../constants';
1111
import { fhirHierarchy } from '../../../ducks/tests/fixtures';
1212
import { waitForElementToBeRemoved } from '@testing-library/dom';
1313
import { createdLocation1 } from '../../LocationForm/tests/fixtures';
14-
import { cleanup, render, screen } from '@testing-library/react';
14+
import { cleanup, render, screen, waitFor } from '@testing-library/react';
1515

1616
jest.mock('fhirclient', () => {
1717
return jest.requireActual('fhirclient/lib/entry/browser');
@@ -94,11 +94,9 @@ test('renders correctly for new locations', async () => {
9494

9595
await waitForElementToBeRemoved(document.querySelector('.ant-spin'));
9696

97-
expect(document.querySelector('title')).toMatchInlineSnapshot(`
98-
<title>
99-
Add Location Unit
100-
</title>
101-
`);
97+
await waitFor(() => {
98+
expect(screen.getByText('Add Location Unit')).toBeInTheDocument();
99+
});
102100

103101
// some small but inconclusive proof that the form rendered
104102
expect(screen.getByLabelText(/name/i)).toMatchSnapshot('name field');

packages/fhir-team-management/src/components/AddEditOrganization/tests/index.test.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { AddEditOrganization } from '..';
66
import { Provider } from 'react-redux';
77
import { store } from '@opensrp/store';
88
import nock from 'nock';
9-
import { cleanup, render, screen } from '@testing-library/react';
9+
import { cleanup, render, screen, waitFor } from '@testing-library/react';
1010
import { waitForElementToBeRemoved } from '@testing-library/dom';
1111
import { createMemoryHistory } from 'history';
1212
import { authenticateUser } from '@onaio/session-reducer';
@@ -127,11 +127,9 @@ test('renders correctly for edit locations', async () => {
127127

128128
expect(nock.pendingMocks()).toEqual([]);
129129

130-
expect(document.querySelector('title')).toMatchInlineSnapshot(`
131-
<title>
132-
Edit team | OpenSRP web Test Organisation
133-
</title>
134-
`);
130+
await waitFor(() => {
131+
expect(screen.getByText('Edit team | OpenSRP web Test Organisation')).toBeInTheDocument();
132+
});
135133

136134
// some small but incoclusive proof that the form rendered and has some initial values
137135
expect(screen.getByLabelText(/name/i)).toMatchSnapshot('name field');

0 commit comments

Comments
 (0)