Skip to content
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

doc(plugins): add help for type error about expect plugin #17

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

AlexandreGerault
Copy link

When installing japa from the doc instructions, it is not mentioned to include the bin folder, which can lead to a TypeScript error saying expect is not available in TestContext type. Some people who aren't used that much to TypeScript can take a while to figure out what they're missing.

🔗 Linked issue

This is somehow related to issue japa/expect#1

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 📄 Documentation

📚 Description

The point of this PR is just to add a small indication about including the bin folder in the tsconfig to avoid the type error

Property 'expect' does not exist on type 'TestContext'.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

When installing japa from the doc instructions, it is not mentioned to include the bin folder, which can lead to a TypeScript error saying expect is not available in TestContext type
@AlexandreGerault
Copy link
Author

Maybe it would be better to also include the exact error message for SEO purpose (when pasting the error right into your search engine)?

Property 'expect' does not exist on type 'TestContext'.

@AlexandreGerault
Copy link
Author

@RomainLanz any thought? :D

@thetutlage
Copy link
Contributor

Shouldn't the bin folder be included by default? Also, it seems more like a per-project TypeScript config detail more than Japa specific.

If my project does not include the root of the project inside the includes, then yes, I have to be aware of including the necessary folders and bin is one of them.

Also, the inclusion of bin is needed not just for Jest expect but for all other plugins too.

@AlexandreGerault
Copy link
Author

Shouldn't the bin folder be included by default?
Well I don't know, it should be for a bootstrapped Adonis project for example, as it has default architecture etc. But on a brand new TypeScript project, where you install Japa, I don't know if that's expected to include the bin folder by default.

You mean adding the bin folder to the include via the npm init @japa/latest?

I didn't try to install since January on a new TS project, so maybe it changed and is done now.

Also, it seems more like a per-project TypeScript config detail more than Japa specific.

Yes, but I would expect the doc to mention it in the install section of the Japa documentation, which might be more appropriate than this PR suggests (I can make a commit doing so if you will to). Are there cases where we do not want to include this folder (or test.ts file more specifically)?

If my project does not include the root of the project inside the includes, then yes, I have to be aware of including the necessary folders and bin is one of them.

In the end it might be a skill issue to look for what caused that error, and maybe no users have been bothered with it. I let you decide whether or not this should be added to documentation. I'm open to suggestions on what to add/edit/delete from the PR.

As said earlier, it might be more suitable to add this to the install section 🤷

Also, the inclusion of bin is needed not just for Jest expect but for all other plugins too.

I agree.

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