-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(frontend): fix test flakiness #1162
Conversation
We were experiencing flaky tests as described in issue #1161. A timeout of 10s works fine on a local MBP 16". However, given that the CI servers are likely much weaker, 2x the timeout to be on the safe side.
To improve test runtimes, we could explore using It seems that since Travis only provides 2 cores, and since Jest runs with |
frontend/src/setupTests.ts
Outdated
@@ -5,6 +5,8 @@ import { Crypto } from '@peculiar/webcrypto' | |||
import 'locales' // Locales necessary for I18nProvider | |||
import { server } from './test-utils' | |||
|
|||
jest.setTimeout(20000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can introduce an environment variable with a fallback to a default for this? This way if we want to tune this for different environments, we do not need to make changes in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I'll do that with a default of 20s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do test this out on Amplify also with repeated runs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I'm doing so on both Amplify and Travis
This is so that we can configure the timeout based on the test environment.
We don't have any tests that test the announcement modal. Hence, disable it for now. A longer-term fix would be to add announcement_version to the initial state of the API mock.
Also remember to remove running tests on Amplify as discussed during sync up. |
We only rely on Amplify for deployments, so there isn't a major reason to run tests there. The main reason is to block the deployment if a test fails, but any test failures should've been caught on Travis during development. If a failure does happen during deployment, we can manually redeploy an older release.
I'll continue running tests until deployment tonight, but this should fix the issue that you had locally as well as the timeout issues. |
@@ -17,6 +18,9 @@ if (process.env.NODE_ENV === 'test') { | |||
gaInitializeOptions = { | |||
testMode: true, | |||
} | |||
|
|||
// Disable announcements in test environments | |||
announcementActive = 'false' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about disabling announcements for tests? I think it's fine since none of our tests rely on announcements currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine. Given that for most of the flows, that's not the main thing we're testing for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! This fixed the issues I was facing previously when running tests. Merge whenever you're ready.
* develop: refactor: use shared function to initialize models (#1172) chore: setup scaffolding for backend tests (#940) 1.23.0 fix(frontend): fix frontend test flakiness (#1162) fix: update successful delivery status only if error does not exist (#1150) chore: upgrade dependencies (#1153) feat: add unit tests for error states in critical workflows (#1118) feat: support whitelisting domains through `agencies` table (#1141) feat: add tests for happy paths in critical workflows (#1110) fix: prevent campaign names from causing dashboard rows to overflow (#1147) fix(email): Fix SendGrid fallback integration (#1026)
* develop: feat: refactor msg template components; add telegram character limit (#1148) refactor: use shared function to initialize models (#1172) chore: setup scaffolding for backend tests (#940) 1.23.0 fix(frontend): fix frontend test flakiness (#1162) fix: update successful delivery status only if error does not exist (#1150) chore: upgrade dependencies (#1153) feat: add unit tests for error states in critical workflows (#1118) feat: support whitelisting domains through `agencies` table (#1141) feat: add tests for happy paths in critical workflows (#1110) fix: prevent campaign names from causing dashboard rows to overflow (#1147)
* develop: fix: fix error when updating Telegram ID for an existing phone number (#1178) chore: upgrade React; use new JSX transform; sort imports (#1129) fix(backend): docker build and tsc output directory structure (#1177) feat: refactor msg template components; add telegram character limit (#1148) refactor: use shared function to initialize models (#1172) chore: setup scaffolding for backend tests (#940) 1.23.0 fix(frontend): fix frontend test flakiness (#1162) fix: update successful delivery status only if error does not exist (#1150) chore: upgrade dependencies (#1153)
We were experiencing flaky tests as described in issue #1161.
Problem
2 issues:
Some tests were failing with an error saying that the test exceeded the timeout of 5000ms.
The integration tests were written under the assumption that
REACT_APP_ANNOUNCEMENT_ACTIVE != "true"
. However, if it is set totrue
, the integration tests will break due to missing API endpoints and the tests not accounting for the need to dismiss the announcement modal.Closes #1161
Solution
/settings/announcement-version
REACT_APP_ANNOUNCEMENT_ACTIVE=false
. This is fine because none of our tests rely on announcements.Note: a longer term fix would be to add support for
announcement_version
in the API mocks, and configure the initialannouncement_version
appropriately during each test.Tests
All CI tests should pass reliably.
Deploy Notes