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

Context buttons at wrong line when returning Promise from test #464

Closed
4 tasks done
rafagsiqueira opened this issue Sep 5, 2024 · 9 comments
Closed
4 tasks done

Comments

@rafagsiqueira
Copy link

rafagsiqueira commented Sep 5, 2024

Describe the bug

Screenshot 2024-09-05 at 8 59 05 AM

As shown on the screenshot, the context button (for running the test from the test file) and error messages (from failed expects) is shown at the wrong line, whenever a test returns a Promise.

Reproduction

Test case with the following syntax:

it('just a test', ({expect}) => new Promise<void>((resolve, reject) => {
 resolve();
}

Output

[8:58:59 AM] Marking "just an asynchronous test" as running
[8:59:00 AM] Marking "just an asynchronous test" as passed
[8:59:00 AM] Ending test run projects/etips-utils/search/src/pochettes.service.spec.ts

Version

v1.2.1

Validations

@sheremet-va
Copy link
Member

Thank you for your answer @andersonsilva87. Would you care to explain the solution instead of sending a zip file? Unfortunately it looks too suspicious.

It is a malicious bot. Please, do not install anything from there.

@sheremet-va
Copy link
Member

Output

This is not the full output. Please, provide the full output.

@rafagsiqueira
Copy link
Author

@sheremet-va I reported the bot already.
Please see full output below:

[INFO 9:49:54 AM] Running 1 file(s) with name pattern: ^\s?ActionsService just an asynchronous test$
[9:49:54 AM] The runner is starting because tests /Users/rafael/Work/etips/projects/etips-utils/search/src/actions.service.spec.ts were started due to a file change
[9:49:54 AM] Enqueuing "just an asynchronous test
[9:49:55 AM] Marking "should be created" as skipped during collection
[9:49:55 AM] No task result for "just an asynchronous test", assuming the test just started running
[9:49:55 AM] Marking "should load action" as skipped during collection
[9:49:55 AM] Marking "should search actions by month and year of registration" as skipped during collection
[9:49:55 AM] Marking "should search actions by submitter code" as skipped during collection
[9:49:55 AM] Marking "should search actions by participant code" as skipped during collection
[9:49:55 AM] Marking "should search actions by registration number" as skipped during collection
[9:49:55 AM] Marking "should search actions by status" as skipped during collection
[9:49:55 AM] Marking "just an asynchronous test" as running
[9:49:56 AM] Marking "just an asynchronous test" as passed
[9:49:56 AM] Ending test run projects/etips-utils/search/src/actions.service.spec.ts

@rafagsiqueira
Copy link
Author

@sheremet-va I realized the minimal repro I sent is not enough. I am trying to reproduce the issue with a new test spec, but couldn't find yet what triggers the unexpected behavior. Will revert back when I find out.

@rafagsiqueira
Copy link
Author

I thought removing annotations from test files fixed it, but I can still see instances where the context buttons are in the wrong line of the tests. Still trying to understand what triggers the bug.

@sheremet-va
Copy link
Member

Maybe you are using a plugin that produces incorrect source maps. Do you see the error column and line correctly when the test fails in the terminal?

Copy link

github-actions bot commented Sep 8, 2024

Hello @rafagsiqueira. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@rafagsiqueira
Copy link
Author

@sheremet-va It's an angular application, and it uses @analogjs/vitest-angular:test as the builder.

"test": {
          "builder": "@analogjs/vitest-angular:test",
          "options": {
            "tsConfig": "tsconfig.spec.json",
            "config": "vitest.config.mjs"
          }
        },

Do you think that might be the culprit?
The following test seems to be a minimal reproduction:

import { describe, it } from 'vitest';

describe('ActionsService', () => {

  it('should be created', ({ expect }) => {
    expect(true).toBeTruthy();
  });

  // it('should load action', ({ expect }) => new Promise<void>((resolve, reject) => {
  //   const actionId = '932B0131-29BD-50C0-BB95-0011A8614E71';
  //   const actionGQL = TestBed.inject(ActionGQL);
  // }));

  it('should fail', ({ expect }) => new Promise<void>((resolve, reject) => {
    expect(false).toBeTruthy();
  }));
});

Adding comments to the test seems to do the trick.

@rafagsiqueira
Copy link
Author

@sheremet-va found an open issue in their project: analogjs/analog#1211

@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2024
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
@sheremet-va @rafagsiqueira and others