Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 13d209c

Browse files
committedSep 24, 2024·
add some tests
1 parent 1efbde6 commit 13d209c

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed
 

‎src/ignoreErrors.test.ts

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { Project } from "ts-morph";
66

77
import { ignoreErrors } from "./ignoreErrors";
88

9-
const PROJECT_ROOT = path.resolve(
10-
import.meta.dirname,
11-
"__fixtures__/sample-project",
12-
);
13-
149
test("should work", (t) => {
10+
const PROJECT_ROOT = path.resolve(
11+
import.meta.dirname,
12+
"__fixtures__/sample-project",
13+
);
14+
1515
const project = new Project({
1616
tsConfigFilePath: path.resolve(PROJECT_ROOT, "tsconfig.json"),
1717
});
@@ -50,3 +50,40 @@ a = "foo";
5050
`,
5151
);
5252
});
53+
54+
test("tsx", (t) => {
55+
const PROJECT_ROOT = path.resolve(
56+
import.meta.dirname,
57+
"__fixtures__/sample-project-react",
58+
);
59+
60+
const project = new Project({
61+
tsConfigFilePath: path.resolve(PROJECT_ROOT, "tsconfig.json"),
62+
});
63+
64+
const diagnostics = project.getPreEmitDiagnostics();
65+
ignoreErrors(diagnostics);
66+
67+
const sourceFile = project.getSourceFile("index.tsx");
68+
assert(sourceFile, "File should exist");
69+
assert.equal(
70+
sourceFile.getText(),
71+
`\
72+
function Component() {
73+
const doc = "foo"
74+
75+
// @ts-expect-error TS(2339) FIXME: Property 'foo' does not exist on type '"foo"'.
76+
doc.foo
77+
78+
return <>
79+
{/* @ts-expect-error TS(2304) FIXME: Cannot find name 'Foo'. */}
80+
<Foo bar={bas} />
81+
{/* @ts-expect-error TS(2339) FIXME: Property 'foo' does not exist on type '"foo"'. */}
82+
{doc.foo}
83+
</>;
84+
}
85+
86+
export default Component
87+
`,
88+
);
89+
});

0 commit comments

Comments
 (0)
Please sign in to comment.