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

[Bug]: GitHubActionsReporter reports error on wrong line #12906

Closed
rethab opened this issue Jun 3, 2022 · 6 comments
Closed

[Bug]: GitHubActionsReporter reports error on wrong line #12906

rethab opened this issue Jun 3, 2022 · 6 comments

Comments

@rethab
Copy link
Contributor

rethab commented Jun 3, 2022

Version

28.1.0

Steps to reproduce

  • Make sure you're using the new github-actions reporter
  • Create a failing test where two objects with a field created: Date are not equal
  • Create a PR on GitHub with this test failing

Expected behavior

I expect the annotation to be created on the line where the test failed, which should be based on the stack trace

Actual behavior

The GitHubActionReporter incorrectly takes parts of the date as the line number and then annotates a random line

Additional context

Repository to reproduce the problem: rethab/actions-test-repo#10

Consider this annotation:

image

  • The error should be reported on line 17, because that's the first stack frame
  • However, the annotation is created at line 2

--> The line two is clearly coming from the date. In fact it's the minute (I ran the test at 11:02). I have tested this by running it multiple times and it annotates the line based on when I run it
--> This might happen, because the reporter looks for the string at when trying to separate the stack from the message and finds it in created. Perhaps this regex is wrong? https://github.com/facebook/jest/blob/24e0472ac41ea03cdd89ffaea8c5f410ecf6054f/packages/jest-message-util/src/index.ts#L403

Environment

System:
    OS: macOS 12.3.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Binaries:
    Node: 16.13.2 - /usr/local/opt/node@16/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.2 - /usr/local/opt/node@16/bin/npm
  npmPackages:
    jest: ^28.1.0 => 28.1.0
@mrazauskas
Copy link
Contributor

mrazauskas commented Jun 3, 2022

Thanks for report.

The logic of github-actions reporter was reworked recently (see #12826), but it seems like this patch is not yet released. Might be that the issue is solved. Hm.. How to check this? I have to think a bit (;

@rethab
Copy link
Contributor Author

rethab commented Jun 3, 2022

No worries @mrazauskas I can just wait until #12826 is out and try again :)

@mrazauskas
Copy link
Contributor

mrazauskas commented Jun 7, 2022

Checked it.

Currently the reporter sends this to GitHub:

::error file=/path/to/test.js,line=41,col=55::<long-error-message-with-stack-trace>

On main branch (not yet released), raw error annotation from your example looks like this:

::error file=/path/to/test.js,line=15,title=test › which line is the error reported?::expect(received).toStrictEqual(expected) // deep equality%0A%0A- Expected  - 1%0A+ Received  + 1%0A%0A@@ -1,7 +1,7 @@%0A  Object {%0A-   "created": 2022-06-07T03:52:29.511Z,%0A+   "created": 2022-06-07T03:52:29.411Z,%0A    "environment": "production",%0A    "foo": "bar",%0A    "id": "12434-124455-114454",%0A    "owner": "rethab",%0A    "repo": "actions-test-repo",%0A%0A    at Object.toStrictEqual (test.js:15:15)

The line number is correct. The title is nicer and stack trace is minimal as well.

@SimenB
Copy link
Member

SimenB commented Jun 7, 2022

https://github.com/facebook/jest/releases/tag/v28.1.1

@rethab
Copy link
Contributor Author

rethab commented Jun 7, 2022

Nice, it now looks correct:

image

@rethab rethab closed this as completed Jun 7, 2022
@github-actions
Copy link

github-actions bot commented Jul 8, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants