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

toMatch output is truncated #2791

Closed
6 tasks done
Shinigami92 opened this issue Feb 2, 2023 · 4 comments · Fixed by #3144
Closed
6 tasks done

toMatch output is truncated #2791

Shinigami92 opened this issue Feb 2, 2023 · 4 comments · Fixed by #3144
Labels
enhancement New feature or request

Comments

@Shinigami92
Copy link
Contributor

Describe the bug

While using e.g. toMatch the expected result is truncated even when setting outputTruncateLength to 1000

 FAIL  test/git.spec.ts > git > random seeded tests for seed 3694299162975756 > commitEntry > should return a valid random commitEntry
AssertionError: expected 'Author: Reynold71 <Reynold_Walsh57@ya…' to match /^Author: [\w_\. ]+ \<[\w\.]+@[\w\.]+\>$/
  test/git.spec.ts:62:30
     60|             expect(parts[5]).toMatch(/^\s{4}.+$/);
     61|           } else {
     62|             expect(parts[1]).toMatch(/^Author: [\w_\. ]+ \<[\w\.]+@[\w\.]+\>$/);
       |                              ^
     63|             expect(parts[2]).toMatch(/^Date: .+$/);
     64|             expect(parts[3]).toBe('');

It might be somewhat related to #2448
But there is no expected vs actual comparison/diff, so it's harder here to find the problem of the failing test

Reproduction

will add if really needed

System Info

System:
    OS: macOS 13.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 3.49 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.4.0 - ~/.nvm/versions/node/v18.4.0/bin/node
    npm: 8.12.1 - ~/.nvm/versions/node/v18.4.0/bin/npm
  Browsers:
    Chrome: 109.0.5414.119
    Safari: 16.2
  npmPackages:
    @vitest/coverage-c8: ~0.28.3 => 0.28.3 
    @vitest/ui: ~0.28.3 => 0.28.3 
    vite: ~4.0.4 => 4.0.4 
    vitest: ~0.28.3 => 0.28.3

Used Package Manager

pnpm

Validations

@sheremet-va
Copy link
Member

AssertionError is always truncated, it's meant to be a short message. You should see expected/actual for the diff.

@ST-DDT
Copy link
Contributor

ST-DDT commented Feb 2, 2023

As shown here it is not:

@sheremet-va
Copy link
Member

But I think you can change it with this code:

import { chai } from 'vitest'
chai.config.truncateThreshold = 100000

We might need to add to the config or reuse another truncate flag.

@Shinigami92
Copy link
Contributor Author

But I think you can change it with this code:

import { chai } from 'vitest'
chai.config.truncateThreshold = 100000

We might need to add to the config or reuse another truncate flag.

Yes, looks like this is working 👍

I still would love to have a vitest config pass-through option for that

Maybe even:

export default defineConfig({
  test: {
    coverage: {
      all: true,
      // ...
    },
    reporters: 'basic',
    // ...
    chaiConfig: {
      truncateThreshold: 10000,
    }
  },
});

@sheremet-va sheremet-va added the enhancement New feature or request label Mar 7, 2023
This was referenced Apr 6, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants