This is actualized version of this PR - https://github.com/louislam/uptime-kuma/pull/6192 But with tests and an additional change that allows to only store responses **for failed HTTP requests**. Add response column to heartbeat table to store HTTP response data * Add monitor configuration options: saveResponse (default: false), saveErrorResponse (default: false) and responseMaxLength (default: 10240 bytes) * Response max length of 0 allows unlimited storage without truncation * Response data accessible in notification templates via heartbeatJSON.response * Add UI controls in monitor edit page with translations (EN) * Only saves response data when explicitly enabled to minimize database impact chore: Tests added fix: Missing response field |
||
|---|---|---|
| .. | ||
| monitor-conditions | ||
| monitors | ||
| notification-providers | ||
| check-translations.test.js | ||
| README.md | ||
| test-cert-hostname-match.js | ||
| test-domain.js | ||
| test-migration.js | ||
| test-monitor-response.js | ||
| test-status-page.js | ||
| test-system-service.js | ||
| test-uptime-calculator.js | ||
| test-util-server.js | ||
| test-util.js | ||
Node.js Test Runner
Documentation: https://nodejs.org/api/test.html
Create a test file in this directory with the name *.js.
Tip
Writing great tests is hard.
You can make our live much simpler by following this guidance:
- Use
describe()to group related tests- Use
test()for individual test cases- One test per scenario
- Use descriptive test names:
function() [behavior] [condition]- Don't prefix with "Test" or "Should"
Template
const { describe, test } = require("node:test");
const assert = require("node:assert");
describe("Feature Name", () => {
test("function() returns expected value when condition is met", () => {
assert.strictEqual(1, 1);
});
});
Run
npm run test-backend