-
-
Couldn't load subscription status.
- Fork 11
chore: add hint message for some known errors #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this 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
globalApisutility 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.
packages/core/src/utils/error.ts
Outdated
| 'jest is not defined', | ||
| 'jest is not defined, did you mean rstest?', | ||
| ); | ||
| } else if (error.message.includes('is not defined')) { |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
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.
packages/core/src/utils/error.ts
Outdated
| const varName = match[1]; | ||
| if ( | ||
| varName && | ||
| globalApis.includes(varName as (typeof globalApis)[number]) |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
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.
| globalApis.includes(varName as (typeof globalApis)[number]) | |
| globalApis.includes(varName) |
Summary
add hint message for some known errors.
jest is not definederrorbefore:

after:

expect is not definederrorbefore:

after:

Related Links
Checklist