Skip to content

Commit

Permalink
test: proper cleanups after tests (#1206)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen committed Jan 12, 2024
1 parent 1c6b360 commit a149b76
Show file tree
Hide file tree
Showing 38 changed files with 213 additions and 159 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ build
# IDE files
.idea
.vscode

# Temporary files
tmp
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-promise": "^6.0.0",
"safe-buffer": "5.2.1",
"tmp": "^0.2.1",
"tsm": "^2.3.0",
"typescript": "^5.2.2",
"vinyl": "^3.0.0",
Expand Down
8 changes: 6 additions & 2 deletions packages/conventional-changelog-angular/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path'
import { describe, it, expect } from 'vitest'
import { afterAll, describe, it, expect } from 'vitest'
import BetterThanBefore from 'better-than-before'
import conventionalChangelogCore from 'conventional-changelog-core'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import preset from '../index.js'

const { setups, preparing, tearsWithJoy } = BetterThanBefore()
Expand Down Expand Up @@ -67,6 +67,10 @@ tearsWithJoy(() => {
testTools?.cleanup()
})

afterAll(() => {
testTools?.cleanup()
})

describe('conventional-changelog-angular', () => {
it('should work if there is no semver tag', async () => {
preparing(1)
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-changelog-atom/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import conventionalChangelogCore from 'conventional-changelog-core'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import preset from '../index.js'

let testTools
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-changelog-cli/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import path from 'path'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'

const CLI_PATH = path.join(__dirname, '../cli.js')
const FIXTURE_CHANGELOG_PATH = path.join(__dirname, 'fixtures/_CHANGELOG.md')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import conventionalChangelogCore from 'conventional-changelog-core'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import preset from '../index.js'

let testTools
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path'
import { describe, it, expect } from 'vitest'
import { afterAll, describe, it, expect } from 'vitest'
import BetterThanBefore from 'better-than-before'
import conventionalChangelogCore from 'conventional-changelog-core'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import preset, { DEFAULT_COMMIT_TYPES } from '../index.js'

const { setups, preparing, tearsWithJoy } = BetterThanBefore()
Expand Down Expand Up @@ -91,6 +91,10 @@ tearsWithJoy(() => {
testTools?.cleanup()
})

afterAll(() => {
testTools?.cleanup()
})

describe('conventional-changelog-conventionalcommits', () => {
it('should work if there is no semver tag', async () => {
preparing(1)
Expand Down
8 changes: 6 additions & 2 deletions packages/conventional-changelog-core/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest'
import { afterAll, describe, it, expect } from 'vitest'
import BetterThanBefore from 'better-than-before'
import path from 'path'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import conventionalChangelogCore from '../index.js'

const { setups, preparing, tearsWithJoy } = BetterThanBefore()
Expand Down Expand Up @@ -121,6 +121,10 @@ tearsWithJoy(() => {
testTools?.cleanup()
})

afterAll(() => {
testTools?.cleanup()
})

describe('conventional-changelog-core', () => {
it('should work if there is no tag', async () => {
preparing(1)
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-changelog-ember/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeEach, afterEach, it, expect } from 'vitest'
import conventionalChangelogCore from 'conventional-changelog-core'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import preset from '../index.js'

let testTools
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-changelog-eslint/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import conventionalChangelogCore from 'conventional-changelog-core'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import preset from '../index.js'

let testTools
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-changelog-express/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeEach, afterEach, it, expect } from 'vitest'
import conventionalChangelogCore from 'conventional-changelog-core'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import preset from '../index.js'

let testTools
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-changelog-jquery/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeEach, afterEach, it, expect } from 'vitest'
import conventionalChangelogCore from 'conventional-changelog-core'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import preset from '../index.js'

let testTools
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-changelog-jshint/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import conventionalChangelogCore from 'conventional-changelog-core'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import preset from '../index.js'

let testTools
Expand Down
8 changes: 6 additions & 2 deletions packages/conventional-changelog-writer/src/cli/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'
import { describe, beforeAll, it, expect } from 'vitest'
import { TestTools } from '../../../../tools/test-tools.js'
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import { TestTools } from '../../../../tools/index.js'

const CLI_PATH = path.join(__dirname, './index.ts')
const FIXTURES_RELATIVE_PATH = path.join('..', '..', 'test', 'fixtures')
Expand All @@ -21,6 +21,10 @@ describe('conventional-changelog-writer', () => {
testTools = new TestTools(__dirname)
})

afterAll(() => {
testTools?.cleanup()
})

it('should work without context and options', async () => {
const { stdout } = await testTools.fork(CLI_PATH, [COMMITS_RELATIVE_PATH])

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest'
import { Readable } from 'stream'
import { toArray } from '../../../../tools/test-tools.js'
import { toArray } from '../../../../tools/index.js'
import { parseJsonStream } from './utils.js'

describe('conventional-changelog-writer', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable testing-library/render-result-naming-convention */
import { describe, it, expect } from 'vitest'
import { delay } from '../../../tools/test-tools.js'
import { delay } from '../../../tools/index.js'
import type { CommitNote } from './types/index.js'
import { getFinalContext } from './context.js'
import { getFinalOptions } from './options.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-changelog-writer/src/writers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { delay, throughObj } from '../../../tools/test-tools.js'
import { delay, throughObj } from '../../../tools/index.js'
import { defaultCommitTransform } from './options.js'
import { formatDate } from './utils.js'
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-changelog/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import conventionalChangelog from '../index.js'

let testTools
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-commits-filter/src/filters.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { toArray } from '../../../tools/test-tools.js'
import { toArray } from '../../../tools/index.js'
import { filterRevertedCommits } from './index.js'

describe('conventional-commits-filter', () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/conventional-commits-parser/src/cli/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs/promises'
import path from 'path'
import { describe, beforeAll, it, expect } from 'vitest'
import { TestTools } from '../../../../tools/test-tools.js'
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import { TestTools } from '../../../../tools/index.js'

const CLI_PATH = path.join(__dirname, './index.ts')
const FIXTURES_PATH = path.resolve(__dirname, '..', '..', 'test', 'fixtures')
Expand All @@ -14,6 +14,10 @@ describe('conventional-commits-parser', () => {
testTools = new TestTools(FIXTURES_PATH)
})

afterAll(() => {
testTools?.cleanup()
})

it('should parse commits in a file', async () => {
const { stdout } = await testTools.fork(CLI_PATH, [path.join(FIXTURES_PATH, 'log1.txt')])

Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-commits-parser/src/cli/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest'
import { Readable } from 'stream'
import { toArray } from '../../../../tools/test-tools.js'
import { toArray } from '../../../../tools/index.js'
import { splitStream } from './utils.js'

describe('conventional-commits-parser', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/conventional-commits-parser/src/stream.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { through } from '../../../tools/test-tools.js'
import { through } from '../../../tools/index.js'
import { parseCommitsStream } from './stream.js'

describe('conventional-commits-parser', () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/conventional-recommended-bump/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest'
import { afterAll, describe, it, expect } from 'vitest'
import BetterThanBefore from 'better-than-before'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import conventionalRecommendedBump from '../index.js'

const { setups, preparing, tearsWithJoy } = BetterThanBefore()
Expand Down Expand Up @@ -41,6 +41,10 @@ tearsWithJoy(() => {
testTools?.cleanup()
})

afterAll(() => {
testTools?.cleanup()
})

describe('conventional-recommended-bump', () => {
describe('options object', () => {
it('should throw an error if an \'options\' object is not provided', async () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/git-client/src/ConventionalGitClient.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, beforeAll, it, expect } from 'vitest'
import { TestTools, toArray } from '../../../tools/test-tools.js'
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import { TestTools, toArray } from '../../../tools/index.js'
import {
ConventionalGitClient,
packagePrefix
Expand All @@ -17,6 +17,10 @@ describe('git-client', () => {
client = new ConventionalGitClient(testTools.cwd)
})

afterAll(() => {
testTools?.cleanup()
})

describe('getCommits', () => {
it('should parse commits', async () => {
const commitsStream = client.getCommits()
Expand Down
8 changes: 6 additions & 2 deletions packages/git-client/src/GitClient.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, beforeAll, it, expect } from 'vitest'
import { TestTools, toArray, delay } from '../../../tools/test-tools.js'
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import { TestTools, toArray, delay } from '../../../tools/index.js'
import { GitClient } from './GitClient.js'

describe('git-client', () => {
Expand All @@ -14,6 +14,10 @@ describe('git-client', () => {
client = new GitClient(testTools.cwd)
})

afterAll(() => {
testTools?.cleanup()
})

describe('getRawCommits', () => {
it('should get raw git commits', async () => {
const commitsStream = client.getRawCommits()
Expand Down
2 changes: 1 addition & 1 deletion packages/git-client/src/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Readable } from 'stream'
import {
toArray,
toString
} from '../../../tools/test-tools.js'
} from '../../../tools/index.js'
import {
spawn,
stdoutSpawn,
Expand Down
2 changes: 1 addition & 1 deletion packages/git-raw-commits/src/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import { TestTools, delay } from '../../../tools/test-tools.ts'
import { TestTools, delay } from '../../../tools/index.ts'
import { getRawCommits } from './index.js'

let testTools
Expand Down
2 changes: 1 addition & 1 deletion packages/git-semver-tags/src/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import { getSemverTags } from './index.js'

let testTools
Expand Down
2 changes: 1 addition & 1 deletion packages/gulp-conventional-changelog/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Buffer } from 'safe-buffer'
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import { join } from 'path'
import Vinyl from 'vinyl'
import { TestTools, through } from '../../../tools/test-tools.ts'
import { TestTools, through } from '../../../tools/index.ts'
import conventionalChangelog from '../index.js'

let testTools
Expand Down
2 changes: 1 addition & 1 deletion packages/standard-changelog/test/cli.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path'
import { describe, beforeAll, beforeEach, afterAll, it, expect } from 'vitest'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'

const CLI_PATH = path.join(__dirname, '../cli.js')
const FIXTURE_CHANGELOG_PATH = path.join(__dirname, 'fixtures/_CHANGELOG.md')
Expand Down
2 changes: 1 addition & 1 deletion packages/standard-changelog/test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, beforeAll, afterAll, it, expect } from 'vitest'
import { TestTools } from '../../../tools/test-tools.ts'
import { TestTools } from '../../../tools/index.ts'
import standardChangelog from '../index.js'

let testTools
Expand Down
10 changes: 0 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a149b76

Please sign in to comment.