diff --git a/Makefile.local b/Makefile.local --- a/Makefile.local +++ b/Makefile.local @@ -55,7 +55,7 @@ echo "flush_all" | nc -q 2 localhost 11211 2>/dev/null run-django-webpack-devserver: add-users-dev yarn-install - bash -c "trap 'trap - SIGINT SIGTERM ERR; kill %1' SIGINT SIGTERM ERR; \ + bash -c "trap 'trap - SIGINT SIGTERM ERR && kill %1' SIGINT SIGTERM ERR; \ $(YARN) start-dev & sleep 10 && cd swh/web && \ python3 manage.py runserver --nostatic --settings=$(SETTINGS_DEV)" @@ -85,7 +85,8 @@ .PHONY: test-frontend-cmd test-frontend-cmd: build-webpack-test add-users-test - bash -c "trap 'trap - SIGINT SIGTERM ERR EXIT; jobs -p | xargs -r kill' SIGINT SIGTERM ERR EXIT; \ + bash -c "trap 'trap - SIGINT SIGTERM ERR EXIT && \ + jobs -p | xargs -r kill' SIGINT SIGTERM ERR EXIT; \ python3 swh/web/manage.py runserver --nostatic --settings=$(SETTINGS_TEST) & \ sleep 10 && $(YARN) run cypress run --config numTestsKeptInMemory=0 && $(YARN) run mochawesome" @@ -96,8 +97,13 @@ test-frontend-full: test-frontend-cmd .PHONY: test-frontend-ui-cmd -test-frontend-ui-cmd: build-webpack-test add-users-test - bash -c "trap 'trap - SIGINT SIGTERM ERR EXIT; jobs -p | xargs -r kill' SIGINT SIGTERM ERR EXIT; \ +test-frontend-ui-cmd: add-users-test yarn-install + # ensure all child processes will be killed when hitting Ctrl-C in terminal + # or manually closing the Cypress UI window, killing by PGID seems the only + # reliable way to do it in that case + bash -c "trap 'trap - SIGINT SIGTERM ERR EXIT && \ + ps -o pgid= $$$$ | grep -o [0-9]* | xargs pkill -g' SIGINT SIGTERM ERR EXIT; \ + $(YARN) start-dev & \ python3 swh/web/manage.py runserver --nostatic --settings=$(SETTINGS_TEST) & \ sleep 10 && $(YARN) run cypress open" diff --git a/assets/config/webpack.config.development.js b/assets/config/webpack.config.development.js --- a/assets/config/webpack.config.development.js +++ b/assets/config/webpack.config.development.js @@ -122,7 +122,8 @@ errors: true }, // workaround for https://github.com/webpack/webpack-dev-server/issues/2692 - injectClient: false + injectClient: false, + transportMode: 'ws' }, // set entries to the bundles we want to produce entry: bundles, diff --git a/cypress.json b/cypress.json --- a/cypress.json +++ b/cypress.json @@ -25,5 +25,7 @@ }, "retries": { "runMode": 4 - } -} + }, + "hmrUrl": "ws://localhost:3000/sockjs-node", + "hmrRestartDelay": 3000 +} \ No newline at end of file diff --git a/cypress/support/index.js b/cypress/support/index.js --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -5,6 +5,7 @@ * See top-level LICENSE file for more information */ +import 'cypress-hmr-restarter'; import '@cypress/code-coverage/support'; import {httpGetJson} from '../utils'; diff --git a/package.json b/package.json --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "copy-webpack-plugin": "^8.1.1", "css-loader": "^5.2.4", "cypress": "^7.3.0", + "cypress-hmr-restarter": "^2.0.1", "cypress-multi-reporters": "^1.5.0", "ejs": "^3.1.6", "ejs-compiled-loader": "^3.1.0", diff --git a/yarn.lock b/yarn.lock --- a/yarn.lock +++ b/yarn.lock @@ -4733,6 +4733,11 @@ dependencies: array-find-index "^1.0.1" +cypress-hmr-restarter@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/cypress-hmr-restarter/-/cypress-hmr-restarter-2.0.1.tgz#1981dd5fbfaecb7df3372f974ec7d2a2c86de3da" + integrity sha512-uBZw6mjrV7FIXSf4Y7PzwUUqfpYMfIFAmMWZ7yTQPzZHAuC9AvDxJ2bbZvXomK1/EabARpCeox6Ip3i7YITLfg== + cypress-multi-reporters@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/cypress-multi-reporters/-/cypress-multi-reporters-1.5.0.tgz#fff2758c082b49e8b91fed39f9650c70bc06de0d"