Cypress AngularJS Unit Test Adapter

1.2.1 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

import { mount } from 'cypress-angularjs-unit-test'
import angular from 'angular'

angular.module('demo', [])
  .controller('WelcomeController', function($scope) {
    $scope.greeting = 'Welcome!';
    $scope.version = angular.version.full
  });

beforeEach(() => {
  // Let's mount our "demo" module and its controller
  // in a "mini app" before each test
  const template = `
    <div ng-controller="WelcomeController">
      {{greeting}}
      ng {{version}}
    </div>
  `
  mount(template, ['demo'])
})

it('shows welcome message and Angular version', () => {
  // "WelcomeController" should have replaced template
  // expression {{greeting}} with actual text
  cy.contains('div', 'Welcome!').should('be.visible')
  cy.contains('div', `ng ${angular.version.full}`).should('be.visible')
  cy.screenshot('welcome-message');
})

view raw JSON →