Thanks, apparently it was just that I missed call
before launching cypress.
call npx cypress run
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Delayed expansion acts weird in my for loop. At the first iteration study
is defined, at the second iteration it seems the delayed expansion doesn't work (delayed expansion is used just to strip the colon out because that will be the name of a directory). It is like that cypress command breaks something. Is that somehow related to how that cypress CLI works or there is something wrong with my script?
@echo off
setlocal EnableExtensions EnableDelayedExpansion
:parse
IF "%~1"=="" GOTO endparse
IF "%~1"=="-s" SET studies=%~2
SHIFT
GOTO parse
:endparse
for %%a in ("%studies:,=" "%") do (
set tmp=%%~na
set study=!tmp::=!
echo study %%~a delayedExString: !study!
npx cypress run -study=%%~a --config videosFolder=cypress/videos/!study! --headless --spec "cypress/integration/*"
)
Example:
myscript.bat -s "firstStudy:Chap1,secondStudy:Chap3"
Console output:
study firstStudy:Chap1 delayedExString firstStudyChap1
[...cypress log...]
study firstStudy:Chap1 delayedExString !study!
[...cypress log...]
As you can see, in the second iteration study is not expanded.
PS: The tags are kind of wrong as there is no "batch" tag. Please note the script runs on a plain Windows 10 machine.
Thanks, apparently it was just that I missed call
before launching cypress.
call npx cypress run
I changed the npx command to just echo what it would execute instead of actually executing the command.
It appears to be executing the commands that you expect to be executed. So your thought that "the cypress command breaks something" appears correct.
Unfortunately, npx is not a Windows 10 command. I have no idea what npx/cypress is or does. If npx is another .bat file, you could try using a CALL statement.
Have you considered using Powershell instead of a .bat?