Protractor with Jasmine was a standard stack for Angular end-to-end (E2E) testing. However, Protractor is now deprecated (as of 2023), and teams are migrating to tools like Playwright, Cypress, or WebdriverIO.

That said, if you’re maintaining a legacy Protractor + Jasmine setup, here’s how it works:

Tech Stack

ToolPurpose
ProtractorE2E test framework for Angular apps
JasmineBDD-style testing framework
Node.jsJavaScript runtime

1. Install Protractor (if still needed)

npm install -g protractor

Install locally in a project:

npm init -y npm install --save-dev protractor jasmine

2. Config File (protractor.conf.js)

exports.config = { framework: 'jasmine', seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['specs/login.spec.js'], capabilities: { browserName: 'chrome' } };

3. Jasmine Test Spec (specs/login.spec.js)

describe('Login Page', function() { it('should log in with valid credentials', function() { browser.get('https://example.com/login'); element(by.id('username')).sendKeys('testuser'); element(by.id('password')).sendKeys('testpass'); element(by.id('login')).click(); let logoutButton = element(by.id('logout')); expect(logoutButton.isDisplayed()).toBe(true); }); });

4. Run the Test

  1. Start Selenium Server (if using WebDriver):

 
webdriver-manager update webdriver-manager start
  1. Run Protractor:

 
protractor protractor.conf.js

Deprecation Note

Protractor was deprecated and is no longer maintained.
It’s recommended to migrate to:

  • Cypress

  • Playwright

  • WebdriverIO