Skip to content

Conversation

@Varadraj75
Copy link
Contributor

@Varadraj75 Varadraj75 commented Dec 31, 2025

Description

  • Replaced all @ts-ignore usages in test files with @ts-expect-error.
  • Added clear comments explaining why the TypeScript errors are intentionally expected in each test case.
  • Improved type safety and readability without changing any test logic or behavior.

Related issue(s)
Fixes #4797

Verification

  • Verified locally that no @ts-ignore usages remain (grep -R "@ts-ignore" tests).
  • All scripts and tests run successfully.
  • Application runs locally without issues.
Screenshot 2025-12-31 at 8 46 53 PM Screenshot 2025-12-31 at 8 48 07 PM Screenshot 2025-12-31 at 8 48 38 PM

Summary by CodeRabbit

  • Tests
    • Replaced TypeScript ignore directives with expect-error directives across multiple test suites.
    • These updates only change static type-checking annotations in tests; runtime behavior, control flow, and public API signatures remain unchanged.
    • No functional changes introduced; test expectations and outcomes remain the same.

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link

netlify bot commented Dec 31, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c8a1a31
🔍 Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/6955462c6f5453000851d8ae
😎 Deploy Preview https://deploy-preview-4825--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 31, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Replaced occurrences of // @ts-ignore with `// `@ts-expect-error across multiple test files (23 instances total). These are test-only TypeScript annotation updates; no runtime logic, exported signatures, or control flow were modified.

Changes

Cohort / File(s) Summary
Build / Post-processing Tests
tests/build-docs/addDocButtons.test.ts, tests/build-post-list.test.ts
Replaced // @ts-ignore with `// `@ts-expect-error in tests that intentionally pass invalid post/doc data (11 instances).
Dashboard Tests
tests/dashboard/build-dashboard.test.ts
Switched // @ts-ignore to `// `@ts-expect-error in tests for write failures and missing env vars (3 instances).
Markdown & Tooling Tests
tests/markdown/check-markdown.test.ts, tests/tools/combine-tools.test.ts, tests/tools/tools-object.test.ts
Replaced // @ts-ignore with `// `@ts-expect-error in tests covering invalid frontmatter, missing properties, and malformed tool data (9 instances).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nibble code and tidy cheer,
Swapping ignores so errors appear.
Tests now shout if hush was wrong,
I hop, I tweak, I sing this song.
Tiny paws for type-safety here.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: replacing @ts-ignore with @ts-expect-error across test files for improved type safety.
Linked Issues check ✅ Passed The PR fully implements all requirements from issue #4797: all 23 @ts-ignore instances replaced with @ts-expect-error across the 6 specified files with descriptive comments explaining the intentional type violations.
Out of Scope Changes check ✅ Passed All changes are strictly within scope—only test files modified to replace @ts-ignore with @ts-expect-error; no unrelated code alterations or functional changes introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b50fdf and c8a1a31.

📒 Files selected for processing (1)
  • tests/tools/tools-object.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/tools/tools-object.test.ts
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: cypress-run
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
  • GitHub Check: Test NodeJS PR - macos-latest
  • GitHub Check: Test NodeJS PR - windows-latest

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Varadraj75
Copy link
Contributor Author

hey @princerajpoot20 @anshgoyalevil , please review and merge the pr

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors test files to replace @ts-ignore directives with @ts-expect-error for better type safety. The change ensures that TypeScript will error if the suppressed type error is fixed, preventing outdated suppressions from lingering in the codebase. Each replacement includes an explanatory comment describing why the type error is expected.

Key changes:

  • Replaced all 21 occurrences of @ts-ignore with @ts-expect-error across 6 test files
  • Added descriptive comments explaining the intentional type violations being tested

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/tools/tools-object.test.ts Updated 4 type suppressions for testing wrong data types, unknown categories, and malformed YAML
tests/tools/combine-tools.test.ts Updated 1 type suppression for testing missing required properties
tests/markdown/check-markdown.test.ts Updated 4 type suppressions for testing invalid and missing frontmatter scenarios
tests/dashboard/build-dashboard.test.ts Updated 3 type suppressions for testing missing function arguments and environment variables
tests/build-post-list.test.ts Updated 8 type suppressions for testing undefined parameters and invalid input types
tests/build-docs/addDocButtons.test.ts Updated 1 type suppression for testing invalid tree posts parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2747eba) to head (c8a1a31).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #4825   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines          798       798           
  Branches       146       146           
=========================================
  Hits           798       798           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Varadraj75 and others added 2 commits December 31, 2025 21:05
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Dec 31, 2025

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 51
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-4825--asyncapi-website.netlify.app/

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/markdown/check-markdown.test.ts (1)

177-178: Consider clarifying the comment.

The comment says "simulating valid frontmatter" but the test passes undefined to validateBlogs and expects the error "Frontmatter is missing". Consider updating the comment to "simulating missing frontmatter" or "testing undefined frontmatter" for clarity.

🔎 Suggested comment update
-    // @ts-expect-error – simulating valid frontmatter
+    // @ts-expect-error – testing undefined frontmatter
     const errors = validateBlogs(undefined);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2747eba and b5f1c2d.

📒 Files selected for processing (6)
  • tests/build-docs/addDocButtons.test.ts
  • tests/build-post-list.test.ts
  • tests/dashboard/build-dashboard.test.ts
  • tests/markdown/check-markdown.test.ts
  • tests/tools/combine-tools.test.ts
  • tests/tools/tools-object.test.ts
🧰 Additional context used
🧠 Learnings (19)
📓 Common learnings
Learnt from: akshatnema
Repo: asyncapi/website PR: 3423
File: tests/index.test.js:2-7
Timestamp: 2025-01-18T08:44:43.614Z
Learning: In JavaScript test files within the AsyncAPI website project, TypeScript file imports must include the .ts extension to avoid lint errors, even though the files being imported are JavaScript files.
Learnt from: akshatnema
Repo: asyncapi/website PR: 3423
File: tests/index.test.js:2-7
Timestamp: 2025-01-18T08:44:43.614Z
Learning: In the AsyncAPI website project, JavaScript test files must include the .ts extension when importing TypeScript files (e.g., `require('../scripts/build-rss.ts')`). This is enforced by the project's configuration which uses `moduleResolution: "bundler"` in tsconfig.json and TypeScript-aware ESLint plugins. The .ts extensions are required even though the files are imported using CommonJS require statements.
Learnt from: anshgoyalevil
Repo: asyncapi/website PR: 3950
File: scripts/utils/check-locales.ts:138-143
Timestamp: 2025-03-23T12:42:49.503Z
Learning: For the locale validation function in check-locales.ts, the team has decided that modifying the outer scope variable 'hasErrors' inside the forEach loop is acceptable despite the ESLint warning about unsafe references in loop functions.
Learnt from: akshatnema
Repo: asyncapi/website PR: 3423
File: tests/index.test.js:2-7
Timestamp: 2025-01-18T08:44:43.614Z
Learning: In the AsyncAPI website project, JavaScript test files must include the .ts extension when importing TypeScript files (e.g., `require('../scripts/build-rss.ts')`). This is a project-specific requirement enforced by the linting rules and build setup, even though it differs from typical Node.js behavior.
📚 Learning: 2024-11-10T18:16:35.551Z
Learnt from: vishvamsinh28
Repo: asyncapi/website PR: 3284
File: scripts/build-post-list.js:28-46
Timestamp: 2024-11-10T18:16:35.551Z
Learning: In the `scripts/build-post-list.js` JavaScript file, tests rely on the `result` object being a global variable. Moving it inside the `buildPostList` function causes tests to fail; therefore, keep `result` as a global variable.

Applied to files:

  • tests/build-post-list.test.ts
📚 Learning: 2024-11-01T09:55:20.531Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3101
File: tests/build-rss.test.js:25-27
Timestamp: 2024-11-01T09:55:20.531Z
Learning: In `tests/build-rss.test.js`, replacing `jest.resetModules()` with `jest.resetAllMocks()` in the `afterEach()` block causes errors. It is necessary to use `jest.resetModules()` to reset the module registry between tests in this file.

Applied to files:

  • tests/build-post-list.test.ts
📚 Learning: 2024-11-10T18:16:22.273Z
Learnt from: vishvamsinh28
Repo: asyncapi/website PR: 3284
File: scripts/build-post-list.js:49-53
Timestamp: 2024-11-10T18:16:22.273Z
Learning: In `scripts/build-post-list.js`, the `walkDirectories` function depends on sequential execution because it mutates `resultObj`. Parallelizing the loop with `Promise.all` causes tests to fail.

Applied to files:

  • tests/build-post-list.test.ts
📚 Learning: 2025-01-18T08:44:43.614Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3423
File: tests/index.test.js:2-7
Timestamp: 2025-01-18T08:44:43.614Z
Learning: In the AsyncAPI website project, JavaScript test files must include the .ts extension when importing TypeScript files (e.g., `require('../scripts/build-rss.ts')`). This is a project-specific requirement enforced by the linting rules and build setup, even though it differs from typical Node.js behavior.

Applied to files:

  • tests/build-post-list.test.ts
  • tests/tools/combine-tools.test.ts
  • tests/dashboard/build-dashboard.test.ts
  • tests/tools/tools-object.test.ts
  • tests/markdown/check-markdown.test.ts
  • tests/build-docs/addDocButtons.test.ts
📚 Learning: 2024-11-01T13:32:15.472Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3101
File: tests/fixtures/rssData.js:1-57
Timestamp: 2024-11-01T13:32:15.472Z
Learning: In the `tests/fixtures/rssData.js` file of the `asyncapi/website` project, tests for edge cases such as empty strings for title or excerpt, very long text content, international characters (UTF-8), or malformed URLs in `slug` or `cover` are not necessary because these cases will not occur.

Applied to files:

  • tests/build-post-list.test.ts
  • tests/tools/tools-object.test.ts
  • tests/markdown/check-markdown.test.ts
📚 Learning: 2025-02-16T12:57:24.575Z
Learnt from: anshgoyalevil
Repo: asyncapi/website PR: 0
File: :0-0
Timestamp: 2025-02-16T12:57:24.575Z
Learning: Tests failing after dependency upgrades indicate potential breaking changes and might require code changes rather than test modifications to support newer versions.

Applied to files:

  • tests/build-post-list.test.ts
  • tests/tools/combine-tools.test.ts
  • tests/dashboard/build-dashboard.test.ts
📚 Learning: 2025-01-18T08:44:43.614Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3423
File: tests/index.test.js:2-7
Timestamp: 2025-01-18T08:44:43.614Z
Learning: In the AsyncAPI website project, JavaScript test files must include the .ts extension when importing TypeScript files (e.g., `require('../scripts/build-rss.ts')`). This is enforced by the project's configuration which uses `moduleResolution: "bundler"` in tsconfig.json and TypeScript-aware ESLint plugins. The .ts extensions are required even though the files are imported using CommonJS require statements.

Applied to files:

  • tests/build-post-list.test.ts
  • tests/tools/combine-tools.test.ts
  • tests/dashboard/build-dashboard.test.ts
  • tests/tools/tools-object.test.ts
  • tests/markdown/check-markdown.test.ts
📚 Learning: 2025-01-18T08:44:43.614Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3423
File: tests/index.test.js:2-7
Timestamp: 2025-01-18T08:44:43.614Z
Learning: In JavaScript test files within the AsyncAPI website project, TypeScript file imports must include the .ts extension to avoid lint errors, even though the files being imported are JavaScript files.

Applied to files:

  • tests/build-post-list.test.ts
  • tests/tools/combine-tools.test.ts
  • tests/dashboard/build-dashboard.test.ts
  • tests/tools/tools-object.test.ts
  • tests/markdown/check-markdown.test.ts
