{"id":13054,"library":"d2l-test-reporting","title":"D2L Test Reporting Helpers","description":"This package provides helper utilities and custom reporters for integrating various JavaScript testing frameworks with the D2L test reporting framework. Currently at version 5.0.1, it receives frequent updates, often with bug fixes and occasional major version bumps primarily driven by Node.js engine support changes. Key differentiators include its specialized reporters for popular tools like Mocha, Playwright, `@web/test-runner`, and WebdriverIO, which streamline the process of generating test reports in a format compatible with D2L's internal reporting infrastructure. It is designed to work in conjunction with a companion D2L GitHub Action for uploading these reports to a centralized dashboard. The package is specifically targeted for Node.js environments and expects modern ES Module syntax.","status":"active","version":"5.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/Brightspace/test-reporting-node","tags":["javascript","d2l","test","reporting"],"install":[{"cmd":"npm install d2l-test-reporting","lang":"bash","label":"npm"},{"cmd":"yarn add d2l-test-reporting","lang":"bash","label":"yarn"},{"cmd":"pnpm add d2l-test-reporting","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for the optional WebdriverIO custom reporter functionality, introduced in v4.3.0.","package":"webdriverio","optional":true}],"imports":[{"note":"Named import for the Web Test Runner reporter. This package primarily uses ES Module syntax and requires Node.js >=22.","wrong":"const { reporter } = require('d2l-test-reporting/reporters/web-test-runner.js');","symbol":"reporter","correct":"import { reporter } from 'd2l-test-reporting/reporters/web-test-runner.js';"},{"note":"The Playwright reporter is commonly referenced as a string path within `playwright.config.js` for configuration, but can be imported as an ES Module directly if needed. Node.js >=22 is required.","wrong":"const PlaywrightReporter = require('d2l-test-reporting/reporters/playwright.js');","symbol":"Playwright Reporter Module","correct":"import 'd2l-test-reporting/reporters/playwright.js';"},{"note":"The Mocha reporter is typically configured by specifying its string path in a `.mocharc.js` configuration file, rather than being imported directly into a JavaScript file.","wrong":"import { MochaReporter } from 'd2l-test-reporting/reporters/mocha.js';","symbol":"Mocha Reporter Path","correct":"reporter: 'd2l-test-reporting/reporters/mocha.js'"}],"quickstart":{"code":"import { defineConfig, devices } from '@playwright/test';\nimport path from 'path';\n\nconst reportPath = path.resolve(process.cwd(), './d2l-test-report.json');\nconst reportConfigPath = path.resolve(process.cwd(), './d2l-test-reporting.config.json');\n\nexport default defineConfig({\n  // Configure projects for different browsers or environments\n  projects: [{\n    name: 'chromium',\n    use: { ...devices['Desktop Chrome'] },\n    testMatch: 'test/*.test.ts' // Adjust based on your test file location\n  }],\n  // Look for test files in the 'test' directory, relative to this config file.\n  testDir: './test',\n  // Each test is given 30 seconds to complete.\n  timeout: 30 * 1000,\n  // Reporter to use, integrating the D2L reporter alongside the default 'list' reporter.\n  reporter: [\n    [\n      'd2l-test-reporting/reporters/playwright.js',\n      {\n        reportPath: reportPath, // Optional: Path to output the D2L report\n        reportConfigurationPath: reportConfigPath // Optional: Path to D2L test mapping config\n      }\n    ],\n    ['list'] // Also use the default 'list' reporter for console output\n  ],\n  // Output directory for Playwright's test results.\n  outputDir: './test-results/',\n});\n\n// Example content for d2l-test-reporting.config.json (create this file):\n/*\n{\n  \"testMapping\": {\n    \"my-playwright-test-suite-id\": {\n      \"type\": \"e2e\",\n      \"experience\": \"WebApp\",\n      \"tool\": \"Playwright\"\n    },\n    \"another-test-group\": {\n      \"type\": \"integration\",\n      \"experience\": \"LMS\",\n      \"tool\": \"Playwright\"\n    }\n  }\n}\n*/","lang":"typescript","description":"Configures Playwright to use the `d2l-test-reporting` reporter, specifying output paths for reports and a D2L-specific configuration file for mapping test metadata."},"warnings":[{"fix":"Ensure your Node.js environment is version 22 or higher when using `d2l-test-reporting@5.x.x`. Upgrade Node.js if necessary (e.g., using `nvm install 22 && nvm use 22`).","message":"Version 5.0.0 of `d2l-test-reporting` initially dropped support for Node.js versions 20 and 22. While version 5.0.1 re-enabled support for Node.js 22, Node.js 20 remains unsupported.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Be aware of this limitation; for comprehensive data across matrix runs, manual aggregation or alternative reporting strategies might be necessary, or consider using single-browser runs if complete data per run is critical.","message":"The Playwright `merge-reports` command is not fully supported with `d2l-test-reporting`'s Playwright reporter due to a lack of browser/launcher information preservation with Playwright's `blob` reporter. This can lead to partial data in the reporting dashboard, especially when using GitHub matrix runs.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Monitor your generated reports for unusual or negative test duration values. If consistent issues arise, investigate the specific test conditions or consider using a version prior to 4.2.2 if the reverted fix was critical for your use case.","message":"Version 4.2.2 included a revert of a fix for 'negative duration issues,' which suggests that problems with incorrect or negative test duration calculations might occur or have recurred in certain scenarios.","severity":"gotcha","affected_versions":">=4.2.2"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Update your Node.js environment to version 22 or newer. You can use a tool like `nvm` (Node Version Manager) to manage multiple Node.js versions easily: `nvm install 22 && nvm use 22`.","cause":"The package is being run in a Node.js environment that does not meet the minimum version requirement (>=22) for `d2l-test-reporting@5.x.x`.","error":"Error: This module requires Node.js version 22 or higher. Your current Node.js version is X."},{"fix":"First, ensure `d2l-test-reporting` is installed: `npm install d2l-test-reporting`. Verify that the reporter path in your configuration file (e.g., `playwright.config.js`) exactly matches the provided path. If using a CommonJS setup, consider switching your project to ES Modules or using dynamic `import()` for the reporter if supported by your test runner's configuration.","cause":"The module path for the reporter is incorrect, the `d2l-test-reporting` package is not installed, or there is an attempt to `require()` an ES Module in a CommonJS context without proper transpilation.","error":"Error: Cannot find module 'd2l-test-reporting/reporters/playwright.js' from 'path/to/your/playwright.config.js'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}