Skip to content

Commit

Permalink
test: ensure ports are free for test servers
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 11, 2022
1 parent d07e814 commit e10b56f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions playground/shims.d.ts
Expand Up @@ -3,6 +3,11 @@ declare module 'css-color-names' {
export default colors
}

declare module 'kill-port' {
const kill: (port: number) => Promise<void>
export default kill
}

declare module '*.vue' {
import type { ComponentOptions } from 'vue'
const component: ComponentOptions
Expand Down
3 changes: 3 additions & 0 deletions playground/ssr-vue/__tests__/serve.ts
Expand Up @@ -2,6 +2,7 @@
// the default e2e test serve behavior

import path from 'path'
import kill from 'kill-port'
import { ports } from '~utils'

export const port = ports['ssr-vue']
Expand Down Expand Up @@ -33,6 +34,8 @@ export async function serve(root, isProd) {
})
}

await kill(port)

const { createServer } = require(path.resolve(root, 'server.js'))
const { app, vite } = await createServer(root, isProd)

Expand Down

0 comments on commit e10b56f

Please sign in to comment.