浏览代码

Tests: Update Unit Test Readme (#25453)

* Update Unit Test Readme

Update unit test readme to reflect changes since #25380
Avoid building the library and flagging the files as changed (tests run off source)
Add notes to help people running unit tests.
ColorManagement.enabled is false by default.
Tune logging so only genuine test failure messages are displayed.

* Update ColorManagement.tests.js

Minimize the console messages captured.
Ed Preston 2 年之前
父节点
当前提交
973cc0453c
共有 2 个文件被更改,包括 37 次插入4 次删除
  1. 18 3
      test/unit/README.md
  2. 19 1
      test/unit/src/math/ColorManagement.tests.js

+ 18 - 3
test/unit/README.md

@@ -1,10 +1,25 @@
 ## Setup
 
-- Execute `npm i --prefix test` from root folder
+- Execute `npm install` from the root folder
 
 ## Run
 
 You can run the unit tests in two environments:
 
-- Node.js: Execute `npm run test-unit` from root folder
-- Browser: Execute `npm start` (or run any other local web sever) from root folder and access `http://localhost:8080/test/unit/UnitTests.html` on web browser. (See [How to run things locally](https://threejs.org/docs/#manual/introduction/How-to-run-things-locally))
+- Node.js: Execute `npm run test-unit` from the root folder
+- Browser: Execute `npx servez -p 8080 --ssl` (or run any other local web sever) from the root folder and access `https://localhost:8080/test/unit/UnitTests.html` in a web browser. 
+
+See [How to run things locally](https://threejs.org/docs/#manual/introduction/How-to-run-things-locally) for more information.
+
+## Notes
+
+Some tests can only be run in a browser environment.
+
+For browser tests, futher changes to the library will not be reflected until the page is refreshed.
+
+When adding or updating tests, the cost common cause of test failure is forgetting to change `QUnit.todo` to `QUnit.test` when the test is ready.
+
+## Debugging
+
+To debug a test, add `debugger;` to the test code. Then, run the test in a browser and open the developer tools. The test will stop at the `debugger` statement and you can inspect the code.
+

+ 19 - 1
test/unit/src/math/ColorManagement.tests.js

@@ -2,15 +2,33 @@
 
 import { ColorManagement } from '../../../../src/math/ColorManagement.js';
 
+import { CONSOLE_LEVEL } from '../../utils/console-wrapper.js';
+
 export default QUnit.module( 'Maths', () => {
 
 	QUnit.module( 'ColorManagement', () => {
 
 		// PROPERTIES
+		QUnit.test( 'enabled', ( assert ) => {
+
+			assert.ok(
+				ColorManagement.enabled == false,
+				'ColorManagement.enabled is false by default.'
+			);
+
+		} );
+
 		QUnit.test( 'legacyMode', ( assert ) => {
 
+			// surpress the following console message during testing
+			// THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.
+
+			console.level = CONSOLE_LEVEL.OFF;
+			const expected = ColorManagement.legacyMode == true;
+			console.level = CONSOLE_LEVEL.DEFAULT;
+
 			assert.ok(
-				ColorManagement.legacyMode == true,
+				expected,
 				'ColorManagement.legacyMode is true by default.'
 			);