Starting Dev Server for Cypress Hangs
My team has been working on migrating to using this plugin as part of our Nx14 upgrade, and one issue we've encountered is when we attempt to use the serve target to start serverless offline, the signal never makes it that the executor is successful, so Cypress never starts.
my-app/project.json:
{
targets: {
"serve": {
"executor": "@ns3/nx-serverless:sls",
"options": {
"command": "offline"
}
}
}
}
my-app-e2e/project.json:
{
targets: {
"e2e": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/my-app-e2e/cypress.json",
"devServerTarget": my-app:serve",
"tsConfig": "apps/my-app-e2e/tsconfig.json"
}
}
}
}
It seems like the call to execa.command in executor.ts is being awaited, but because the command is serverless offline the process doesn't exit, and thus execa doesn't return a value, causing the whole executor to stall, and never returning a ready state.
Hi, yeah, I have never tested it for. You may be right. I feel like there would be a lot of work to make it work as expected - taking into the account format output locally and on CI - which is important for nx-cloud.
await works great for all "normal" targets like "package" or "deploy", but with "offline" you are right, it doesn't end. Perhaps we need a separate executor for "continuous tasks"... I am not happy about it :/ I like the simplicity of the current solution. I personally always test deployed instance so "offline" mode was always an afterthought, but I do recognise the need.
If you have an idea for elegant solution to that issue I always welcome a PR ;)
As a workaround you can probably just wrap my-app:serve in some simple executor that executed original serve without awaiting result and yielding right away.
Just as a follow-on for anyone who comes across this thread, another def on my team found a workaround for this issue. We added the following target that we use as the devServerTarget for our e2e project:
"cypress": {
"executor": "nx:run-commands",
"options": {
"command": "npx nx run <serverless-project>:serve",
"readyWhen": "[HTTP] server ready"
}
},