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

FR: clicking on a failed test should open the failed test to that line in the editor #184

Open
gregveres opened this issue Feb 9, 2020 · 6 comments

Comments

@gregveres
Copy link
Contributor

Is this a bug report or a feature request?

feature request

Version Info

  • Version of Majestic: latest
  • Version of Jest: 25
  • Version of Node:
  • Operating System: Windows

Reproduction Repo

When a test fails, Jest is really good at spitting out the line of the assertion that failed. It would be nice if you could click on the div for that failed test and have it open the test file to the line of the failed assertion.

This is a little nicer than the open in editor button in the summary because it will take you directly to the failed assertion without having to eyeball the line number in the failure message and then jumping to that line number. I know that VS Code for instance will open directly to a line number because I have seen other packages do this.

@gregveres
Copy link
Contributor Author

I think I know what to do in order to implement this.
I can use the OPEN_IN_EDITOR mutation as a template. It turns out that VSCode opens a file to the line and column you specify if you specify them as :line_number:column_number after the file name.

The only tricky bit will be extracting the file name from the error text. I think that can happen on the server side code. We can send the failure string to the new mutation rather than the path string. Then the server code can do its magic at extracting the first file it finds from the error string and then launches the editor the same way OPEN_IN_EDITOR does uses the file location string from the error message.

I will work on this once the collabsible UI pr has been merged in because it will conflict with those changes if I do it now.

@gregveres
Copy link
Contributor Author

I have a PR ready to be submitted for this FR. I will submit it when the collapsable ui PR is accepted or rejected.

@gregveres
Copy link
Contributor Author

Anybody who is interested in this feature can use my fork. I have updated my fork to the latest version (1.7.0)

@davidlukerice
Copy link

Is there a way from preventing this behavior when highlighting text? I'm often wanting to copy different sections of the error or test or just highlight pieces while thinking and am finding myself constantly being kicked back into vscode unintentionally.

@duykhoa
Copy link

duykhoa commented Dec 22, 2021

In my case, it opens multiple Vim processes and consumes over 80% of CPU. Is there a way to disable this feature?

@sagarpanchal
Copy link

sagarpanchal commented Dec 12, 2023

Solve this by using cross-env

{
  ...
  "scripts": {
    ...
    "test:ui": "cross-env EDITOR=code majestic"
  },
  ...
}

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

No branches or pull requests

4 participants