Skip to content

Commit

Permalink
test(windows): fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah committed Jan 13, 2022
1 parent 019abda commit 6de6b32
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/utils/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getExecaOptions = ({ cwd, env }) => ({
encoding: 'utf8',
})

const startServer = async ({ cwd, offline = true, env = {}, args = [] }) => {
const startServer = async ({ cwd, offline = true, env = {}, args = [], expectFailure = false }) => {
const tryPort = currentPort
currentPort += 1
const port = await getPort({ port: tryPort })
Expand All @@ -49,7 +49,7 @@ const startServer = async ({ cwd, offline = true, env = {}, args = [] }) => {
let selfKilled = false
ps.stdout.on('data', (data) => {
outputBuffer.push(data)
if (data.includes('Server now ready on')) {
if (!expectFailure && data.includes('Server now ready on')) {
resolve({
url,
host,
Expand All @@ -75,7 +75,7 @@ const startDevServer = async (options, expectFailure) => {
// eslint-disable-next-line fp/no-loops
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
try {
const { timeout, ...server } = await startServer(options)
const { timeout, ...server } = await startServer({ ...options, expectFailure })
if (timeout) {
throw new Error(`Timed out starting dev server.\nServer Output:\n${server.output}`)
}
Expand Down

0 comments on commit 6de6b32

Please sign in to comment.