From 4a3c77ac7d073f91e46d310ce1eb79fe626a502b Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 30 Nov 2026 16:48:00 +0100 Subject: [PATCH 1/2] 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 --- doc/contributing/writing-tests.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/contributing/writing-tests.md b/doc/contributing/writing-tests.md index 3a0ee0969eaf..2c05d66da1dd 100644 --- a/doc/contributing/writing-tests.md +++ b/doc/contributing/writing-tests.md @@ -38,6 +38,14 @@ 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. Be especially cautious if the flag +comes from V8 as V8 internal behaviors can change frequently during V8 upgrades and +are out of our control. + ## Test structure Let's analyze this basic test from the Node.js test suite: From a51bf388042356168c5b9a7337aa467dea6f7b21 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 2 Dec 2026 17:02:56 +0100 Subject: [PATCH 2/2] fixup! doc: discourage use of internals in test writing guide --- doc/contributing/writing-tests.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/contributing/writing-tests.md b/doc/contributing/writing-tests.md index 2c05d66da1dd..2b825336fb48 100644 --- a/doc/contributing/writing-tests.md +++ b/doc/contributing/writing-tests.md @@ -42,9 +42,10 @@ A good test should avoid using flags such as `--expose-internals` to access inte 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. Be especially cautious if the flag -comes from V8 as V8 internal behaviors can change frequently during V8 upgrades and -are out of our control. +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