angularseleniumprotractorcucumberangular-e2e

Angular Cucumber not finding any test to execute


I am trying to run e2e tests with cucumber. I have followed the steps here, and run my e2e tests. However, no tests are found. Why are no test being found?

The console output is as follows:

$ webdriver-manager update --no-gecko --ignore_ssl && ng e2e --no-webdriver-update --protractor-config e2e/protractor.conf.lcl.js

[14:54:54] I/http_utils - ignoring SSL certificate
[14:54:54] I/config_source - curl -ok /Users/rnaddy/Documents/vscode/projects/user-management-ui/node_modules/protractor/node_modules/webdriver-manager/selenium/standalone-response.xml https://selenium-release.storage.googleapis.com/
[14:54:54] I/http_utils - ignoring SSL certificate
[14:54:54] I/config_source - curl -ok /Users/rnaddy/Documents/vscode/projects/user-management-ui/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
[14:54:54] I/http_utils - ignoring SSL certificate
[14:54:54] I/http_utils - ignoring SSL certificate
[14:54:54] I/http_utils - ignoring SSL certificate
[14:54:55] I/http_utils - ignoring SSL certificate
[14:54:55] I/http_utils - ignoring SSL certificate
[14:54:55] I/update - chromedriver: file exists /Users/rnaddy/Documents/vscode/projects/user-management-ui/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_85.0.4183.87.zip
[14:54:55] I/update - chromedriver: unzipping chromedriver_85.0.4183.87.zip
[14:54:55] I/update - chromedriver: setting permissions to 0755 for /Users/rnaddy/Documents/vscode/projects/user-management-ui/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_85.0.4183.87
[14:54:55] I/update - chromedriver: chromedriver_85.0.4183.87 up to date
[14:54:55] I/update - selenium standalone: file exists /Users/rnaddy/Documents/vscode/projects/user-management-ui/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar
[14:54:55] I/update - selenium standalone: selenium-server-standalone-3.141.59.jar up to date

chunk {main} main.js, main.js.map (main) 1.04 MB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 438 kB [initial] [rendered]
chunk {polyfills-es5} polyfills-es5.js, polyfills-es5.js.map (polyfills-es5) 694 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 1.28 MB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 11.2 MB [initial] [rendered]
Date: 2020-09-23T19:55:19.109Z - Hash: 1453b65c5aa3bb581d3d - Time: 15205ms
** Angular Live Development Server is listening on localhost:4200, open your browser on https://localhost:4200/ **
: Compiled successfully.
[14:55:19] I/launcher - Running 1 instances of WebDriver
[14:55:19] I/local - Starting selenium standalone server...
[14:55:20] I/local - Selenium standalone server started at http://192.168.1.106:49459/wd/hub


0 scenarios
0 steps
0m00.000s
[14:55:24] I/local - Shutting down selenium standalone server.
[14:55:24] I/launcher - 0 instance(s) of WebDriver still running
[14:55:24] I/launcher - chrome #01 passed
Invalid Cucumber JSON file found under ./e2e/reports: e2e/reports/cucumber_report.33165.json

šŸš€ Cucumber HTML report ./e2e/reports/cucumber_report.html generated successfully šŸ‘

The folder structure looks like this:

e2e
  src
    features
      home-page.feature
    pages
      home-page.po.ts
    steps
      home-page.steps.ts
  protractor.conf.lcl.js
  tsconfig.e2e.json

And the configuration looks like this:

// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const fs = require('fs-extra')
const path = require('path')

/** @type {import('protractor').Config} */
exports.config = {
  allScriptsTimeout: 800000,
  getPageTimeout: 400000,
  specs: ['./src/features/**/*.feature'],
  params: {
    pageObjects: require['./src/pages/**/*.po.ts'],
    customTimeout: 200000
  },
  capabilities: {
    browserName: 'chrome',
    shardTestFiles: true,
    maxInstances: 1
  },
  // Only works with Chrome and Firefox
  directConnect: false,
  baseUrl: 'https://localhost:4200/',
  useAllAngular2AppRoots: true,
  framework: 'custom',
  frameworkPath: require.resolve('protractor-cucumber-framework'),
  cucumberOpts: {
    compiler: 'ts:ts-node/register',
    require: ['./src/steps/**/*.steps.ts'],
    format: 'json:e2e/reports/cucumber_report.json',
    monochrome: true,
    strict: true,
    tags: '@Regression'
  },
  beforeLaunch: () => {
    // Delete old report files
  },
  onPrepare() {
    // If you need to navigate to a page which does not use Angular,
    // you can turn off waiting for Angular
    browser.ignoreSynchronization = true
    require('ts-node').register({
      project: path.join(__dirname, './tsconfig.e2e.json')
    })
  },
  afterLaunch: () => {
    var reporter = require('cucumber-html-reporter')
    var options = {
      theme: 'bootstrap',
      jsonDir: './e2e/reports',
      jsonFile: './e2e/reports/cucumber_report.html.json',
      output: './e2e/reports/cucumber_report.html',
      ignoreBadJsonFile: true,
      reportSuiteAsScenarios: true,
      launchReport: false,
      metadata: {
        'App Version': '0.3.2',
        'Test Environment': 'STAGING',
        'Browser': 'Chrome 80.0.3987.163',
        'Platform': 'Mac',
        'Parallel': 'Scenarios',
        'Executed': 'Remote'
      }
    }
    reporter.generate(options)
  },
}

Here is the feature:

Feature: Go to the home page
  Scenario: Home Page
    Given I am on the home page
    When I do nothing
    Then I should see the title

Here is the steps:

import { expect } from 'chai';
import { Before, Given, Then, When } from 'cucumber';
import { HomePage } from '../pages/home-page.po';


let home: HomePage;

Before(() => {
  home = new HomePage();
});

Given('I am on the home page', async () => {
  await home.navigateHome();
});

When('I do nothing', () => { });

Then('I should see the title', async () => {
  expect(await home.getTitleText()).to.equal('Login');
});

Solution

  • specs: ['./src/features/*.feature'],
    

    Please update path for features in config. Actually features were not dedected.

    Add @Regression in the feature file before your scenario