Skip to content

Provide option to disable test case printf truncation #2954

@jasperdunn

Description

@jasperdunn

Clear and concise description of the problem

As a developer using Vitest I want to be able to use test.each in a way that helps me to understand what tests are breaking without losing some of the description.

I am using test cases via test.each to reduce the amount of test boilerplate code.

However when using $description I am getting only a truncated version of the text, which doesn't help determine which test is breaking.

Each test case object has expected: ReturnType<Fn> and description: string properties;

describe('getTimelineRange', () => {
  test('throws error when there are no rows', () => {
    expect(() => getTimelineRange([])).toThrowError();
  });

  test.each(getTimelineRangeCases)('$description', ({rows, expected}) => {
    expect(getTimelineRange(rows)).toEqual(expected);
  });
});

I am getting this as my test output:

Screen Shot 2023-03-03 at 10 03 12 am

I'd prefer to get the full description, instead of a truncated version.

Suggested solution

Could a setting be exposed to disable or set the truncation size?

Alternative

For now I am considering either:

Prefixing a number
Screen Shot 2023-03-03 at 10 11 25 am

or

Returning the entire object as a string via %s -> test.each(getTimelineRangeCases)('%s', ({rows, expected}) => {
Screen Shot 2023-03-03 at 10 12 26 am

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions