summaryrefslogtreecommitdiff
path: root/tests/specs/test/markdown_ts_expect_error
diff options
context:
space:
mode:
authorYusuke Tanaka <yusuktan@maguro.dev>2024-11-14 14:04:32 +0900
committerGitHub <noreply@github.com>2024-11-13 21:04:32 -0800
commit15fae197482a9ac84e0227200ef8f4d0d4e4bd33 (patch)
treebe0cce33690ed742d950091bdb46c22ce04b0a1f /tests/specs/test/markdown_ts_expect_error
parent6b5cb41545086a7a550c698620f5b7bb19b5524f (diff)
fix(cli): preserve comments in doc tests (#26828)
This commit makes comments in code snippets in JSDoc or markdown preserved when they are executed as tests. In particular, this is needed to get TypeScript special comments such as `@ts-ignore` or `@ts-expect-error` to work correctly. Fixes #26728
Diffstat (limited to 'tests/specs/test/markdown_ts_expect_error')
-rw-r--r--tests/specs/test/markdown_ts_expect_error/__test__.jsonc5
-rw-r--r--tests/specs/test/markdown_ts_expect_error/main.md8
-rw-r--r--tests/specs/test/markdown_ts_expect_error/main.out6
3 files changed, 19 insertions, 0 deletions
diff --git a/tests/specs/test/markdown_ts_expect_error/__test__.jsonc b/tests/specs/test/markdown_ts_expect_error/__test__.jsonc
new file mode 100644
index 000000000..ad73f6df6
--- /dev/null
+++ b/tests/specs/test/markdown_ts_expect_error/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "test --doc main.md",
+ "exitCode": 0,
+ "output": "main.out"
+}
diff --git a/tests/specs/test/markdown_ts_expect_error/main.md b/tests/specs/test/markdown_ts_expect_error/main.md
new file mode 100644
index 000000000..9be70e919
--- /dev/null
+++ b/tests/specs/test/markdown_ts_expect_error/main.md
@@ -0,0 +1,8 @@
+# Documentation
+
+This test case checks if `@ts-expect-error` comment works as expected.
+
+```ts
+// @ts-expect-error
+const a: string = 42;
+```
diff --git a/tests/specs/test/markdown_ts_expect_error/main.out b/tests/specs/test/markdown_ts_expect_error/main.out
new file mode 100644
index 000000000..65990cd3f
--- /dev/null
+++ b/tests/specs/test/markdown_ts_expect_error/main.out
@@ -0,0 +1,6 @@
+Check [WILDCARD]/main.md$5-9.ts
+running 1 test from ./main.md$5-9.ts
+[WILDCARD]/main.md$5-9.ts ... ok ([WILDCARD]ms)
+
+ok | 1 passed | 0 failed ([WILDCARD]ms)
+