diff --git a/integration_test/common.js b/integration_test/common.js index 18fce26df..91b686630 100644 --- a/integration_test/common.js +++ b/integration_test/common.js @@ -558,7 +558,7 @@ module.exports = { if (pubkey) { if (request.method === 'POST') { if (ENABLE_LOG) { - console.warn('POST', [data, timestamp]); + console.warn('POST for', pubkey, [data, timestamp]); } let ori = this.messages[pubkey]; @@ -571,9 +571,10 @@ module.exports = { response.writeHead(200, { 'Content-Type': 'text/html' }); response.end(); } else { - const retrievedMessages = { messages: this.messages[pubkey] }; + const messages = this.messages[pubkey] || []; + const retrievedMessages = { messages }; if (ENABLE_LOG) { - console.warn('GET', pubkey, retrievedMessages); + console.warn('GET for', pubkey, retrievedMessages); } if (this.messages[pubkey]) { response.writeHead(200, { 'Content-Type': 'application/json' }); @@ -638,12 +639,17 @@ module.exports = { * @param {*} str the string to search (not regex) * Note: getRenderProcessLogs() clears the app logs each calls. */ - async logsContains(renderLogs, str) { - const found = renderLogs.some(log => log.message.includes(str)); + async logsContains(renderLogs, str, count = undefined) { + const foundLines = renderLogs.filter(log => log.message.includes(str)); // eslint-disable-next-line no-unused-expressions - chai.expect(found, `'${str}' not found in logs but was expected`).to.be + chai.expect(foundLines.length > 0, `'${str}' not found in logs but was expected`).to.be .true; + + if (count) { + // eslint-disable-next-line no-unused-expressions + chai.expect(foundLines.length, `'${str}' found but not the correct number of times`).to.be.equal(count); + } }, // async killStubSnodeServer() {