mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-23 12:45:38 +00:00
* feat: add support for skipped files in run command and update HTML report template * refactor: enhance skipped file handling in run command * fix: improve error display in HTML report for skipped requests * test: add unit test for HTML report generation of skipped requests with parsing errors * test: update HTML report generation tests to check for skipped request summaries * refactor: extract skipped result creation logic into a separate utility function * refactor: enhance skipped result processing in run command to include additional metadata * refactor: rename and enhance createSkippedResults function for improved skipped file processing * refactor: remove unused stripExtension import from run command * refactor: rename createSkippedResults to createSkippedFileResults for clarity and consistency
114 lines
3.4 KiB
JavaScript
114 lines
3.4 KiB
JavaScript
const { describe, it, expect } = require('@jest/globals');
|
|
const { generateHtmlReport } = require('@usebruno/common/runner');
|
|
|
|
describe('HTML Report Generation', () => {
|
|
it('should include all metadata in the HTML report', async () => {
|
|
// Sample test results
|
|
const mockResults = [
|
|
{
|
|
iterationIndex: 0,
|
|
environment: 'production',
|
|
results: [],
|
|
summary: {
|
|
totalRequests: 1,
|
|
passedRequests: 1,
|
|
failedRequests: 0,
|
|
errorRequests: 0,
|
|
skippedRequests: 0,
|
|
totalAssertions: 0,
|
|
passedAssertions: 0,
|
|
failedAssertions: 0,
|
|
totalTests: 0,
|
|
passedTests: 0,
|
|
failedTests: 0
|
|
}
|
|
}
|
|
];
|
|
|
|
// Generate HTML using mock data
|
|
const htmlString = generateHtmlReport({
|
|
runnerResults: mockResults,
|
|
version: 'usebruno v1.16.0',
|
|
environment: 'production',
|
|
runCompletionTime: '2024-01-15T14:30:45.123Z'
|
|
});
|
|
|
|
// Verify the HTML contains expected metadata structure
|
|
expect(htmlString).toContain('Bruno run dashboard');
|
|
expect(htmlString).toContain('Date & Time');
|
|
expect(htmlString).toContain('Version');
|
|
expect(htmlString).toContain('Environment');
|
|
expect(htmlString).toContain('Total run duration');
|
|
expect(htmlString).toContain('Total data received');
|
|
expect(htmlString).toContain('Average response time');
|
|
|
|
expect(htmlString).toContain('{{ runCompletionTime }}');
|
|
expect(htmlString).toContain('{{ brunoVersion }}');
|
|
expect(htmlString).toContain('{{ environment }}');
|
|
expect(htmlString).toContain('{{ totalDuration }}');
|
|
expect(htmlString).toContain('{{ totalDataReceived }}');
|
|
expect(htmlString).toContain('{{ averageResponseTime }}');
|
|
});
|
|
|
|
it('should include skipped requests with parsing errors in the HTML report', async () => {
|
|
const mockResults = [
|
|
{
|
|
iterationIndex: 0,
|
|
results: [
|
|
{
|
|
test: {
|
|
filename: 'invalid-request.bru'
|
|
},
|
|
request: {
|
|
method: null,
|
|
url: null,
|
|
headers: null,
|
|
data: null
|
|
},
|
|
response: {
|
|
status: 'skipped',
|
|
statusText: 'Unexpected token',
|
|
data: null,
|
|
responseTime: 0
|
|
},
|
|
error: 'Unexpected token',
|
|
status: 'skipped',
|
|
skipped: true,
|
|
assertionResults: [],
|
|
testResults: [],
|
|
preRequestTestResults: [],
|
|
postResponseTestResults: [],
|
|
name: 'invalid-request.bru',
|
|
path: 'invalid-request.bru',
|
|
runDuration: 0
|
|
}
|
|
],
|
|
summary: {
|
|
totalRequests: 1,
|
|
passedRequests: 0,
|
|
failedRequests: 0,
|
|
errorRequests: 0,
|
|
skippedRequests: 1,
|
|
totalAssertions: 0,
|
|
passedAssertions: 0,
|
|
failedAssertions: 0,
|
|
totalTests: 0,
|
|
passedTests: 0,
|
|
failedTests: 0
|
|
}
|
|
}
|
|
];
|
|
|
|
const htmlString = generateHtmlReport({
|
|
runnerResults: mockResults,
|
|
version: 'usebruno v1.16.0',
|
|
environment: null,
|
|
runCompletionTime: '2024-01-15T14:30:45.123Z'
|
|
});
|
|
|
|
expect(htmlString).toContain('Request Skipped');
|
|
expect(htmlString).toContain('summarySkippedRequests');
|
|
expect(htmlString).toContain('result.response.status === \'skipped\'');
|
|
});
|
|
});
|