Commit ae10d612cb2 for nodejs
commit ae10d612cb2fcfbe77c3586fc27fc37974f4af11
Author: Joyee Cheung <joyeec9h3@gmail.com>
Date: Wed Dec 2 19:32:04 2026 +0100
doc: discourage use of internals in test writing guide
This appears to be an issue quite often during V8 upgrades.
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67900
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
diff --git a/doc/contributing/writing-tests.md b/doc/contributing/writing-tests.md
index 3a0ee0969ea..2b825336fb4 100644
--- a/doc/contributing/writing-tests.md
+++ b/doc/contributing/writing-tests.md
@@ -38,6 +38,15 @@ so that when it fails, other contributors can fix it with the full context
of its intention, and be able to modify it in good confidence when the context
changes.
+A good test should avoid using flags such as `--expose-internals` to access internals
+that are not part of the public API unless there's a strong justification for doing so.
+If it's absolutely necessary to use internals, try to make the test flexible enough to
+not test more than what it really tries to verify, so that when irrelevant changes
+are made to the internals, the test still passes. Avoid V8 flags meant for testing V8
+itself, such as `--allow-natives-syntax`. Tests that rely on them depend on V8 internal
+behavior, such as when a function gets optimized or how a string is represented internally,
+which can change in any V8 upgrade and is outside of our control.
+
## Test structure
Let's analyze this basic test from the Node.js test suite: