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

Test Case name not fully displaying when space is available #368

Closed
4 tasks done
charlieforward9 opened this issue May 1, 2024 · 17 comments
Closed
4 tasks done

Test Case name not fully displaying when space is available #368

charlieforward9 opened this issue May 1, 2024 · 17 comments

Comments

@charlieforward9
Copy link

charlieforward9 commented May 1, 2024

Describe the bug

When I drag the Navigation Bar out to show more text within the test cases, I see the ellipses. This should show the entire test name.

Screenshot 2024-05-01 at 12 57 52 AM

Reproduction

describe("This is a really long test name that will surpass the length of the VSCode Testing navigator display", () => {
  it("should not show all of this text in the VSCode Testing navigator display because of a Vitest limitation", () => {
     expect(testDescriptorSizeLimit).toBe(undefined);
  });
});

Output

A view similar to the one above with two test items showing something like this

This is a really long test name tha...
   should not show all of this text in...

Version

v0.8.6

Validations

Tasks

No tasks being tracked yet.
@sheremet-va
Copy link
Member

sheremet-va commented May 1, 2024

This is how names are reported by Vitest, so they are generated by someone like this.

Copy link

github-actions bot commented May 1, 2024

Hello @charlieforward9. 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.

@charlieforward9
Copy link
Author

charlieforward9 commented May 2, 2024

@sheremet-va thank you for the response.
Is it possible to change this in Vitest, it would be helpful to see the full string in the navigation bar if it were dragged to the respective width.

UPDATE: A reproduction was added to the original Issue description.

@sheremet-va
Copy link
Member

sheremet-va commented May 2, 2024

Is it possible to change this in Vitest, it would be helpful to see the full string in the navigation bar if it were dragged to the respective width.

Vitest doesn't do anything with the name. This is something done by an external tool before the extension receives the data. I cannot reproduce it with your reproduction:

Screenshot 2024-05-02 at 10 29 05

You can also see that there is no ' symbol which further proves that the name was truncated by someone else. Vitest never stringifies it.

@charlieforward9
Copy link
Author

Im sorry, it seems I misunderstood what you originally said. This seems to be an issue with the vitest-cucumber plugin, or something else I am depending on. Thank you for clarifying.

@charlieforward9 charlieforward9 closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
@sheremet-va
Copy link
Member

I managed to reproduce it with this code:

  it.each([{ key: 'should not show all of this text in the VSCode Testing navigator display because of a Vitest limitation' }])("$key", () => {
     expect(undefined).toBe(undefined);
  });

Vitest doesn't expect the full names to be used as properties there as they are treated a bit differently that if it was %s for example (which will just be replaced) - it also intentionally puts ' to signal it as a string. Adding truncateTreshold should help:

export default defineConfig({
  test: {
    chaiConfig: {
      truncateThreshold: Infinity,
    }
  },
})

But I would change how the tests are generated on cucumber side.

@charlieforward9
Copy link
Author

charlieforward9 commented May 2, 2024

@sheremet-va Thank you for the details. I will see about contributing these findings to give back to the community after getting so much support!

@charlieforward9
Copy link
Author

amiceli/vitest-cucumber#72 is addressing this issue.

@amiceli
Copy link

amiceli commented May 3, 2024

I've improved tests title in vitest-cucumber, long title are more legible now.
@sheremet-va tests are sorted alphabetically ?
For example When is before Then.

image

@charlieforward9
Copy link
Author

I see this in my own code as well. Changing this to Sort by location does not fix it either.

Screenshot 2024-05-06 at 12 30 56 PM

@sheremet-va
Copy link
Member

sheremet-va commented May 7, 2024

I need any kind of reproduction that uses vitest-cucumber. From what I remember, the extension sorts by location by default.

Ideally, for frameworks built on top of Vitest, I would recommend using suite.task method to define your own tasks.

Copy link

github-actions bot commented May 8, 2024

Hello @charlieforward9. 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.

@amiceli
Copy link

amiceli commented May 9, 2024

I'm creating an example repository.
I finish it and give you its link.

@amiceli
Copy link

amiceli commented May 9, 2024

@sheremet-va You can check vitest-cucumber-example project.
When I use vitest on vscode, I see Then before When for example ;).

Say me if you need more examples inside this project.

@sheremet-va
Copy link
Member

It doesn't have information about the location (you would've seen the green arrow in this case), so it's sorted by default. I don't think this is the extension's fault.

I will fix the sorting by modifying the sortText string, but I would recommend using the official custom API for this instead of wrapping test function.

@sheremet-va
Copy link
Member

Fixed by f282283

@amiceli
Copy link

amiceli commented May 9, 2024

@sheremet-va Yes, it works on example projet ;).

@github-actions github-actions bot locked and limited conversation to collaborators May 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