Skip to content

Commit 47f1220

Browse files
authored
Merge pull request #1472 from mikepenz/feature/vitest
Replace Jest with Vitest
2 parents cc630f2 + ca0b2e3 commit 47f1220

17 files changed

+3230
-5494
lines changed

__tests__/configuration.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import {mergeConfiguration, parseConfiguration, resolveConfiguration} from '../src/utils.js'
22
import {clear} from '../src/transform.js'
3-
import {jest} from '@jest/globals'
3+
import {expect, test} from 'vitest'
44

5-
jest.setTimeout(180000)
65
clear()
76

8-
it('Configurations are merged correctly', async () => {
7+
test('Configurations are merged correctly', async () => {
98
const configurationJson = parseConfiguration(`{
109
"sort": "DESC",
1110
"empty_template": "- no magic changes",

__tests__/demo/demo.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import {mergeConfiguration, resolveConfiguration} from '../../src/utils.js'
22
import {ReleaseNotesBuilder} from '../../src/releaseNotesBuilder.js'
33
import {GithubRepository} from '../../src/repositories/GithubRepository.js'
4-
import {jest} from '@jest/globals'
4+
import { expect, test } from 'vitest'
55

6-
jest.setTimeout(180000)
76

87
// Define the token to use. Either retrieved from the environment.
98
// Alternatively provide it as a string right here.
109
const token = process.env.GITHUB_TOKEN || ''
1110
const githubRepository = new GithubRepository(token, undefined, '.')
12-
it('Test custom changelog builder', async () => {
11+
test('Test custom changelog builder', async () => {
1312
// define the configuration file to use.
1413
// By default, it retrieves a configuration from a json file
1514
// You can also quickly modify in code.

__tests__/gitea/releaseNotesBuilderGitea.test.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import {mergeConfiguration, resolveConfiguration} from '../../src/utils.js'
22
import {ReleaseNotesBuilder} from '../../src/releaseNotesBuilder.js'
33
import {GiteaRepository} from '../../src/repositories/GiteaRepository.js'
44
import {clear} from '../../src/transform.js'
5-
import {jest} from '@jest/globals'
5+
import { expect, test } from 'vitest'
66

7-
jest.setTimeout(180000)
87
clear()
98

109
/**
@@ -20,7 +19,7 @@ const owner = 'jolheiser'
2019
const repo = 'sip'
2120
const configurationFile = 'configs/configuration_gitea.json'
2221

23-
it('[Gitea] Verify reviewers who approved are fetched and also release information', async () => {
22+
test('[Gitea] Verify reviewers who approved are fetched and also release information', async () => {
2423
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
2524

2625
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -60,7 +59,7 @@ it('[Gitea] Verify reviewers who approved are fetched and also release informati
6059
)
6160
})
6261

63-
it('[Gitea] Should match generated changelog (unspecified fromTag)', async () => {
62+
test('[Gitea] Should match generated changelog (unspecified fromTag)', async () => {
6463
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
6564

6665
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -97,7 +96,7 @@ it('[Gitea] Should match generated changelog (unspecified fromTag)', async () =>
9796
})
9897

9998
//
100-
it('[Gitea] Should match generated changelog (unspecified tags)', async () => {
99+
test('[Gitea] Should match generated changelog (unspecified tags)', async () => {
101100
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
102101

103102
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -133,7 +132,7 @@ it('[Gitea] Should match generated changelog (unspecified tags)', async () => {
133132
`)
134133
})
135134

136-
it('[Gitea] Should use empty placeholder', async () => {
135+
test('[Gitea] Should use empty placeholder', async () => {
137136
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
138137

139138
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -184,7 +183,7 @@ it('[Gitea] Should use empty placeholder', async () => {
184183
`)
185184
})
186185

187-
it('[Gitea] Should fill empty placeholders', async () => {
186+
test('[Gitea] Should fill empty placeholders', async () => {
188187
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
189188

190189
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -292,7 +291,7 @@ https://gitea.com/jolheiser/sip/compare/v0.1.0...v0.4.0
292291
)
293292
})
294293

295-
it('[Gitea] Should fill `template` placeholders', async () => {
294+
test('[Gitea] Should fill `template` placeholders', async () => {
296295
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
297296

298297
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -400,7 +399,7 @@ https://gitea.com/jolheiser/sip/compare/v0.1.0...v0.4.0
400399
)
401400
})
402401

403-
it('[Gitea] Should fill `template` placeholders, ignore', async () => {
402+
test('[Gitea] Should fill `template` placeholders, ignore', async () => {
404403
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_empty_all_placeholders.json'))
405404
configuration.categories.pop() // drop `uncategorized` category
406405

@@ -466,7 +465,7 @@ https://gitea.com/jolheiser/sip/compare/v0.3.0...v0.5.0
466465
)
467466
})
468467

469-
it('[Gitea] Uncategorized category', async () => {
468+
test('[Gitea] Uncategorized category', async () => {
470469
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_uncategorized_category.json'))
471470

472471
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -540,7 +539,7 @@ Ignored:
540539
)
541540
})
542541

543-
it('[Gitea] Verify commit based changelog', async () => {
542+
test('[Gitea] Verify commit based changelog', async () => {
544543
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_commits.json'))
545544

546545
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -617,7 +616,7 @@ Ignored:
617616
)
618617
})
619618

620-
it('[Gitea] Verify commit based changelog', async () => {
619+
test('[Gitea] Verify commit based changelog', async () => {
621620
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
622621

623622
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -655,7 +654,7 @@ it('[Gitea] Verify commit based changelog', async () => {
655654
)
656655
})
657656
// no open prs
658-
it('[Gitea] Verify default inclusion of open PRs', async () => {
657+
test('[Gitea] Verify default inclusion of open PRs', async () => {
659658
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_including_open.json'))
660659

661660
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -696,7 +695,7 @@ Open
696695
`)
697696
})
698697

699-
it('[Gitea] Verify custom categorisation of open PRs', async () => {
698+
test('[Gitea] Verify custom categorisation of open PRs', async () => {
700699
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_excluding_open.json'))
701700

702701
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
@@ -727,7 +726,7 @@ it('[Gitea] Verify custom categorisation of open PRs', async () => {
727726
expect(changeLog).toStrictEqual(``)
728727
})
729728

730-
it('[Gitea] Fetch release information', async () => {
729+
test('[Gitea] Fetch release information', async () => {
731730
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
732731
configuration.template = '#{{FROM_TAG}}-#{{FROM_TAG_DATE}}\n#{{TO_TAG}}-#{{TO_TAG_DATE}}\n#{{DAYS_SINCE}}'
733732

@@ -761,7 +760,7 @@ master-2020-09-21T19:30:21.000Z
761760
4`)
762761
})
763762

764-
it('[Gitea] Fetch release information for non existing tag / release', async () => {
763+
test('[Gitea] Fetch release information for non existing tag / release', async () => {
765764
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_approvers.json'))
766765
configuration.template = '#{{FROM_TAG}}-#{{FROM_TAG_DATE}}\n#{{TO_TAG}}-#{{TO_TAG_DATE}}\n#{{DAYS_SINCE}}'
767766

__tests__/gitea/releaseNotesBuilderPullGitea.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import {Options, pullData} from '../../src/pr-collector/prCollector.js'
44
import {GiteaRepository} from '../../src/repositories/GiteaRepository.js'
55
import {clear} from '../../src/transform.js'
66
import {ReleaseNotesOptions} from '../../src/releaseNotesBuilder.js'
7-
import {jest} from '@jest/globals'
7+
import { expect, test } from 'vitest'
88

9-
jest.setTimeout(180000)
109
clear()
1110

1211
// load octokit instance
@@ -35,7 +34,7 @@ const owner = 'jolheiser'
3534
const repo = 'sip'
3635
const giteaRepository = new GiteaRepository(token, undefined, workingDirectory)
3736
const configurationFile = 'configs/configuration_gitea.json'
38-
it('[Gitea] Should have changelog (tags)', async () => {
37+
test('[Gitea] Should have changelog (tags)', async () => {
3938
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
4039

4140
const options = {
@@ -74,7 +73,7 @@ it('[Gitea] Should have changelog (tags)', async () => {
7473
`)
7574
})
7675

77-
it('[Gitea] Should match generated changelog (tags)', async () => {
76+
test('[Gitea] Should match generated changelog (tags)', async () => {
7877
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
7978
const options = {
8079
owner: owner,
@@ -112,7 +111,7 @@ it('[Gitea] Should match generated changelog (tags)', async () => {
112111
`)
113112
})
114113

115-
it('[Gitea] Should match generated changelog (refs)', async () => {
114+
test('[Gitea] Should match generated changelog (refs)', async () => {
116115
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_all_placeholders.json'))
117116

118117
const options = {
@@ -170,7 +169,7 @@ It also scans CLI flags into variables for fewer footguns.
170169
`)
171170
})
172171

173-
it('[Gitea] Should match generated changelog and replace all occurrences (refs)', async () => {
172+
test('[Gitea] Should match generated changelog and replace all occurrences (refs)', async () => {
174173
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_replace_all_placeholders.json'))
175174
const options = {
176175
owner: owner,
@@ -231,7 +230,7 @@ It also scans CLI flags into variables for fewer footguns.
231230
`)
232231
})
233232

234-
it('[Gitea] Should match ordered ASC', async () => {
233+
test('[Gitea] Should match ordered ASC', async () => {
235234
const configuration = mergeConfiguration(undefined, resolveConfiguration('', configurationFile))
236235
configuration.categories.pop() // drop `uncategorized` category
237236
const options = {
@@ -288,7 +287,7 @@ it('[Gitea] Should match ordered ASC', async () => {
288287
`)
289288
})
290289

291-
it('[Gitea] Should match ordered DESC', async () => {
290+
test('[Gitea] Should match ordered DESC', async () => {
292291
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs_test/configuration_gitea_desc.json'))
293292
configuration.categories.pop() // drop `uncategorized` category
294293
const options = {

__tests__/main.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import * as process from 'process'
33
import * as cp from 'child_process'
44
import * as fs from 'fs'
55
import {clear} from '../src/transform.js'
6-
import {jest} from '@jest/globals'
7-
import { fileURLToPath } from 'url';
6+
import {fileURLToPath} from 'url'
7+
import {expect, test} from 'vitest'
88

9-
jest.setTimeout(180000)
109
clear()
1110

12-
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
13-
const __dirname = path.dirname(__filename); // get the name of the directory
11+
const __filename = fileURLToPath(import.meta.url) // get the resolved path to the file
12+
const __dirname = path.dirname(__filename) // get the name of the directory
1413

1514
function resetEnv(): void {
1615
process.env['INPUT_CONFIGURATION'] = ''
@@ -113,7 +112,7 @@ test('offline mode should work with commit mode', () => {
113112
const readOutput = fs.readFileSync('test.md')
114113
fs.unlinkSync('test.md')
115114

116-
expect(readOutput.toString()).not.toBe("- no changes")
115+
expect(readOutput.toString()).not.toBe('- no changes')
117116
expect(readOutput.toString()).not.toBe('')
118117

119118
console.log('Offline mode test succeeded')

__tests__/offline/offlineMode.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
import {mergeConfiguration, resolveConfiguration} from '../../src/utils.js'
1717
import {ReleaseNotesBuilder} from '../../src/releaseNotesBuilder.js'
1818
import {OfflineRepository} from '../../src/repositories/OfflineRepository.js'
19-
import {jest} from '@jest/globals'
20-
21-
jest.setTimeout(180000)
19+
import { expect, test } from 'vitest'
2220

2321
// This test validates the behavior of the new offline mode
2422
test('Test offline mode functionality', async () => {

__tests__/regexUtils.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import {transformStringToValue, validateRegex} from '../src/pr-collector/regexUtils.js'
22
import {Regex} from '../src/pr-collector/types.js'
33
import {clear} from '../src/transform.js'
4-
import {jest} from '@jest/globals'
4+
import {expect, test} from 'vitest'
55

6-
jest.setTimeout(180000)
76
clear()
87

9-
it('Replace into target', async () => {
8+
test('Replace into target', async () => {
109
const regex: Regex = {
1110
pattern: '.*(\\[Feature\\]|\\[Issue\\]).*',
1211
target: '$1'
@@ -16,7 +15,7 @@ it('Replace into target', async () => {
1615
expect(transformStringToValue('[Feature] TEST', validatedRegex!!)).toStrictEqual(`[Feature]`)
1716
})
1817

19-
it('Replace all into target', async () => {
18+
test('Replace all into target', async () => {
2019
const regex: Regex = {
2120
pattern: '.*(\\[Feature\\]|\\[Issue\\]).*',
2221
method: 'replaceAll',
@@ -27,7 +26,7 @@ it('Replace all into target', async () => {
2726
expect(transformStringToValue('[Feature] TEST', validatedRegex!!)).toStrictEqual(`[Feature]`)
2827
})
2928

30-
it('Match without target', async () => {
29+
test('Match without target', async () => {
3130
const regex: Regex = {
3231
pattern: '\\[Feature\\]|\\[Issue\\]',
3332
method: 'match'
@@ -37,7 +36,7 @@ it('Match without target', async () => {
3736
expect(transformStringToValue('[Feature] TEST', validatedRegex!!)).toStrictEqual(`[Feature]`)
3837
})
3938

40-
it('Match into target', async () => {
39+
test('Match into target', async () => {
4140
const regex: Regex = {
4241
pattern: '(?<label>\\[Feature\\]|\\[Issue\\])',
4342
method: 'match',
@@ -48,7 +47,7 @@ it('Match into target', async () => {
4847
expect(transformStringToValue('[Feature] TEST', validatedRegex!!)).toStrictEqual(`[Feature]`)
4948
})
5049

51-
it('Match into named group', async () => {
50+
test('Match into named group', async () => {
5251
const regex: Regex = {
5352
pattern: '(?<label>\\[Feature\\]|\\[Issue\\])',
5453
method: 'match',

0 commit comments

Comments
 (0)