ui5-community / generator-ui5-app

Generator for UI5 applications which use the official UI5 tooling. This generator was built as a plug-in for the community project Easy UI5 by SAP.
Apache License 2.0
4 stars 4 forks source link

QUnit / OPA tests are generating console errors because of invalid use of `QUnit.config.autostart = false;` #10

Open ArnaudBuchholz opened 11 months ago

ArnaudBuchholz commented 11 months ago

Easy-Ui5 version:

Latest version

OS/version:

Not relevant

Browser/version (+device/version):

Not relevant

Steps to reproduce the problem:

  1. Generate an static server app with easy-ui5
  2. Serve the newly created app
  3. Open the qunit or OPA tests

What is the expected result?

Tests are executed (and they are)

What happens instead?

Depending on the server used, the The console log shows an error about QUnit being called on start while the tests are already started. image

Any other information? (attach screenshot if possible)

The problem comes from the asynchronous loading of the unitTests.qunit module that happens asynchronously after qunit is loaded. Hence it does not prevent the startup soon enough.

https://github.com/ui5-community/generator-ui5-app/blob/95ee595678d06576ccd6a3732349e158bd987796/generators/app/templates/webapp/test/unit/unitTests.qunit.html#L17

I would recommend inserting a small script file that synchronously prevents the tests to start like in : https://github.com/ArnaudBuchholz/training-ui5con18-opa/blob/main/webapp/test/qunit.autostart.js

If you agree with it, I can submit a PR.

ArnaudBuchholz commented 11 months ago

As a side note, it appears that this problem is quite common with UI5 apps, I had to tweak ui5-test-runner to be less strict on that issue. I also observed that the karma runner doesn't care about this problem.