forked from vuejs/create-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.mjs
53 lines (42 loc) · 1.45 KB
/
test.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env zx
import 'zx/globals'
const playgroundDir = path.resolve(__dirname, '../playground/')
let projects = fs
.readdirSync(playgroundDir, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
.filter((name) => !name.startsWith('.') && name !== 'node_modules')
if (process.argv[3]) projects = projects.filter((project) => project.includes(process.argv[3]))
cd(playgroundDir)
console.log('Installing playground dependencies')
await $`pnpm install`
for (const projectName of projects) {
cd(path.resolve(playgroundDir, projectName))
const packageJSON = require(path.resolve(playgroundDir, projectName, 'package.json'))
console.log(`
#####
Building ${projectName}
#####
`)
await $`pnpm build`
if ('@playwright/test' in packageJSON.devDependencies) {
await $`pnpm playwright install --with-deps`
}
if ('test:e2e' in packageJSON.scripts) {
console.log(`Running e2e tests in ${projectName}`)
await $`pnpm test:e2e`
}
if ('test:unit' in packageJSON.scripts) {
console.log(`Running unit tests in ${projectName}`)
if (projectName.includes('vitest') || projectName.includes('with-tests')) {
// Vitest would otherwise enable watch mode by default.
await $`CI=1 pnpm test:unit`
} else {
await $`pnpm test:unit`
}
}
if ('type-check' in packageJSON.scripts) {
console.log(`Running type-check in ${projectName}`)
await $`pnpm type-check`
}
}