quasarframework / quasar-testing

Testing Harness App Extensions for the Quasar Framework 2.0+
https://testing.quasar.dev
MIT License
179 stars 65 forks source link

Cypress E2E tests not configured to use the custom dev server port #320

Closed staszek998 closed 11 months ago

staszek998 commented 1 year ago

Software version

What did you get as the error?

Running the npm run test:e2e command does NOT open the Cypress runner. The process hangs on the very beginning, just after the initialization of the Quasar's dev server, waits for some time, and finally outputs the following message:

Error: Timed out waiting for: http-get://localhost:9000
    at C:\Users\A447524\workspace\playground\quasar-testing-custom-dev-server-port\node_modules\wait-on\lib\wait-on.js:132:31
    at doInnerSub (C:\Users\A447524\workspace\playground\quasar-testing-custom-dev-server-port\node_modules\rxjs\dist\cjs\internal\operators\mergeInternals.js:22:31)
    at outerNext (C:\Users\A447524\workspace\playground\quasar-testing-custom-dev-server-port\node_modules\rxjs\dist\cjs\internal\operators\mergeInternals.js:17:70)
    at OperatorSubscriber._this._next (C:\Users\A447524\workspace\playground\quasar-testing-custom-dev-server-port\node_modules\rxjs\dist\cjs\internal\operators\OperatorSubscriber.js:33:21)
    at Subscriber.next (C:\Users\A447524\workspace\playground\quasar-testing-custom-dev-server-port\node_modules\rxjs\dist\cjs\internal\Subscriber.js:51:18)
    at AsyncAction.work (C:\Users\A447524\workspace\playground\quasar-testing-custom-dev-server-port\node_modules\rxjs\dist\cjs\internal\observable\timer.js:28:28)
    at AsyncAction._execute (C:\Users\A447524\workspace\playground\quasar-testing-custom-dev-server-port\node_modules\rxjs\dist\cjs\internal\scheduler\AsyncAction.js:79:18)
    at AsyncAction.execute (C:\Users\A447524\workspace\playground\quasar-testing-custom-dev-server-port\node_modules\rxjs\dist\cjs\internal\scheduler\AsyncAction.js:67:26)
    at AsyncScheduler.flush (C:\Users\A447524\workspace\playground\quasar-testing-custom-dev-server-port\node_modules\rxjs\dist\cjs\internal\scheduler\AsyncScheduler.js:38:33)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

What were you expecting?

I expected the Cypress runner to pop-up.

What steps did you take, to get the error?

  1. Scaffold a fresh new app using the newest stable Quasar CLI:
    • run npm init quasar
    • choose Quasar v2 + Vite (it shouldn't really matter, but you have to choose something)
    • everything else using the default values
  2. Change the devServer.port property inside the quasar.config.js file to any value different from the default one (default is 9000). Example values to reproduce the bug: 9001, 8080, 3000.
  3. Install the Quasar Testing AE:
    • run quasar ext add @quasar/testing
    • choose Cypress 12+
    • add "scripts" to the package.json
  4. Run the Cypress E2E tests using the npm run test:e2e or npm run test:e2e:ci command (it doesn't matter which one, the effect is exactly the same).

Current workaround

Update the body of the test:e2e and test:e2e:ci scripts so they use the correct dev server port. For example, when you set the devServer.port property value to 3000, your scripts should look like this:

"test:e2e": "cross-env NODE_ENV=test start-test \"quasar dev\" http-get://localhost:3000 \"cypress open --e2e\"",
"test:e2e:ci": "cross-env NODE_ENV=test start-test \"quasar dev\" http-get://localhost:3000 \"cypress run --e2e\"",

Likewise, when you set the devServer.port property value to 9001, your scripts should be updated accordingly:

"test:e2e": "cross-env NODE_ENV=test start-test \"quasar dev\" http-get://localhost:9001 \"cypress open --e2e\"",
"test:e2e:ci": "cross-env NODE_ENV=test start-test \"quasar dev\" http-get://localhost:9001 \"cypress run --e2e\"",
IlCallo commented 1 year ago

That's a known problem, see a related one https://github.com/quasarframework/quasar-testing/issues/196

It boils down to not knowing wheter the end user tampered with the default port, and not having a simple way to act upon that manual change We're open to PRs, but the only thing which comes to my mind right now is just to add a disclaimer on the documentation

IlCallo commented 11 months ago

In the upcoming new version we'll force the devServer to use 8080 port to unify the usage among different build targets