Skip to content

Commit f33beb6

Browse files
authored
chore(vscode): improving the playwright setup/teardown steps (#4883)
1 parent b81b109 commit f33beb6

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

vscode/extension/playwright.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ export default defineConfig({
77
retries: process.env.CI ? 2 : 0,
88
workers: 4,
99
reporter: [['html', { outputFolder: 'playwright-report' }], ['list']],
10-
globalSetup: './tests/global-setup.ts',
1110
projects: [
11+
{
12+
name: 'setup',
13+
testMatch: 'tests/extension.setup.ts',
14+
teardown: 'cleanup',
15+
},
16+
{
17+
name: 'cleanup',
18+
testMatch: 'tests/extension.teardown.ts',
19+
},
1220
{
1321
name: 'electron-vscode',
1422
use: {
@@ -20,6 +28,7 @@ export default defineConfig({
2028
viewport: { width: 1512, height: 944 },
2129
video: 'retain-on-failure',
2230
},
31+
dependencies: ['setup'],
2332
},
2433
],
2534
})

vscode/extension/tests/global-setup.ts renamed to vscode/extension/tests/extension.setup.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { test as setup } from '@playwright/test'
12
import { execSync } from 'child_process'
23
import path from 'path'
34
import fs from 'fs-extra'
45
import { createHash } from 'crypto'
56

6-
async function globalSetup() {
7+
setup('prepare extension', async () => {
78
console.log('Setting up extension for Playwright tests...')
89

910
const extensionDir = path.join(__dirname, '..')
@@ -70,11 +71,9 @@ async function globalSetup() {
7071
// Clean up temporary user data directory
7172
await fs.remove(tempUserDataDir)
7273
}
73-
}
74+
})
7475

7576
async function hashFile(filePath: string): Promise<string> {
7677
const fileBuffer = await fs.readFile(filePath)
7778
return createHash('sha256').update(fileBuffer).digest('hex')
7879
}
79-
80-
export default globalSetup
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { test as teardown } from '@playwright/test'
2+
import path from 'path'
3+
import fs from 'fs-extra'
4+
5+
teardown('cleanup extension', async () => {
6+
console.log('Cleaning up extension test setup...')
7+
8+
const extensionDir = path.join(__dirname, '..')
9+
const testSetupDir = path.join(extensionDir, '.test_setup')
10+
11+
// Clean up test setup directory
12+
if (fs.existsSync(testSetupDir)) {
13+
await fs.remove(testSetupDir)
14+
console.log('Test setup directory cleaned up')
15+
}
16+
})

0 commit comments

Comments
 (0)