From e6a935f49dca3301f0ef8cb138909f67a4fa72e1 Mon Sep 17 00:00:00 2001 From: dpschen Date: Mon, 11 Oct 2021 18:39:27 +0000 Subject: [PATCH] fix: disable service workers in cypress (#830) Co-authored-by: Dominik Pschenitschni Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/830 Reviewed-by: konrad Co-authored-by: dpschen Co-committed-by: dpschen --- .drone.yml | 20 ++++---------------- cypress/support/index.js | 7 +++++++ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.drone.yml b/.drone.yml index 514ca996..a41dfe2a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -79,25 +79,13 @@ steps: depends_on: - dependencies - # Building in dev mode to avoid the service worker for testing - - name: build-dev - image: node:16 - pull: true - environment: - YARN_CACHE_FOLDER: .cache/yarn/ - CYPRESS_CACHE_FOLDER: .cache/cypress/ - commands: - - yarn build:dev - depends_on: - - dependencies - - name: build-prod image: node:16 pull: true environment: YARN_CACHE_FOLDER: .cache/yarn/ commands: - - yarn build --dest dist-prod + - yarn build depends_on: - dependencies @@ -119,12 +107,12 @@ steps: CYPRESS_CACHE_FOLDER: .cache/cypress/ CYPRESS_DEFAULT_COMMAND_TIMEOUT: 60000 commands: - - sed -i 's/localhost/api/g' dist-dev/index.html - - yarn serve:dist-dev & npx wait-on http://localhost:5000 + - sed -i 's/localhost/api/g' dist/index.html + - yarn serve:dist & npx wait-on http://localhost:5000 - yarn test:frontend --browser chrome depends_on: - dependencies - - build-dev + - build-prod - name: upload-test-results image: plugins/s3 diff --git a/cypress/support/index.js b/cypress/support/index.js index 22ec961f..0c885c65 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -2,3 +2,10 @@ import './commands' import 'cypress-file-upload' import '@4tw/cypress-drag-drop' + +// see https://github.com/cypress-io/cypress/issues/702#issuecomment-587127275 +Cypress.on('window:before:load', (win) => { + // disable service workers + // @ts-ignore + delete win.navigator.__proto__.ServiceWorker +}) \ No newline at end of file