Skip to content

Commit b2e79a1

Browse files
committed
test: output client logs on test failure
1 parent ca6aaa2 commit b2e79a1

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/utils/wait.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const AWAIT_SLEEP = 3000
1010

1111
const BLOCKCHAIN_BODY_REQUEST = JSON.stringify({ id: 1, jsonrpc: '2.0', method: 'eth_chainId' })
1212
const EXPECTED_CHAIN_ID = '0x7a69'
13-
const ALLOWED_ERRORS = ['ECONNREFUSED', 'ECONNRESET', 'UND_ERR_SOCKET']
13+
const ALLOWED_ERRORS = ['ECONNREFUSED', 'ECONNRESET', 'UND_ERR_SOCKET', 502]
1414

1515
function isAllowedError(e: FetchError): boolean {
1616
if (e.cause) {
@@ -22,8 +22,6 @@ function isAllowedError(e: FetchError): boolean {
2222
return true
2323
}
2424

25-
// Errors from Bee-js does not have the `FetchError` structure (eq. `code` property)
26-
// so we assert message itself.
2725
if (e.message.includes('socket hang up')) {
2826
return true
2927
}
@@ -93,6 +91,8 @@ export async function waitForClient(
9391
}
9492
}
9593
} catch (error) {
94+
console.log('Error:', error)
95+
9696
if (!isAllowedError(error as FetchError)) {
9797
throw error
9898
}

test/commands/start.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import { deleteNetwork, findContainer } from '../utils/docker'
1212
chaiUse(chaiAsPromised)
1313
let testFailed = false
1414

15-
async function runCommand(args: string): Promise<ReturnType<typeof runCommandRaw>> {
15+
async function runCommand (args: string): Promise<ReturnType<typeof runCommandRaw>> {
1616
const result = await runCommandRaw(args)
1717

1818
if (result.error) {
19-
console.log(result.stdout)
20-
console.error(result.stderr)
19+
console.log('============\n=> ERROR:', result.error)
20+
console.log('============\n=> STDOUT:', result.stdout)
21+
console.error('============\n=> STDERR:', result.stderr)
2122
}
2223

2324
return result
@@ -72,7 +73,9 @@ describe('start command', () => {
7273
const containers = await docker.listContainers()
7374
for (const c of containers) console.log(` - ${c.Names.join(', ')}`)
7475

75-
await runCommand('logs client')
76+
const { stdout } = await runCommand('logs client')
77+
console.log('Client logs:\n', stdout)
78+
7679
}
7780

7881
await runCommand('stop')

0 commit comments

Comments
 (0)