From dec0fe5a83db234ab87bedc9e56d7b85ed0462aa Mon Sep 17 00:00:00 2001 From: Henry Castro Date: Thu, 22 Jun 2023 14:43:00 -0400 Subject: [PATCH] cypress: fix missing config file, builddir != srcdir "Could not find a Cypress configuration file in this folder"" Change-Id: I7d5b2094d6cd10ca3da2a099650f830bee31dfb1 Signed-off-by: Henry Castro --- cypress_test/Makefile.am | 27 ++++++++++++++++++--------- cypress_test/run_parallel.sh | 3 +++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/cypress_test/Makefile.am b/cypress_test/Makefile.am index 8a23c5b2f8..cd8b78cb1a 100644 --- a/cypress_test/Makefile.am +++ b/cypress_test/Makefile.am @@ -9,6 +9,7 @@ WAIT_ON_BINARY = $(abs_builddir)/node_modules/wait-on/bin/wait-on GET_PORT_BINARY = $(abs_builddir)/node_modules/get-port-cli/cli.js NPM_INSTALLED = $(abs_builddir)/workdir/npm_installed CAPABILITIES = $(if @ENABLE_SETCAP@,true,false) +CYPRESS_CONFIG = $(abs_srcdir)/cypress.config.ts PARALLEL_SCRIPT = $(abs_srcdir)/run_parallel.sh @@ -579,12 +580,14 @@ do-run-cov: @JAILS_PATH@ $(NODE_BINS) # Open cypress interactive test runner window with all tests in it. # # Parameters: -# 1 - config: cypress configuration (e.g. cypress' --config argument). -# 2 - env: list of environment variables (e.g. cypress' --env argument). +# 1 - config-file: cypress configuration file (e.g. cypress.config.ts). +# 2 - config: cypress configuration (e.g. cypress' --config argument). +# 3 - env: list of environment variables (e.g. cypress' --env argument). define run_interactive_all DEBUG='cypress:*' \ DISPLAY=$(if $(HEADLESS_BUILD),$(HEADLESS_DISPLAY),$(DISPLAY)) \ $(CYPRESS_BINARY) open \ + --config-file $(CYPRESS_CONFIG) \ --config $(1) \ --env $(2) endef @@ -592,15 +595,17 @@ endef # Run single test in cypress interactive test runner. # # Parameters: -# 1 - config: cypress configuration (e.g. cypress' --config argument). -# 2 - env: list of environment variables (e.g. cypress' --env argument). -# 3 - spec: test file path (e.g. cypress' --spec argument) +# 1 - config-file: cypress configuration file (e.g. cypress.config.ts). +# 2 - config: cypress configuration (e.g. cypress' --config argument). +# 3 - env: list of environment variables (e.g. cypress' --env argument). +# 4 - spec: test file path (e.g. cypress' --spec argument) define run_interactive_single DEBUG='cypress:*' \ DISPLAY=$(if $(HEADLESS_BUILD),$(HEADLESS_DISPLAY),$(DISPLAY)) \ $(CYPRESS_BINARY) run \ --browser $(BROWSER) \ --headed --no-exit \ + --config-file $(CYPRESS_CONFIG) \ --config $(1),retries=0 \ --env $(2) \ --spec=$(3) @@ -614,6 +619,7 @@ endef # 3 - spec: test file path (e.g. cypress' --spec argument) # 4 - type: test type (e.g. mobile, desktop, multi-user) # 5 - log: log file path +# 6 - config-file: cypress configuration file (e.g. cypress.config.ts) define run_test_parallel $(PARALLEL_SCRIPT) \ --browser $(BROWSER) \ @@ -621,19 +627,22 @@ define run_test_parallel --env $(2) \ --spec $(3) \ --type $(4) \ - --log-file $(5) + --log-file $(5) \ + --config-file $(CYPRESS_CONFIG) endef # Run one test \ tests in headless mode. # # Parameters: -# 1 - config: cypress configuration (e.g. cypress' --config argument). -# 2 - env: list of environment variables (e.g. cypress' --env argument). -# 3 - spec (optional): test file path (e.g. cypress' --spec argument) +# 1 - config-file: cypress configuration file (e.g. cypress.config.ts). +# 2 - config: cypress configuration (e.g. cypress' --config argument). +# 3 - env: list of environment variables (e.g. cypress' --env argument). +# 4 - spec (optional): test file path (e.g. cypress' --spec argument) define run_test_headless $(CYPRESS_BINARY) run \ --browser $(BROWSER) \ --headless \ + --config-file $(CYPRESS_CONFIG) \ --config $(1) \ --env $(2) \ $(if $(3),--spec=$(3)) \ diff --git a/cypress_test/run_parallel.sh b/cypress_test/run_parallel.sh index 5b26c7cfc9..9869254363 100755 --- a/cypress_test/run_parallel.sh +++ b/cypress_test/run_parallel.sh @@ -32,6 +32,7 @@ print_help () TEST_FILE= TEST_LOG= TEST_CONFIG= +TEST_CONFIG_FILE= TEST_ENV= TEST_TYPE= BROWSER= @@ -40,6 +41,7 @@ while test $# -gt 0; do case $1 in --spec) TEST_FILE=$2; shift;; --log-file) TEST_LOG=$2; shift;; + --config-file) TEST_CONFIG_FILE=$2; shift;; --config) TEST_CONFIG=$2; shift;; --env) TEST_ENV=$2; shift;; --type) TEST_TYPE=$2; shift;; @@ -65,6 +67,7 @@ fi RUN_COMMAND="${CYPRESS_BINARY} run \ --browser ${BROWSER} \ --headless \ + --config-file ${TEST_CONFIG_FILE}\ --config ${TEST_CONFIG}\ --env ${TEST_ENV}\ --spec=${TEST_FILE_PATH}"