Skip to content

Commit

Permalink
tests: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Jun 5, 2024
1 parent fbee7d0 commit ce19e01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/instances/stackup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ test('behavior: instance errored (duplicate ports)', async () => {
})

await instance_1.start()
await expect(() => instance_2.start()).rejects.toThrowError(
'port is already allocated',
)
await expect(() => instance_2.start()).rejects.toThrowError()

Check failure on line 63 in src/instances/stackup.test.ts

View workflow job for this annotation

GitHub Actions / Verify / Test

src/instances/stackup.test.ts > behavior: instance errored (duplicate ports)

AssertionError: promise resolved "[Function bound stop]" instead of rejecting - Expected: [Error: rejected promise] + Received: [Function bound stop] ❯ src/instances/stackup.test.ts:63:40
})

test('behavior: start and stop multiple times', async () => {
Expand All @@ -86,7 +84,7 @@ test('behavior: can subscribe to stderr', async () => {

await instance_1.start()
instance_2.on('stderr', (message) => messages.push(message))
await expect(instance_2.start()).rejects.toThrow('port is already allocated.')
await expect(instance_2.start()).rejects.toThrowError()

Check failure on line 87 in src/instances/stackup.test.ts

View workflow job for this annotation

GitHub Actions / Verify / Test

src/instances/stackup.test.ts > behavior: can subscribe to stderr

AssertionError: promise resolved "[Function bound stop]" instead of rejecting - Expected: [Error: rejected promise] + Received: [Function bound stop] ❯ src/instances/stackup.test.ts:87:34
})

test('behavior: exit', async () => {
Expand Down
10 changes: 7 additions & 3 deletions src/instances/stackup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@ export const stackup = defineInstance((parameters?: StackupParameters) => {
resolver({ process, resolve, reject }) {
process.stderr.on('data', async (data) => {
const message = data.toString()
// For some reason, `stackup-bundler` logs to stderr. So we have to try
// and dissect what is an error, and what is not. 😅
if (message.includes('Set nextTxnTs to'))
// For some reason, stackup-bundler logs to stderr. So after we receive a message back
// from the server, we will wait to make sure an error didn't occur after connection.
setTimeout(() => resolve(), 100)
if (message.toLowerCase().match(/panic|error|connection refused/))
else if (
message
.toLowerCase()
.match(/panic|error|connection refused|address already in use/)
)
reject(data)
})
},
Expand Down

0 comments on commit ce19e01

Please sign in to comment.