From b21c6f82e210df4dcacff94c6edb3bf968f8b777 Mon Sep 17 00:00:00 2001 From: Tinco Andringa Date: Sun, 7 Apr 2024 10:49:41 +0200 Subject: [PATCH] test(tsc): add test for #4203 (#4207) --- packages/tsc/tests/index.spec.ts | 11 ++++++++++- test-workspace/tsc/should-error/main.vue | 8 ++++++++ test-workspace/tsc/should-error/tsconfig.json | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test-workspace/tsc/should-error/main.vue create mode 100644 test-workspace/tsc/should-error/tsconfig.json diff --git a/packages/tsc/tests/index.spec.ts b/packages/tsc/tests/index.spec.ts index c20fc15dd3..b189d4731f 100644 --- a/packages/tsc/tests/index.spec.ts +++ b/packages/tsc/tests/index.spec.ts @@ -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([ @@ -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'); + }); }); diff --git a/test-workspace/tsc/should-error/main.vue b/test-workspace/tsc/should-error/main.vue new file mode 100644 index 0000000000..0255a314f5 --- /dev/null +++ b/test-workspace/tsc/should-error/main.vue @@ -0,0 +1,8 @@ + + + diff --git a/test-workspace/tsc/should-error/tsconfig.json b/test-workspace/tsc/should-error/tsconfig.json new file mode 100644 index 0000000000..a1e651d6e8 --- /dev/null +++ b/test-workspace/tsc/should-error/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": [ "**/*" ] +}