|
| 1 | +import { describe, expect, it } from 'vitest' |
| 2 | +import { runVitest } from '../../test-utils' |
| 3 | + |
| 4 | +describe('truncateThreshold', () => { |
| 5 | + it('default', async () => { |
| 6 | + const result = await runVitest({ |
| 7 | + root: 'fixtures/chai-config', |
| 8 | + reporters: ['tap-flat'], |
| 9 | + }) |
| 10 | + expect(cleanOutput(result.stdout)).toMatchInlineSnapshot(` |
| 11 | + "TAP version 13 |
| 12 | + 1..9 |
| 13 | + ok 1 - test-each-title.test.ts > '012345678901234567890123456789' (length = 30) |
| 14 | + ok 2 - test-each-title.test.ts > '0123456789012345678901234567890123456…' (length = 40) |
| 15 | + ok 3 - test-each-title.test.ts > '0123456789012345678901234567890123456…' (length = 50) |
| 16 | + ok 4 - test-each-title.test.ts > [ 'one', 'two', 'three' ] |
| 17 | + ok 5 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four' ] |
| 18 | + ok 6 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four', …(1) ] |
| 19 | + ok 7 - test-each-title.test.ts > { one: 1, two: 2, three: 3 } |
| 20 | + ok 8 - test-each-title.test.ts > { one: 1, two: 2, three: 3, four: 4 } |
| 21 | + ok 9 - test-each-title.test.ts > { one: 1, two: 2, three: 3, …(2) } |
| 22 | + " |
| 23 | + `) |
| 24 | + expect(result.exitCode).toBe(0) |
| 25 | + }) |
| 26 | + |
| 27 | + it('40', async () => { |
| 28 | + const result = await runVitest({ |
| 29 | + root: 'fixtures/chai-config', |
| 30 | + reporters: ['tap-flat'], |
| 31 | + chaiConfig: { |
| 32 | + truncateThreshold: 40, |
| 33 | + }, |
| 34 | + }) |
| 35 | + expect(cleanOutput(result.stdout)).toMatchInlineSnapshot(` |
| 36 | + "TAP version 13 |
| 37 | + 1..9 |
| 38 | + ok 1 - test-each-title.test.ts > '012345678901234567890123456789' (length = 30) |
| 39 | + ok 2 - test-each-title.test.ts > '0123456789012345678901234567890123456…' (length = 40) |
| 40 | + ok 3 - test-each-title.test.ts > '0123456789012345678901234567890123456…' (length = 50) |
| 41 | + ok 4 - test-each-title.test.ts > [ 'one', 'two', 'three' ] |
| 42 | + ok 5 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four' ] |
| 43 | + ok 6 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four', …(1) ] |
| 44 | + ok 7 - test-each-title.test.ts > { one: 1, two: 2, three: 3 } |
| 45 | + ok 8 - test-each-title.test.ts > { one: 1, two: 2, three: 3, four: 4 } |
| 46 | + ok 9 - test-each-title.test.ts > { one: 1, two: 2, three: 3, …(2) } |
| 47 | + " |
| 48 | + `) |
| 49 | + expect(result.exitCode).toBe(0) |
| 50 | + }) |
| 51 | + |
| 52 | + it('0', async () => { |
| 53 | + const result = await runVitest({ |
| 54 | + root: 'fixtures/chai-config', |
| 55 | + reporters: ['tap-flat'], |
| 56 | + chaiConfig: { |
| 57 | + truncateThreshold: 0, |
| 58 | + }, |
| 59 | + }) |
| 60 | + expect(cleanOutput(result.stdout)).toMatchInlineSnapshot(` |
| 61 | + "TAP version 13 |
| 62 | + 1..9 |
| 63 | + ok 1 - test-each-title.test.ts > '012345678901234567890123456789' (length = 30) |
| 64 | + ok 2 - test-each-title.test.ts > '0123456789012345678901234567890123456789' (length = 40) |
| 65 | + ok 3 - test-each-title.test.ts > '01234567890123456789012345678901234567890123456789' (length = 50) |
| 66 | + ok 4 - test-each-title.test.ts > [ 'one', 'two', 'three' ] |
| 67 | + ok 5 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four' ] |
| 68 | + ok 6 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four', 'five' ] |
| 69 | + ok 7 - test-each-title.test.ts > { one: 1, two: 2, three: 3 } |
| 70 | + ok 8 - test-each-title.test.ts > { one: 1, two: 2, three: 3, four: 4 } |
| 71 | + ok 9 - test-each-title.test.ts > { one: 1, two: 2, three: 3, four: 4, five: 5 } |
| 72 | + " |
| 73 | + `) |
| 74 | + expect(result.exitCode).toBe(0) |
| 75 | + }) |
| 76 | +}) |
| 77 | + |
| 78 | +function cleanOutput(output: string) { |
| 79 | + // remove non-deterministic output |
| 80 | + return output.replaceAll(/\s*# time=.*/g, '') |
| 81 | +} |
0 commit comments