📚 Learning: 2024-11-29T17:36:09.783Z
Learnt from: vishvamsinh28
Repo: asyncapi/website PR: 3378
File: tests/markdown/check-markdown.test.js:133-138
Timestamp: 2024-11-29T17:36:09.783Z
Learning: When testing the 'main' function in 'check-markdown.test.js', it's acceptable to simply ensure it doesn't throw any errors, as the functions it calls are already tested elsewhere.

Applied to files:

  • tests/build-post-list.test.ts
  • tests/tools/combine-tools.test.ts
  • tests/dashboard/build-dashboard.test.ts
  • tests/tools/tools-object.test.ts
  • tests/markdown/check-markdown.test.ts
📚 Learning: 2025-01-19T04:51:41.255Z
Learnt from: anshgoyalevil
Repo: asyncapi/website PR: 3557
File: tests/fixtures/markdown/check-edit-links-data.js:3-11
Timestamp: 2025-01-19T04:51:41.255Z
Learning: In the AsyncAPI website repository, the test data in `tests/fixtures/markdown/check-edit-links-data.js` intentionally includes inconsistent paths (with and without 'docs' prefix) to verify the script's ability to normalize and handle ambiguous path structures.

Applied to files:

  • tests/build-post-list.test.ts
  • tests/dashboard/build-dashboard.test.ts
  • tests/markdown/check-markdown.test.ts
  • tests/build-docs/addDocButtons.test.ts
📚 Learning: 2024-11-29T19:42:31.175Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3265
File: scripts/tools/tools-object.js:93-98
Timestamp: 2024-11-29T19:42:31.175Z
Learning: In `scripts/tools/tools-object.js`, when validation fails in the `convertTools` function, errors should be thrown or rejected instead of only logging them, to ensure proper error propagation and handling.

Applied to files:

  • tests/tools/combine-tools.test.ts
  • tests/tools/tools-object.test.ts
📚 Learning: 2024-11-01T12:49:32.805Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3136
File: scripts/tools/combine-tools.js:122-125
Timestamp: 2024-11-01T12:49:32.805Z
Learning: In `scripts/tools/combine-tools.js`, the existing URL parsing logic for `repoUrl` without additional error handling is acceptable and does not require changes.

Applied to files:

  • tests/tools/combine-tools.test.ts
📚 Learning: 2024-12-02T05:52:49.547Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3265
File: tests/helper/toolsObjectData.js:1-18
Timestamp: 2024-12-02T05:52:49.547Z
Learning: In `tests/helper/toolsObjectData.js`, using the hard-coded repository ID directly in the URL is acceptable when creating mock data for tests, as we are not asserting anything at `REPO_ID`.

Applied to files:

  • tests/tools/tools-object.test.ts
📚 Learning: 2024-11-25T18:34:51.303Z
Learnt from: akshatnema
Repo: asyncapi/website PR: 3378
File: scripts/markdown/check-markdown.js:1-1
Timestamp: 2024-11-25T18:34:51.303Z
Learning: When reviewing `scripts/markdown/check-markdown.js`, optimizations should be addressed in separate issues and not included in the current pull request.

Applied to files:

  • tests/markdown/check-markdown.test.ts
📚 Learning: 2024-10-18T17:24:45.053Z
Learnt from: anshgoyalevil
Repo: asyncapi/website PR: 3301
File: scripts/markdown/check-markdown.js:0-0
Timestamp: 2024-10-18T17:24:45.053Z
Learning: In `scripts/markdown/check-markdown.js`, the script is not run in an asynchronous environment, so refactoring it to use `async/await` is unnecessary.

Applied to files:

  • tests/markdown/check-markdown.test.ts
📚 Learning: 2024-12-30T11:00:42.064Z
Learnt from: JeelRajodiya
Repo: asyncapi/website PR: 3423
File: jest.config.cjs:6-7
Timestamp: 2024-12-30T11:00:42.064Z
Learning: The user only wants coverage for scripts, not for .tsx files, because the existing tests are focused on scripts.

Applied to files:

  • tests/markdown/check-markdown.test.ts
