-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(utils): fix
objDisplay
default truncate option for test.each
…
…title (#4917)
- Loading branch information
Showing
4 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
test.each` | ||
length | param | ||
${30} | ${'0123456789'.repeat(3)} | ||
${40} | ${'0123456789'.repeat(4)} | ||
${50} | ${'0123456789'.repeat(5)} | ||
`('$param (length = $length)', () => {}); | ||
|
||
test.each` | ||
param | ||
${['one', 'two', 'three']} | ||
${['one', 'two', 'three', 'four']} | ||
${['one', 'two', 'three', 'four', 'five']} | ||
`('$param', () => {}); | ||
|
||
test.each` | ||
param | ||
${{ one: 1, two: 2, three: 3 }} | ||
${{ one: 1, two: 2, three: 3, four: 4 }} | ||
${{ one: 1, two: 2, three: 3, four: 4, five: 5 }} | ||
`('$param', () => {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { runVitest } from '../../test-utils' | ||
|
||
describe('truncateThreshold', () => { | ||
it('default', async () => { | ||
const result = await runVitest({ | ||
root: 'fixtures/chai-config', | ||
reporters: ['tap-flat'], | ||
}) | ||
expect(cleanOutput(result.stdout)).toMatchInlineSnapshot(` | ||
"TAP version 13 | ||
1..9 | ||
ok 1 - test-each-title.test.ts > '012345678901234567890123456789' (length = 30) | ||
ok 2 - test-each-title.test.ts > '0123456789012345678901234567890123456…' (length = 40) | ||
ok 3 - test-each-title.test.ts > '0123456789012345678901234567890123456…' (length = 50) | ||
ok 4 - test-each-title.test.ts > [ 'one', 'two', 'three' ] | ||
ok 5 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four' ] | ||
ok 6 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four', …(1) ] | ||
ok 7 - test-each-title.test.ts > { one: 1, two: 2, three: 3 } | ||
ok 8 - test-each-title.test.ts > { one: 1, two: 2, three: 3, four: 4 } | ||
ok 9 - test-each-title.test.ts > { one: 1, two: 2, three: 3, …(2) } | ||
" | ||
`) | ||
expect(result.exitCode).toBe(0) | ||
}) | ||
|
||
it('40', async () => { | ||
const result = await runVitest({ | ||
root: 'fixtures/chai-config', | ||
reporters: ['tap-flat'], | ||
chaiConfig: { | ||
truncateThreshold: 40, | ||
}, | ||
}) | ||
expect(cleanOutput(result.stdout)).toMatchInlineSnapshot(` | ||
"TAP version 13 | ||
1..9 | ||
ok 1 - test-each-title.test.ts > '012345678901234567890123456789' (length = 30) | ||
ok 2 - test-each-title.test.ts > '0123456789012345678901234567890123456…' (length = 40) | ||
ok 3 - test-each-title.test.ts > '0123456789012345678901234567890123456…' (length = 50) | ||
ok 4 - test-each-title.test.ts > [ 'one', 'two', 'three' ] | ||
ok 5 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four' ] | ||
ok 6 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four', …(1) ] | ||
ok 7 - test-each-title.test.ts > { one: 1, two: 2, three: 3 } | ||
ok 8 - test-each-title.test.ts > { one: 1, two: 2, three: 3, four: 4 } | ||
ok 9 - test-each-title.test.ts > { one: 1, two: 2, three: 3, …(2) } | ||
" | ||
`) | ||
expect(result.exitCode).toBe(0) | ||
}) | ||
|
||
it('0', async () => { | ||
const result = await runVitest({ | ||
root: 'fixtures/chai-config', | ||
reporters: ['tap-flat'], | ||
chaiConfig: { | ||
truncateThreshold: 0, | ||
}, | ||
}) | ||
expect(cleanOutput(result.stdout)).toMatchInlineSnapshot(` | ||
"TAP version 13 | ||
1..9 | ||
ok 1 - test-each-title.test.ts > '012345678901234567890123456789' (length = 30) | ||
ok 2 - test-each-title.test.ts > '0123456789012345678901234567890123456789' (length = 40) | ||
ok 3 - test-each-title.test.ts > '01234567890123456789012345678901234567890123456789' (length = 50) | ||
ok 4 - test-each-title.test.ts > [ 'one', 'two', 'three' ] | ||
ok 5 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four' ] | ||
ok 6 - test-each-title.test.ts > [ 'one', 'two', 'three', 'four', 'five' ] | ||
ok 7 - test-each-title.test.ts > { one: 1, two: 2, three: 3 } | ||
ok 8 - test-each-title.test.ts > { one: 1, two: 2, three: 3, four: 4 } | ||
ok 9 - test-each-title.test.ts > { one: 1, two: 2, three: 3, four: 4, five: 5 } | ||
" | ||
`) | ||
expect(result.exitCode).toBe(0) | ||
}) | ||
}) | ||
|
||
function cleanOutput(output: string) { | ||
// remove non-deterministic output | ||
return output.replaceAll(/\s*# time=.*/g, '') | ||
} |