Add console logs to all Nightwatch tests

Created on 30 September 2019, about 5 years ago
Updated 23 January 2024, 11 months ago

Problem/Motivation

It seems like #3059356: [Security] Update yarn packages to fix 19 vulnerabilities by updating nightwatch broke the functionality to write logs to the file system after test run.

Proposed resolution

Write logs when test case has enabled this functionality.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Javascript 

Last updated about 22 hours ago

Created by

🇫🇮Finland lauriii Finland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • 🇮🇳India nikhil_110

    Attached patch against Drupal 10.1.x

    Patch #14 is not applied for Drupal 10.1.x so Inter-diff file is not added.

    Checking patch core/tests/Drupal/Nightwatch/Commands/drupalLogAndEnd.js...
    Checking patch core/tests/Drupal/Nightwatch/Tests/loginTest.js...
    error: while searching for:
          .drupalRelativeURL('/admin/reports')
          .waitForElementVisible('body', 1000)
          .assert.containsText('h1', 'Reports')
          .assert.noDeprecationErrors();
      },
    };
    
    error: patch failed: core/tests/Drupal/Nightwatch/Tests/loginTest.js:19
    error: core/tests/Drupal/Nightwatch/Tests/loginTest.js: patch does not apply
    Checking patch core/tests/Drupal/Nightwatch/Tests/statesTest.js...
    error: while searching for:
          .drupalRelativeURL('/form-test/javascript-states-form')
          .waitForElementVisible('body', 1000)
          .waitForElementNotVisible('input[name="textfield"]', 1000)
          .assert.noDeprecationErrors();
      },
    };
    
    error: patch failed: core/tests/Drupal/Nightwatch/Tests/statesTest.js:19
    error: core/tests/Drupal/Nightwatch/Tests/statesTest.js: patch does not apply
    Checking patch core/tests/Drupal/Nightwatch/globals.js...
    error: while searching for:
    
    export const drupalDbPrefix = null;
    export const drupalSitePath = null;
    
    module.exports = {
      before: done => {
    
    error: patch failed: core/tests/Drupal/Nightwatch/globals.js:14
    error: core/tests/Drupal/Nightwatch/globals.js: patch does not apply
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    10:17
    8:09
    Running
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,304 pass
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • Assigned to spokje
  • Merge request !6076Alledged consoleLog fix → (Open) created by spokje
  • Pipeline finished with Success
    11 months ago
    #74009
  • Pipeline finished with Success
    11 months ago
    #74015
  • 🇳🇱Netherlands spokje

    I applied the consoleLog fix to the first commit in the MR and then reversed it in the second commit.

    I compared the consoleLogs from the artifacts of both Nightwatch GitLab CI jobs and besides some timestamps they are exactly equal.
    So, as far as I can see, there's currently no problem with the consoleLogs and there's no need for a fix.

    However it is a good idea to add consoleLogs to as much Nightwatch tests as possible, so I'm going to repurpose this issue for that cause.

  • Pipeline finished with Success
    11 months ago
    #74035
  • Pipeline finished with Failed
    11 months ago
    #74084
  • Pipeline finished with Success
    11 months ago
    #74087
  • Pipeline finished with Failed
    11 months ago
    #81352
  • Pipeline finished with Canceled
    11 months ago
    #81355
  • Pipeline finished with Failed
    11 months ago
    #81365
  • Pipeline finished with Success
    11 months ago
    #81366
  • Pipeline finished with Success
    11 months ago
    #81392
  • Issue was unassigned.
  • 🇳🇱Netherlands spokje

    So I think the approach taken in core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarApiTest.js should be the one to go for IMHO.

    Sadly since logAndEnd works with the _global_ test hooks, which means the afterEach in there will only run after each testsuite instead of each single test, this isn't going to work with altering logAndEnd.

    I'll leave that for somebody else, I've tried real hard to learn to love Nightwatch, but it's just not happening for me.
    I'm going to leave it alone and spend my time on other stuff in core.

Production build 0.71.5 2024