Tests: Suggestion, Introduce -webonly keyword to QUnit.module name for skipping the tests on Node.js #20884
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue: #20795 (comment)
Background:
There are two ways to run our unit tests.
npm run test-unit(or other) command.http://localhost:8080/test/unit/UnitTests.html.Problem:
The both run the same unit test sets. (I focus on core source code unit tests for now.) And Three.js partly has code including features Node.js doesn't natively support, for example DOM operation.
Then currently we can't add test cases using such features because the tests fail or terminate on Node.js.
Suggestion:
I'd like to suggest
-webonlykeyword (better name idea is welcome) toQUnit.modulename for skipping such the tests on Node.js.QUnit.config.filtercan filter the tests. My idea is running the tests on Node.js excepts for the ones whose module name includes-webonlywhile running all the tests on Web.https://api.qunitjs.com/config/QUnit.config/
Example:
I added
WebGLRendererinstantiation test as an example in this PR.new WebGLRenderer()doesn't work as is on Node.js because it has a dependency withdocument.The following two screenshots show that the tests pass on both Node.js and Web although the
WebGLRenderer()instantiation test is added.Benefits
We can add the tests more to the unit tests. It helps keeping Three.js functionality.
Alternative solutions
Probably my idea is simpler than the alternatives. Disadvantage compared to 2 is we still can't run the tests using the features Node.js doesn't natively support on Node.js
This contribution is made at San Francisco International Airport.