Skip to content

Commit fe9a10a

Browse files
authored
chore: add a broken tsconfig test (#205)
1 parent 078a298 commit fe9a10a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{

src/tests/tsconfig_paths.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
use std::path::{Path, PathBuf};
66

77
use crate::{
8-
ResolveError, ResolveOptions, Resolver, TsConfig, TsconfigOptions, TsconfigReferences,
8+
JSONError, ResolveError, ResolveOptions, Resolver, TsConfig, TsconfigOptions,
9+
TsconfigReferences,
910
};
1011

1112
// <https://github.com/parcel-bundler/parcel/blob/b6224fd519f95e68d8b93ba90376fd94c8b76e69/packages/utils/node-resolver-rs/src/lib.rs#L2303>
@@ -90,6 +91,28 @@ fn json_with_comments() {
9091
assert_eq!(resolved_path, Ok(f.join("bar.js")));
9192
}
9293

94+
#[test]
95+
fn broken() {
96+
let f = super::fixture_root().join("tsconfig");
97+
98+
let resolver = Resolver::new(ResolveOptions {
99+
tsconfig: Some(TsconfigOptions {
100+
config_file: f.join("tsconfig_broken.json"),
101+
references: TsconfigReferences::Auto,
102+
}),
103+
..ResolveOptions::default()
104+
});
105+
106+
let resolved_path = resolver.resolve(&f, "/");
107+
let error = ResolveError::JSON(JSONError {
108+
path: f.join("tsconfig_broken.json"),
109+
message: String::from("EOF while parsing an object at line 2 column 0"),
110+
line: 2,
111+
column: 0,
112+
});
113+
assert_eq!(resolved_path, Err(error));
114+
}
115+
93116
// <https://github.com/parcel-bundler/parcel/blob/c8f5c97a01f643b4d5c333c02d019ef2618b44a5/packages/utils/node-resolver-rs/src/tsconfig.rs#L193C12-L193C12>
94117
#[test]
95118
fn test_paths() {

0 commit comments

Comments
 (0)