mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
feat: enhance HTML report generation by including environment name (#6055)
This commit is contained in:
73
packages/bruno-cli/tests/reporters/html.spec.js
Normal file
73
packages/bruno-cli/tests/reporters/html.spec.js
Normal file
@@ -0,0 +1,73 @@
|
||||
const { describe, it, expect } = require('@jest/globals');
|
||||
const fs = require('fs');
|
||||
|
||||
const mockGenerateHtmlReport = jest.fn(() => '<html>Mock HTML</html>');
|
||||
|
||||
jest.mock('@usebruno/common/runner', () => ({
|
||||
generateHtmlReport: mockGenerateHtmlReport
|
||||
}));
|
||||
|
||||
const makeHtmlOutput = require('../../src/reporters/html');
|
||||
|
||||
describe('makeHtmlOutput', () => {
|
||||
let writeFileSyncSpy;
|
||||
|
||||
beforeEach(() => {
|
||||
mockGenerateHtmlReport.mockClear();
|
||||
writeFileSyncSpy = jest.spyOn(fs, 'writeFileSync').mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('should pass environment parameter to generateHtmlReport when provided', async () => {
|
||||
const mockResults = {
|
||||
results: [],
|
||||
summary: {
|
||||
totalRequests: 0,
|
||||
passedRequests: 0,
|
||||
failedRequests: 0,
|
||||
errorRequests: 0,
|
||||
skippedRequests: 0,
|
||||
totalAssertions: 0,
|
||||
passedAssertions: 0,
|
||||
failedAssertions: 0,
|
||||
totalTests: 0,
|
||||
passedTests: 0,
|
||||
failedTests: 0
|
||||
}
|
||||
};
|
||||
|
||||
await makeHtmlOutput(mockResults, '/tmp/test.html', '2024-01-15T14:30:45.123Z', 'production');
|
||||
|
||||
expect(mockGenerateHtmlReport).toHaveBeenCalledWith(expect.objectContaining({
|
||||
environment: 'production'
|
||||
}));
|
||||
});
|
||||
|
||||
it('should pass null environment when not provided', async () => {
|
||||
const mockResults = {
|
||||
results: [],
|
||||
summary: {
|
||||
totalRequests: 0,
|
||||
passedRequests: 0,
|
||||
failedRequests: 0,
|
||||
errorRequests: 0,
|
||||
skippedRequests: 0,
|
||||
totalAssertions: 0,
|
||||
passedAssertions: 0,
|
||||
failedAssertions: 0,
|
||||
totalTests: 0,
|
||||
passedTests: 0,
|
||||
failedTests: 0
|
||||
}
|
||||
};
|
||||
|
||||
await makeHtmlOutput(mockResults, '/tmp/test.html', '2024-01-15T14:30:45.123Z');
|
||||
|
||||
expect(mockGenerateHtmlReport).toHaveBeenCalledWith(expect.objectContaining({
|
||||
environment: null
|
||||
}));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user