mocha-multiple-session-detailed-runner-ui
v1.0.2
Published
UI for Multi-Session Detailed Runner with vanilla TypeScript (no dependencies)
Maintainers
Readme
Mocha Multiple Session Detailed Runner UI
A UI library for displaying multi-session test results from the mocha-multiple-sessions-detailed-runner.
✨ Features
- Display test session results with detailed reports
- Show combined reports across multiple test sessions
- Vanilla JavaScript implementation with no runtime dependencies
- Light and dark theme support
- Interactive test result exploration
- Compatible with mocha-detailed-json-reporter-ui
🚀 Installation
npm install mocha-multiple-session-detailed-runner-ui📋 Usage
Basic Usage with CDN
<!-- Include the UI library and stylesheet -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/iife/multi-session-detailed-runner-ui.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/build/css/multi-session-detailed-runner-ui.min.css">
<!-- Include the detailed reporter UI -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/iife/mocha-report-ui.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/mocha-report.css">
<script>
// Create a UI instance
const ui = MultiSessionDetailedRunnerUI.createMultiSessionRunnerUI('container-id', {
theme: 'light',
expandFailures: true,
showConsoleLogs: true
});
// Render a session report
ui.renderReport(sessionReport);
// Render combined report
ui.renderCombinedReport(combinedReport);
</script>Integration with Multi-Session Detailed Runner
// Create the runner
const runner = MultiSessionDetailedRunner.createMultiSessionDetailedRunner();
// Initialize the UI
const ui = createMultiSessionRunnerUI('container-id', {
theme: 'light',
expandFailures: true,
showConsoleLogs: true,
onSessionSelect: (sessionLabel) => {
// When user selects a session, show its report
const report = runner.getReport(sessionLabel);
if (report) {
ui.renderReport(report);
}
}
});
// Run a test session
const result = await runner.run('unit-tests');
// Update UI with current session states
ui.renderSessions(runner.getSessionStates());
// Render the test report
const report = runner.getReport('unit-tests');
ui.renderReport(report);🔧 API Reference
createMultiSessionRunnerUI(containerId, options)
Creates a new UI instance for displaying test reports.
Parameters:
containerId(string): The ID of the container elementoptions(object): Configuration optionstheme('light' | 'dark'): UI themeexpandFailures(boolean): Auto-expand failed testsshowConsoleLogs(boolean): Show console logs in reportsrenderSessionsView(boolean): Show sessions sidebaronSessionSelect(function): Called when a session is selected
Returns:
MultiSessionRunnerUIinstance with the following methods:renderSessions(sessionStates): Render the session listrenderReport(report): Render a detailed test reportrenderCombinedReport(combinedReport): Render a combined reportshowEmptyState(message): Show an empty state messagesetTheme(theme): Set the UI theme ('light' | 'dark')
📝 License
MIT
