Skip to content

Codeceptjs+puppeteer tests are hanging if testing application is down #2406

@aelzhanova

Description

@aelzhanova

Sometimes when I run tests my testing application is down, but I don't know about it. I waited that my tests will fail

My tests are hanging and will never end

Provide console output if related. Use --verbose mode for more details.

CodeceptJS v2.6.3
Using test root "..."
Helpers: Puppeteer, ResembleHelper, REST, MockRequestHelper, allureHelper
Plugins: screenshotOnFail, allure, customLocator, autoLogin

My list tests --
    [1] Starting recording promises
    Emitted | suite.before ([object Object])
 › [Session] Starting singleton browser session
  Filter price cards by category
    Emitted | test.before ([object Object])
    Emitted | hook.start ([object Object])
    [1] Starting <check login> session
    Emitted | step.before (I see "#24")
    Emitted | step.after (I see "#24")
    Emitted | step.before (I dont see element "//input[@name='userName']")
    Emitted | step.after (I dont see element "//input[@name='userName']")
    Emitted | step.start (I see "#24")
    I see "#24"
    [1] <check login> Error | Error
    Emitted | step.failed (I see "#24")
    Emitted | step.finish (I see "#24")
    [1] <check login> Error | Error
    Emitted | step.failed (I dont see element "//input[@name='userName']")
    Emitted | step.finish (I dont see element "//input[@name='userName']")
 › Failed auto login for admin118 due to Error
 › Logging in again
    [1] <check login> Starting <auto login> session
    Emitted | step.before (I am on page "/signin")
    Emitted | step.after (I am on page "/signin")
    Emitted | step.before (I wait for element "//input[@name='userName']", 5)
    Emitted | step.after (I wait for element "//input[@name='userName']", 5)
    Emitted | step.before (I fill field "//input[@name='userName']", "[email protected]")
    Emitted | step.after (I fill field "//input[@name='userName']", "[email protected]")
    Emitted | step.before (I fill field "//input[@type='password']", "12345")
    Emitted | step.after (I fill field "//input[@type='password']", "12345")
    Emitted | step.before (I click "button[type='submit']")
    Emitted | step.after (I click "button[type='submit']")
    Emitted | step.before (I wait for text "#24", 10)
    Emitted | step.after (I wait for text "#24", 10)
    Emitted | step.before (I wait for invisible "//input[@type='password']", 10)
    Emitted | step.after (I wait for invisible "//input[@type='password']", 10)
 › Saved user session into file for admin118
    [1] <auto login> Finalize <check login> session
    Emitted | step.start (I am on page "/signin")
    I am on page "/signin"
    [1] Error | Error: net::ERR_CONNECTION_REFUSED at http://localhost:8080/signin
    Emitted | step.failed (I am on page "/signin")
    Emitted | step.finish (I am on page "/signin")
    [1] Error | Error: net::ERR_CONNECTION_REFUSED at http://localhost:8080/signin
    Emitted | step.failed (I wait for element "//input[@name='userName']", 5)
    Emitted | step.finish (I wait for element "//input[@name='userName']", 5)
    [1] Error | Error: net::ERR_CONNECTION_REFUSED at http://localhost:8080/signin
    Emitted | step.failed (I fill field "//input[@name='userName']", "[email protected]")
    Emitted | step.finish (I fill field "//input[@name='userName']", "[email protected]")
    [1] Error | Error: net::ERR_CONNECTION_REFUSED at http://localhost:8080/signin
    Emitted | step.failed (I fill field "//input[@type='password']", "12345")
    Emitted | step.finish (I fill field "//input[@type='password']", "12345")
    [1] Error | Error: net::ERR_CONNECTION_REFUSED at http://localhost:8080/signin
    Emitted | step.failed (I click "button[type='submit']")
    Emitted | step.finish (I click "button[type='submit']")
    [1] Error | Error: net::ERR_CONNECTION_REFUSED at http://localhost:8080/signin
    Emitted | step.failed (I wait for text "#24", 10)
    Emitted | step.finish (I wait for text "#24", 10)
    [1] Error | Error: net::ERR_CONNECTION_REFUSED at http://localhost:8080/signin
    Emitted | step.failed (I wait for invisible "//input[@type='password']", 10)
    Emitted | step.finish (I wait for invisible "//input[@type='password']", 10)
    [1] Error | Error: net::ERR_CONNECTION_REFUSED at http://localhost:8080/signin
 › continue
    [1] Stopping recording promises
    Emitted | hook.passed ([object Object])
    Emitted | test.start ([object Object])
 › [Url] http://localhost:8080/signin

Provide test source code if related

Feature('My list tests');

const {
  pageURLs, loginAs
} = inject();

Before(async () => {
  await loginAs('admin118');
});

Scenario.only('Open page by url', () => {
    I.amOnPage(pageURLs.PRICES.priceManagement);
});

Details

  • CodeceptJS version: 2.6.3
  • NodeJS Version:
  • Operating System:
  • puppeteer 2.0.0
  • Configuration file:
const data = require('./src/dictionaries/data');

const config = {
  helpers: {
    Puppeteer: {
      url: process.env.CODECEPT_URL || 'http://localhost:8080',
      show: false,
      browser: 'chrome',
      windowSize: '1920x1080',
      waitForAction: 0,
      waitForNavigation: 'load',
      waitForTimeout: 5000,
      restart: false,
      keepBrowserState: true,
      typeInterval: '-1',
      chrome: {
        args: ['--no-sandbox', '--headless', '--window-size=1920,1080', '--disable-web-security'],
        ignoreHTTPSErrors: true,
      },
      capabilities: {
        chromeOptions: {
          w3c: false,
        },
      },
    },
  },

  include: {
    I: './steps_file.js',
    // dictionaries
    data: './src/dictionaries/data.js',
    pageURLs: './src/dictionaries/pageURLs.js',
  },
  multiple: {
    parallel: {
      // Splits tests into 8 chunks
      chunks: 8,
    },
  },
  mocha: {
    reporterOptions: {
      reportDir: './report',
      autoOpen: true,
    },
  },
  plugins: {
    allure: {
      enabled: true,
      outputDir: './allure-results',
      enableScreenshotDiffPlugin: true,
    },
    stepByStepReport: {},
    customLocator: {
      enabled: true,
      attribute: 'data-test-id',
    },
    autoLogin: {
      enabled: true,
      saveToFile: true,
      inject: 'loginAs',
      users: {
        admin118: {
          login: async (I) => {
            await I.login(data.24_ADMIN);
          },
          check: (I) => {
            I.see(data.24_ADMIN.companyName);
            I.dontSeeElement("//input[@name='userName']");
          },
          fetch: () => true, // not necessary due to "keepCookies" option
          restore: () => {}, // not necessary due to "keepCookies" option
        },
      },
    },
  },
  tests: './tests/**/*.js',
  name: 'e2e',
};

exports.config = config;

steps_file.js

// in this file you can append custom step methods to 'I' object

module.exports = function() {
  return actor({
    async login(user) {
      this.amOnPage('/signin');
      this.waitForElement("//input[@name='userName']", 5);
      this.fillField("//input[@name='userName']", user.email);
      this.fillField("//input[@type='password']", user.password);
      this.click("button[type='submit']");
      this.waitForText(user.companyName, 10);
      this.waitForInvisible("//input[@type='password']", 10);
    },
  });
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions