mirror of
https://github.com/dorny/test-reporter.git
synced 2026-03-21 23:52:12 +01:00
feat: added a slug-prefix parameter for link anchors
Motivation: when using a matrix job, or more than one kind of tests in a same workflow, we can end up with multiple summaries at the same time. This will lead to multiple anchors and html id that will no longer be unique. This prefix option allow to disambiguate those anchors ; and keep them functional.
This commit is contained in:
parent
3d76b34a45
commit
7f0723a953
7 changed files with 49 additions and 4 deletions
28
__tests__/utils/slugger.test.ts
Normal file
28
__tests__/utils/slugger.test.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import {DEFAULT_OPTIONS} from '../../src/report/get-report.js'
|
||||
import {slug} from '../../src/utils/slugger.js'
|
||||
|
||||
describe('slugger', () => {
|
||||
it('adds prefix from report options to generated slug', () => {
|
||||
const result = slug('r0s1', {
|
||||
...DEFAULT_OPTIONS,
|
||||
slugPrefix: 'prefix-'
|
||||
})
|
||||
|
||||
expect(result).toEqual({
|
||||
id: 'user-content-prefix-r0s1',
|
||||
link: '#user-content-prefix-r0s1'
|
||||
})
|
||||
})
|
||||
|
||||
it('sanitizes custom prefix using existing slug normalization', () => {
|
||||
const result = slug('r0', {
|
||||
...DEFAULT_OPTIONS,
|
||||
slugPrefix: ' my /custom_prefix?.'
|
||||
})
|
||||
|
||||
expect(result).toEqual({
|
||||
id: 'user-content-my-customprefix-r0',
|
||||
link: '#user-content-my-customprefix-r0'
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue