Skip to content

Commit

Permalink
test(tsc): add test for #4203 (#4207)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinco authored Apr 7, 2024
1 parent 06d6848 commit b21c6f8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/tsc/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function collectTests(dir: string, depth = 2, isRoot: boolean = true): [filePath
for (const file of files) {
const filePath = path.join(dir, file);
const stat = fs.statSync(filePath);
if (stat.isDirectory()) {
if (stat.isDirectory() && file !== 'should-error') {
const tsconfigPath = path.join(filePath, 'tsconfig.json');
if (fs.existsSync(tsconfigPath)) {
tests.push([
Expand Down Expand Up @@ -77,4 +77,13 @@ describe(`vue-tsc`, () => {
for (const [path, isRoot] of tests) {
it(`vue-tsc no errors (${prettyPath(path, isRoot)})`, () => runVueTsc(path), 400_000);
}

it(`should throw an error when no vue-expect-error is used but the there is no error`, async () => {
try {
await runVueTsc(path.resolve(workspace, 'should-error'));
} catch (e) {
return;
}
throw new Error('Expected an error but got none');

Check failure on line 87 in packages/tsc/tests/index.spec.ts

View workflow job for this annotation

GitHub Actions / build (16, ubuntu-latest)

packages/tsc/tests/index.spec.ts > vue-tsc > should throw an error when no vue-expect-error is used but the there is no error

Error: Expected an error but got none ❯ packages/tsc/tests/index.spec.ts:87:9
});
});
8 changes: 8 additions & 0 deletions test-workspace/tsc/should-error/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script setup lang="ts">
const foo = {};
</script>

<template>
<!-- @vue-expect-error -->
<div v-bind="foo"></div>
</template>
4 changes: 4 additions & 0 deletions test-workspace/tsc/should-error/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": [ "**/*" ]
}

0 comments on commit b21c6f8

Please sign in to comment.