📚 Learning: 2024-10-18T17:37:50.602Z
Learnt from: anshgoyalevil
Repo: asyncapi/website PR: 3301
File: scripts/markdown/check-markdown.js:31-31
Timestamp: 2024-10-18T17:37:50.602Z
Learning: In `scripts/markdown/check-markdown.js`, the `frontmatter` object cannot have a property named `hasOwnProperty`, so using `frontmatter.hasOwnProperty(attr)` is acceptable.

Applied to files:

  • tests/markdown/check-markdown.test.ts
📚 Learning: 2025-04-20T16:05:16.482Z
Learnt from: anshgoyalevil
Repo: asyncapi/website PR: 3950
File: scripts/utils/check-locales.ts:122-129
Timestamp: 2025-04-20T16:05:16.482Z
Learning: In the AsyncAPI website project, Next.js throws errors at runtime when locale files are missing, making additional validation for missing files unnecessary in the check-locales script.

Applied to files:

  • tests/markdown/check-markdown.test.ts
🧬 Code graph analysis (2)
tests/build-post-list.test.ts (1)
scripts/build-post-list.ts (3)
  • buildPostList (288-314)
  • addItem (74-90)
  • slugifyToC (39-51)
tests/dashboard/build-dashboard.test.ts (1)
scripts/dashboard/build-dashboard.ts (2)
  • writeToFile (329-329)
  • getDiscussionByID (322-322)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
  • GitHub Check: cypress-run
  • GitHub Check: Test NodeJS PR - windows-latest
  • GitHub Check: Test NodeJS PR - macos-latest
  • GitHub Check: Lighthouse CI
🔇 Additional comments (7)
tests/build-post-list.test.ts (1)

203-298: LGTM! Type safety improvements applied consistently.

The replacements of @ts-ignore with @ts-expect-error throughout this file are appropriate. The descriptive comments clearly explain why each type error is intentionally expected (testing invalid parameters, type violations, etc.). This change will cause TypeScript to fail if any of these errors no longer exist, making the suppressions more maintainable.

tests/build-docs/addDocButtons.test.ts (1)

84-84: LGTM! Improved type safety directive.

The replacement is appropriate and the comment clearly explains that this test intentionally passes an invalid data structure to verify error handling.

tests/tools/combine-tools.test.ts (1)

290-290: LGTM! Type safety improvement for missing properties test.

The replacement is appropriate and the comment clearly explains that this test intentionally passes tools without required properties to verify error handling.

tests/tools/tools-object.test.ts (1)

76-175: LGTM! Type safety improvements applied consistently.

All four replacements of @ts-ignore with @ts-expect-error are appropriate. The descriptive comments clearly explain the test scenarios: testing wrong data types, unknown categories, and malformed JSON handling. This ensures TypeScript will fail if these intentional errors no longer exist.

tests/markdown/check-markdown.test.ts (2)

59-86: LGTM! Type safety improvements for invalid frontmatter tests.

The replacements are appropriate and comments clearly explain that these tests simulate invalid or missing frontmatter scenarios.


185-185: LGTM! Type safety improvement for valid frontmatter test.

The replacement is appropriate. The comment accurately describes that this tests valid frontmatter (ensuring no errors are returned).

tests/dashboard/build-dashboard.test.ts (1)

262-273: LGTM! Type safety improvements for error handling tests.

All three replacements of @ts-ignore with @ts-expect-error are appropriate. The descriptive comments clearly explain the test scenarios: intentionally triggering write failures and testing missing environment variables. This ensures TypeScript will fail if these intentional errors no longer exist.

@singhaditya73
Copy link
Contributor

Hi @Varadraj75,
I created this issue (#4797), asked the maintainer for assignment, and was officially assigned to work on it.
I also informed you in the issue discussion that I was actively working on this, but you still submitted this PR.

I have submitted my PR #4826
Please Check issue assignments before submitting PRs to avoid duplicate work.
cc @princerajpoot20 @anshgoyalevil

@princerajpoot20
Copy link
Member

closing in support of #4825 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚧 refactor(tests): replace @ts-ignore with @ts-expect-error for improved type safety

4 participants