Skip to content

Conversation

@9aoy
Copy link
Contributor

@9aoy 9aoy commented Sep 29, 2025

Summary

add hint message for some known errors.

jest is not defined error

before:
img_v3_02qj_f812f1ed-0ed1-44b3-9b55-75016c3b290g

after:
image

expect is not defined error

before:
img_v3_02qj_06bcec3b-bc4b-4e35-be97-ea3e5f2c1eeg

after:
image

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings September 29, 2025 09:02
@netlify
Copy link

netlify bot commented Sep 29, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 7a91f1d
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/68da4c69e997130008a8cd0f
😎 Deploy Preview https://deploy-preview-608--rstest-dev.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.

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 adds helpful hint messages to improve developer experience when encountering common "not defined" errors in the testing framework. It provides specific guidance for jest is not defined and other global API undefined errors.

  • Replaces generic "jest is not defined" error with a hint suggesting to use "rstest" instead
  • Adds hints for undefined global APIs, suggesting to enable "globals" configuration
  • Imports the globalApis utility to check if undefined variables are known global APIs

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

'jest is not defined',
'jest is not defined, did you mean rstest?',
);
} else if (error.message.includes('is not defined')) {
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

This condition will match the 'jest is not defined' case that was already handled above, making the specific jest check redundant. Consider changing this to check for variables other than 'jest' or restructure the logic to avoid overlap.

Copilot uses AI. Check for mistakes.
const varName = match[1];
if (
varName &&
globalApis.includes(varName as (typeof globalApis)[number])
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The type assertion as (typeof globalApis)[number] is unnecessary since includes() accepts any value and performs the type check internally. Simply use globalApis.includes(varName) for cleaner code.

Suggested change
globalApis.includes(varName as (typeof globalApis)[number])
globalApis.includes(varName)

Copilot uses AI. Check for mistakes.
@9aoy 9aoy merged commit f063dab into main Sep 29, 2025
17 checks passed
@9aoy 9aoy deleted the error-hint branch September 29, 2025 09:32
@9aoy 9aoy mentioned this pull request Sep 30, 2025
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.

2 participants