For token transformers, we now have the transformTests.js script to help unit test individual token transformers. This lets us feed the same token streams to the JS code and the ported PHP code and (a) verify that the output token streams match (b) evaluate performance.
We need an equivalent functionality for DOM transformations. All DOM transformations now have the ability to dump the DOM before and after the transformation which can be used to generate unit test input and output for comparison on the PHP side.
parse.js script already has the ability to dump DOMs pre/post a dom-pass which can be used for testing and comparing the JS and PHP outputs. parse.js --dump=help lists the dumping options. However, this dump is primarily targeted for debugging and needs to be adapted for generating dom tests. Here is a possible approach:
parse.js already has a --genTest option. Now it accepts `--genTest dom:PASS-NAME,dom:ANOTHER-PASS-NAME --genDIrectory ../tests --genFragments true --pageName Hampi
This produces a pair of test files in the ../test directory called hampi-PASS-NAME-pre.txt and hampi-PASS-NAME-post.txt The default is to not generate fragments but that can be enabled for special reasons with --genFragments true option.