Skip to content

Commit

Permalink
ci: Investigate why Cypress tests often timeout (#520)
Browse files Browse the repository at this point in the history
* troubleshoot /api/notif responses
to investigate `JQMIGRATE: jQuery.parseJSON requires a valid JSON string` front-end errors before cypress tests time out

* try workaround from cypress-io/cypress#2938 (comment)

* Revert "try workaround from cypress-io/cypress#2938 (comment)"

This reverts commit e7d605c.

* track URLs of $.ajax() calls

* urls are sometimes objects

* add more logs and artifacts from cypress

* try forcing JSON dataType on /api/notifs requests, to get rid of JQMIGRATE warnings

e.g. https://github.com/openwhyd/openwhyd/runs/4574789313?check_suite_focus=true#step:8:220

* remove logs from /api/notif controller

* disable verbose debug logs from cypress

* try doubling cypress timeout thresholds

* enable screenshots and video

* reduce risk of failing call to /testing/reset before each test

cf video recording: https://dashboard.cypress.io/projects/8mw8bh/runs/559/test-results/e214af35-c109-4513-a1dd-145a82fc7ef0/video
  • Loading branch information
adrienjoly committed Dec 19, 2021
1 parent 58249a3 commit cf051e5
Show file tree
Hide file tree
Showing 6 changed files with 1,691 additions and 1,672 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ jobs:
browser: 'chromium' # to include browser console in cypress logs
record: true
parallel: true

env:
CI: true
APPLITOOLS_API_KEY: ${{ secrets.APPLITOOLS_API_KEY }}
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_DASHBOARD_KEY }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# DEBUG: 'cypress:*'
- name: Get coverage data
run: |
# npm run test:coverage
Expand All @@ -200,6 +200,18 @@ jobs:
path: |
.nyc_output
coverage
# NOTE: screenshots will be generated only if E2E test failed
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
# Test run video was always captured, so this action uses "always()" condition
- uses: actions/upload-artifact@v2
if: always()
with:
name: cypress-videos
path: cypress/videos

coverage:
name: Send coverage reports to Codacy
Expand Down
8 changes: 4 additions & 4 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"projectId": "8mw8bh",
"screenshotOnRunFailure": false,
"video": false,
"screenshotOnRunFailure": true,
"video": true,
"chromeWebSecurity": false,
"baseUrl": "http://localhost:8080",
"defaultCommandTimeout": 4000,
"defaultCommandTimeout": 8000,
"execTimeout": 60000,
"taskTimeout": 60000,
"pageLoadTimeout": 60000,
"pageLoadTimeout": 120000,
"requestTimeout": 5000,
"responseTimeout": 30000,
"slowTestThreshold": 10000
Expand Down
6 changes: 5 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import 'cypress-file-upload';
// Note: please document these commands in index.d.ts.

Cypress.Commands.add('resetDb', () => {
cy.request('POST', `/testing/reset`, { timeout: 10000 });
cy.request('POST', `/testing/reset`, {
timeout: 20000,
retryOnStatusCodeFailure: true,
retryOnNetworkFailure: true,
});
});

Cypress.Commands.add('logout', () => {
Expand Down
2 changes: 1 addition & 1 deletion public/js/jquery-1.10.2.min.js

Large diffs are not rendered by default.

0 comments on commit cf051e5

Please sign in to comment.