Repository: oxc-project/oxc-resolver
Pull request #205 (2024-06-30 15:55:28)

chore: add a broken tsconfig test

codspeed-hq[bot]: ## [CodSpeed Performance Report](https://codspeed.io/oxc-project/oxc-resolver/branches/code-coverage)

### Merging #205 will **not alter performance**

<sub>Comparing <code>code-coverage</code> (bcdd1d9) with <code>main</code> (078a298)</sub>



### Summary

`✅ 2` untouched benchmarks





codecov[bot]: ## [Codecov](https://app.codecov.io/gh/oxc-project/oxc-resolver/pull/205?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=oxc-project) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 96.91%. Comparing base [(`078a298`)](https://app.codecov.io/gh/oxc-project/oxc-resolver/commit/078a29843c22b8df0df431b6ce6e4066d39182a1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=oxc-project) to head [(`bcdd1d9`)](https://app.codecov.io/gh/oxc-project/oxc-resolver/commit/bcdd1d9f7ea43c2127a39e285c3537a88227328c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=oxc-project).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main     #205      +/-   ##
==========================================
+ Coverage   96.86%   96.91%   +0.04%     
==========================================
  Files          11       11              
  Lines        2299     2299              
==========================================
+ Hits         2227     2228       +1     
+ Misses         72       71       -1     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/oxc-project/oxc-resolver/pull/205?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=oxc-project).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=oxc-project).


Patch:
diff --git a/fixtures/tsconfig/tsconfig_broken.json b/fixtures/tsconfig/tsconfig_broken.json
new file mode 100644
index 0000000..98232c6
--- /dev/null
+++ b/fixtures/tsconfig/tsconfig_broken.json
@@ -0,0 +1,1 @@
+{


Test patch:
diff --git a/src/tests/tsconfig_paths.rs b/src/tests/tsconfig_paths.rs
index 26935b5..b85bf6b 100644
--- a/src/tests/tsconfig_paths.rs
+++ b/src/tests/tsconfig_paths.rs
@@ -5,7 +5,8 @@
 use std::path::{Path, PathBuf};
 
 use crate::{
-    ResolveError, ResolveOptions, Resolver, TsConfig, TsconfigOptions, TsconfigReferences,
+    JSONError, ResolveError, ResolveOptions, Resolver, TsConfig, TsconfigOptions,
+    TsconfigReferences,
 };
 
 // <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() {
     assert_eq!(resolved_path, Ok(f.join("bar.js")));
 }
 
+#[test]
+fn broken() {
+    let f = super::fixture_root().join("tsconfig");
+
+    let resolver = Resolver::new(ResolveOptions {
+        tsconfig: Some(TsconfigOptions {
+            config_file: f.join("tsconfig_broken.json"),
+            references: TsconfigReferences::Auto,
+        }),
+        ..ResolveOptions::default()
+    });
+
+    let resolved_path = resolver.resolve(&f, "/");
+    let error = ResolveError::JSON(JSONError {
+        path: f.join("tsconfig_broken.json"),
+        message: String::from("EOF while parsing an object at line 2 column 0"),
+        line: 2,
+        column: 0,
+    });
+    assert_eq!(resolved_path, Err(error));
+}
+
 // <https://github.com/parcel-bundler/parcel/blob/c8f5c97a01f643b4d5c333c02d019ef2618b44a5/packages/utils/node-resolver-rs/src/tsconfig.rs#L193C12-L193C12>
 #[test]
 fn test_paths() {