Skip to content

Conversation

@avivkeller
Copy link
Member

Description

I kept wondering why, whenever I attempted to mock these modules with node:test mocking, I would always get an error that they weren't defined. Then it hit me: next-router isn't defined, because we don't use it 🤦.

So, this PR removes the mock for next-router, and uses node:test for mocking next-intl.

Validation

All tests should pass

Related Issues

Ref: https://github.com/nodejs/nodejs.org/pull/7623/files#r2032206240

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run npm run format to ensure the code follows the style guide.
  • I have run npm run test to check if all tests are passing.
  • I have run npx turbo build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

Copilot AI review requested due to automatic review settings April 17, 2025 18:52
@avivkeller avivkeller requested a review from a team as a code owner April 17, 2025 18:52
@vercel
Copy link

vercel bot commented Apr 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Apr 17, 2025 6:52pm

Copy link
Contributor

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 cleans up the test harness by removing the unused mocks for next-router and next-intl and switching to using node:test's built-in mocking via t.module.mock. The changes include removing legacy mock files and loader modifications, and introducing a new setup.jsx file that sets up mocks for next-intl and next-intl/navigation.

Reviewed Changes

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

Show a summary per file
File Description
apps/site/tests/setup.mjs Removed the legacy setup that registered a custom module loader.
apps/site/tests/setup.jsx Added new mocking setup using node:test's t.module.mock for next-intl and its navigation.
apps/site/tests/mocks/next-router.mjs Removed the unused next-router mock.
apps/site/tests/mocks/next-intl.jsx Removed the legacy next-intl mock file.
apps/site/tests/loader.mjs Removed the custom module resolution hook, now unnecessary with t.module.mock.
Files not reviewed (1)
  • apps/site/package.json: Language not supported

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.61%. Comparing base (162cd26) to head (e81241f).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/site/tests/setup.jsx 96.42% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7660      +/-   ##
==========================================
+ Coverage   74.54%   74.61%   +0.06%     
==========================================
  Files          96       96              
  Lines        7673     7685      +12     
  Branches      194      192       -2     
==========================================
+ Hits         5720     5734      +14     
+ Misses       1951     1949       -2     
  Partials        2        2              

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@avivkeller avivkeller changed the title chore(test): use t.module.mock for mocking chore(test): use t.mock.module for mocking Apr 17, 2025
@ovflowd ovflowd added the fast-track Fast Tracking PRs label Apr 17, 2025
@ovflowd
Copy link
Member

ovflowd commented Apr 17, 2025

Feel free to fast-track this. Giving a 👍

@github-actions
Copy link
Contributor

github-actions bot commented Apr 17, 2025

Lighthouse Results

URL Performance Accessibility Best Practices SEO Report
/en 🟢 99 🟢 100 🟢 100 🟢 91 🔗
/en/about 🟢 100 🟢 100 🟢 100 🟢 91 🔗
/en/about/previous-releases 🟢 99 🟢 100 🟢 100 🟢 92 🔗
/en/download 🟢 99 🟢 100 🟢 100 🟢 91 🔗
/en/blog 🟢 100 🟢 100 🟢 96 🟢 92 🔗

@ovflowd ovflowd added the github_actions:pull-request Trigger Pull Request Checks label Apr 17, 2025
@ovflowd ovflowd enabled auto-merge April 17, 2025 19:20
@github-actions github-actions bot removed the github_actions:pull-request Trigger Pull Request Checks label Apr 17, 2025
@ovflowd ovflowd added this pull request to the merge queue Apr 17, 2025
Merged via the queue into main with commit c0d6b17 Apr 17, 2025
27 checks passed
@ovflowd ovflowd deleted the chore/better-mock branch April 17, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fast-track Fast Tracking PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants