Skip to content

Commit b73dcd7

Browse files
committed
test: concurrently
1 parent 841584c commit b73dcd7

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

tests/_utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import path from 'node:path'
22
import { expectFilesSnapshot } from '@sxzz/test-utils'
3+
import type { ExpectStatic } from 'vitest'
34

45
export async function expectSnapshot(
56
dir: string,
67
name: string,
7-
pattern = '**/*',
8+
expect?: ExpectStatic,
89
): Promise<void> {
910
await expectFilesSnapshot(
1011
dir,
1112
path.resolve(__dirname, '__snapshots__', `${name}.md`),
12-
pattern,
13+
{ expect },
1314
)
1415
}

tests/esbuild.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { dependencies } from '../package.json'
66
import UnpluginIsolatedDecl from '../src/esbuild'
77
import { expectSnapshot } from './_utils'
88

9-
describe('esbuild', () => {
9+
describe.concurrent('esbuild', () => {
1010
const input = path.resolve(__dirname, 'fixtures/basic/main.ts')
1111

12-
test('write mode', async () => {
12+
test('write mode', async ({ expect }) => {
1313
const dist = path.resolve(__dirname, 'temp/esbuild/basic')
1414
await build({
1515
entryPoints: [input],
@@ -28,7 +28,7 @@ describe('esbuild', () => {
2828
})
2929

3030
const outDir = path.resolve(dist, 'extraOutdir')
31-
await expectSnapshot(outDir, `esbuild/basic`)
31+
await expectSnapshot(outDir, `esbuild/basic`, expect)
3232
})
3333

3434
test('generate mode', async () => {

tests/rollup.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { describe, expect, test } from 'vitest'
77
import UnpluginIsolatedDecl from '../src/rollup'
88
import { expectSnapshot } from './_utils'
99

10-
describe('rollup', () => {
10+
describe.concurrent('rollup', () => {
1111
const fixtures = path.resolve(__dirname, 'fixtures')
1212
const TEST_SANDBOX_FOLDER = path.resolve(__dirname, 'temp/rollup')
1313

14-
test('generate basic', async () => {
14+
test('generate basic', async ({ expect }) => {
1515
const dir = 'basic'
1616
const input = path.resolve(fixtures, dir, 'main.ts')
1717

@@ -25,7 +25,7 @@ describe('rollup', () => {
2525
expect(outputToSnapshot(result.output)).toMatchSnapshot()
2626
})
2727

28-
test(`keep ext`, async () => {
28+
test(`keep ext`, async ({ expect }) => {
2929
const dir = 'keep-ext'
3030
const input = path.resolve(fixtures, dir, 'main.ts')
3131

@@ -39,7 +39,7 @@ describe('rollup', () => {
3939
expect(outputToSnapshot(result.output)).toMatchSnapshot()
4040
})
4141

42-
test(`extraOutdir`, async () => {
42+
test(`extraOutdir`, async ({ expect }) => {
4343
const dir = 'extra-outdir'
4444
const input = path.resolve(fixtures, dir, 'main.ts')
4545
const dist = path.resolve(TEST_SANDBOX_FOLDER, dir)
@@ -51,10 +51,10 @@ describe('rollup', () => {
5151
})
5252
await bundle.write({ dir: dist })
5353

54-
await expectSnapshot(dist, `rollup/${dir}`)
54+
await expectSnapshot(dist, `rollup/${dir}`, expect)
5555
})
5656

57-
test('write entry-points (#22)', async () => {
57+
test('write entry-points (#22)', async ({ expect }) => {
5858
const dir = 'entry-points-22'
5959
const input = {
6060
a: path.resolve(fixtures, dir, 'a/index.ts'),
@@ -80,10 +80,10 @@ describe('rollup', () => {
8080
preserveModules: true,
8181
})
8282

83-
await expectSnapshot(dist, `rollup/${dir}`)
83+
await expectSnapshot(dist, `rollup/${dir}`, expect)
8484
})
8585

86-
test('write entry-points (#34)', async () => {
86+
test('write entry-points (#34)', async ({ expect }) => {
8787
const dir = 'entry-points-34'
8888
const input = {
8989
index: path.resolve(fixtures, dir, 'main.ts'),
@@ -104,10 +104,10 @@ describe('rollup', () => {
104104

105105
await bundle.write({ dir: dist })
106106

107-
await expectSnapshot(dist, `rollup/${dir}`)
107+
await expectSnapshot(dist, `rollup/${dir}`, expect)
108108
})
109109

110-
test('custom rewriter', async () => {
110+
test('custom rewriter', async ({ expect }) => {
111111
const dir = 'import-rewriter'
112112
const input = path.resolve(fixtures, dir, 'index.ts')
113113

@@ -136,7 +136,7 @@ describe('rollup', () => {
136136
expect(importer).toBe(path.resolve(fixtures, dir, 'index.ts'))
137137
})
138138

139-
test('no index path', async () => {
139+
test('no index path', async ({ expect }) => {
140140
const dir = 'no-index'
141141
const input = path.resolve(fixtures, dir, 'main.ts')
142142
const dist = path.resolve(TEST_SANDBOX_FOLDER, dir)
@@ -149,6 +149,6 @@ describe('rollup', () => {
149149

150150
await bundle.write({ dir: dist })
151151

152-
await expectSnapshot(dist, `rollup/${dir}`)
152+
await expectSnapshot(dist, `rollup/${dir}`, expect)
153153
})
154154
})

0 commit comments

Comments
 (0)