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: