Skip to content

Commit 1ca0aac

Browse files
authored
Add source map visualization for tests (#19997)
This PR is an internal change only related to how we visualize source maps. As part of this PR (#19996) I added a test for source maps related to how `@variant` is processed. And while the result was correct, I had a hard time verifying if this was _actually_ correct. I did the mental mapping of comparing locations from the output to the input. <img width="495" height="495" alt="image" src="https://github.com/user-attachments/assets/2b1c12cd-43ee-461a-b93b-bafe6ce1cce5" /> With this PR, I want to make that more visual by actually printing the input source(s) and output file and highlight the necessary parts: <img width="1101" height="1085" alt="image" src="https://github.com/user-attachments/assets/14390026-f211-4cfc-8c6c-3293105f6403" /> I didn't want to get too clever here. But printing line numbers also helps in case we point to different spots on the same line: <img width="1200" height="981" alt="image" src="https://github.com/user-attachments/assets/e75f7622-eb51-49ee-928e-fdc8672d2c3f" /> And if we point to different files, then we visualize these as well: <img width="851" height="957" alt="image" src="https://github.com/user-attachments/assets/77e65801-b46b-4579-8659-d919a8750f60" /> If you combine this with snapshot tests, then it's very easy to verify that locations match up correctly. Each source map location is highlighted and references a symbol starting at `A`, `B`, etc. A change to the source maps _can_ result in a big diff, and even this PR introduces a big diff because of the preflight diffs. But at least you can see how things line up. ## Test plan 1. All tests still pass 2. Added tests for the source map visualizer that is only used in tests 3. No actual source code was touched
1 parent e1201bc commit 1ca0aac

4 files changed

Lines changed: 1628 additions & 294 deletions

File tree

0 commit comments

Comments
 (0)