Skip to content

Commit

Permalink
test: Add debug log, to see why test randomly failed (#628)
Browse files Browse the repository at this point in the history
I cannot find root cause, I'm adding log, once it fails again it should
help to debug.
  • Loading branch information
drobnikj authored Jan 27, 2025
1 parent 3876d90 commit 6175cfb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,17 @@ const validateRequest = (query = {}, params = {}, body = {}, additionalHeaders =
};
const request = mockServer.getLastRequest();
const expectedQuery = getExpectedQuery(query);
if (query !== false) expect(request.query).toEqual(expectedQuery);
if (query !== false) {
try {
expect(request.query).toEqual(expectedQuery);
} catch (err) {
// Debug log to check what was actually in request.
// It is happening that the "_batchAddRequests() works" randomly fails on CI, it can be caused by tests concurrency.
// If so we need to update how mockServer.getLastRequest() works.
console.log('Request:', request.route.path, request.route.methods, request.query);

Check warning on line 75 in test/_helper.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
throw err;
}
}
if (params !== false) expect(request.params).toEqual(params);
if (body !== false) expect(request.body).toEqual(body);
Object.entries(headers).forEach(([key, value]) => {
Expand Down

0 comments on commit 6175cfb

Please sign in to comment.