This package provides a dedicated reporter for Protractor, the end-to-end testing framework, specifically designed for use with Jasmine2. It automatically captures screenshots after each executed test case, whether passing or failing, and consolidates them into a single HTML report. Key features include configurable output directories, custom report filenames, the ability to include external CSS and JavaScript for custom styling and interactivity, and options to ignore pending specs or capture screenshots only for failed tests. The current stable version is 0.5.1. Given that its primary dependency, Protractor, was officially deprecated in 2022 and this reporter has not seen updates since 2016, it is effectively an abandoned project. There is no active release cadence, and it is not recommended for new projects.
npm install protractor-jasmine2-screenshot-reporterVerified import paths — ran on the pinned version, not inferred.
This configuration snippet demonstrates how to integrate `protractor-jasmine2-screenshot-reporter` into a Protractor `conf.js` file, setting up the reporter lifecycle methods for `beforeLaunch`, `onPrepare`, and `afterLaunch` to capture screenshots and generate an HTML report.
For new projects, consider modern alternatives like Cypress, Playwright, or WebdriverIO, which have built-in screenshot capabilities and active development. For existing Protractor projects, be aware that this reporter may not receive updates or bug fixes.
If running tests in parallel or needing to preserve previous reports, set `cleanDestination: false` in the reporter options. When disabling `cleanDestination`, it's also recommended to set `showSummary: false`, `showConfiguration: false`, and `reportTitle: null` to avoid cluttered reports from multiple runs.
Ensure your Protractor configuration file (`conf.js`) uses CommonJS `require()` syntax. If you are in an ESM project, you might need to use a CommonJS wrapper or configure your build system to correctly handle CommonJS modules.
Create a declaration file (e.g., `protractor-jasmine2-screenshot-reporter.d.ts`) in your project with `declare module 'protractor-jasmine2-screenshot-reporter';` or `declare var HtmlScreenshotReporter: any;` to provide basic type information, or use `@ts-ignore` for the import line.
Ensure `reporter.beforeLaunch` is called within a `new Promise()` block and returns that promise, as shown in the quickstart example: `return new Promise(function(resolve){ reporter.beforeLaunch(resolve); });`Verify that the `dest` path in the reporter options is correct and writable. Check the console for any error messages during test execution. If `captureOnlyFailedSpecs` is true, ensure there are failing tests to trigger screenshot capture. If no report file appears, check for errors during `afterLaunch` or verify the `filename` option.
Ensure your Protractor configuration file (`conf.js`) is treated as a CommonJS module. If your project is ESM-first, you may need to use `.cjs` file extension for the config or ensure your `package.json`'s `type` field isn't set to `module` for the relevant directory, or configure your bundler to handle CommonJS imports.