- Failure is Feedback
- Posts
- ✅ Quick Tip: Just (JSDoc)Link It 🔗
✅ Quick Tip: Just (JSDoc)Link It 🔗

Every day, we rely on a simple bit of code where the results of any deploy hang in the balance:
The data-testid 🎉
And, while not everyone relies on the data-testid (I’m looking at you, MUI!), most developers and testers find it to be the bedrock of the automated test.
So, what happens if a change is made in a source file, and Cypress tests start to fail? Want to give yourself an extra edge on navigating straight to the file with the broken test(s)?
Introducing: JSDoc Links 🔗
You can use JSDoc links in any file, and using CMD + click, anyone in the code will be redirected straight to the related test file. 1
Let’s check it out.
TL;DR: Add a JSDoc link in your source file to link to the related test files.
If you haven’t already, install JSDoc in your project.
Determine which test file you want to link back to. What I do is search for the data-testid in the repository and see which files show up.

Once I’ve identified the source file, I add a commented section, outlining the test files that could be affected if any changes are made:
The linked file is noted here:
{@link file://./cypress/e2e/quick-tip/link-it.cy.ts}Then, I test the link by using the command key and clicking the mouse button at the same time. 🗒️ Important note: Hovering over the link and clicking “Follow link” will trigger this area.

Also, be sure you get the path set correctly in the linked file. Otherwise, you will get the same error. When using the CMD + click, you should be reidrected to the test file.
Check out the JSDoc link example on Github!
If everything else were that easy to find.
Till next week…

All my posts are free to read, and clicking subscribe will bring each post to your inbox. If my work brings you joy, and you’d like to support it, you can become a paid subscriber by clicking the button above. If a paid subscription is not your thing, you can support my caffeine addiction writing by clicking the button below! Thanks!
Written with floating in space — dreamcore sleep music playing in the background
1 Windows users, you would probably need to use CTRL + click. If I’m incorrect, let me know!
Reply