This package enables unit testing of AngularJS (Angular 1.x) values, services, controllers, and components directly within the Cypress.io test runner. It allows developers to leverage Cypress's powerful features, such as DOM snapshots and time-travel debugging, for individual AngularJS units, providing a comprehensive debugging experience similar to end-to-end tests. The current stable version is 1.2.1, released in April 2018. Given the last release date and its 'BETA' designation in the README, the project appears unmaintained. Its primary differentiator was bringing Cypress's robust E2E testing environment to the unit testing of AngularJS applications. It's crucial to note that AngularJS itself reached End-of-Life (EOL) on December 31, 2021, meaning it no longer receives official updates or security patches, which significantly impacts the relevance and security of this package.
npm install cypress-angularjs-unit-testVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to define an AngularJS module and controller, then mount a component using `mount` in a Cypress test. It verifies the rendered content with Cypress commands.
Consider migrating to a modern framework like Angular (2+) or React. If migration is not immediately feasible for legacy AngularJS applications, explore extended long-term support (LTS) options from providers like OpenLogic or HeroDevs for security patches and compatibility fixes.
Downgrade Cypress to a version compatible with `^2.1.0` (e.g., Cypress 3.x or lower if possible) or refrain from using this unmaintained package. Modern Cypress (v10+) offers built-in component testing features for frameworks like Angular, which would be the recommended approach for newer Angular applications.
Do not use this package for new projects. For existing legacy AngularJS applications, proceed with caution and be prepared to debug and potentially fork the package for any necessary fixes or adaptations.
Install AngularJS as a project dependency: `npm install angular@^1.6.9 --save-dev`.
Ensure your `cypress.json` and `cypress/plugins/index.js` are configured correctly if using an older Cypress. However, the core issue is likely the overall age and incompatibility with modern tooling. Consider alternatives for testing.
Change your import statement from `import mount from 'cypress-angularjs-unit-test'` to `import { mount } from 'cypress-angularjs-unit-test'` for ESM, or use `const { mount } = require('cypress-angularjs-unit-test')` for CommonJS.