mirror of
https://github.com/danbulant/oxc
synced 2026-05-22 05:38:54 +00:00
- Related https://github.com/rolldown/rolldown/issues/2737 Probably this is still an approximation of what https://github.com/evanw/source-map-visualization does, but I tried to get some ideas from it. For comparison, I added an example from their site https://evanw.github.io/source-map-visualization/ as a snapshot in `crates/oxc_sourcemap/tests/fixtures/esbuild/visualizer.snap`. I'll mention a few notable changes in the comments. Snapshot change in rolldown repo can be found in - https://github.com/rolldown/rolldown/pull/2829
17 lines
748 B
Rust
17 lines
748 B
Rust
use std::fs;
|
|
|
|
use oxc_sourcemap::{SourceMap, SourcemapVisualizer};
|
|
|
|
#[test]
|
|
fn snapshot_sourcemap_visualizer() {
|
|
insta::glob!("fixtures/**/*.js", |path| {
|
|
let js = fs::read_to_string(path).unwrap();
|
|
let js_map = fs::read_to_string(path.with_extension("js.map")).unwrap();
|
|
let sourcemap = SourceMap::from_json_string(&js_map).unwrap();
|
|
let visualizer = SourcemapVisualizer::new(&js, &sourcemap);
|
|
let visualizer_text = visualizer.into_visualizer_text();
|
|
insta::with_settings!({ snapshot_path => path.parent().unwrap(), prepend_module_to_snapshot => false, snapshot_suffix => "", omit_expression => true }, {
|
|
insta::assert_snapshot!("visualizer", visualizer_text);
|
|
});
|
|
});
|
|
}
|