Skip to content

Commit

Permalink
Fixes e2e test failures via console log exception to handle temp `wpn…
Browse files Browse the repository at this point in the history
…once` error (#19532)

* Adds console log exception to handle temp wp nonce error

>  [DOM] Found 2 elements with non-unique id #_wpnonce: (More info: https://goo.gl/9p2vKq)

This error was getting logged to console when running e2e tests locally and causing my tests to fail. It’s a known issue with WordPress:
https://core.trac.wordpress.org/ticket/23165.

This commit adds a new condition to console log exception handling to ensure console logs containing this message are ignored and do not trigger test failures.

See also https://wordpress.slack.com/archives/C02QB2JS7/p1578578973183100

* Refactor to make test for console msg more resilient and tollerant
  • Loading branch information
getdave authored Jan 10, 2020
1 parent 19c40af commit 256f67c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/e2e-tests/config/setup-test-framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ function observeConsoleLogging() {
return;
}

// As of WordPress 5.3.2 in Chrome 79, navigating to the block editor
// (Posts > Add New) will display a console warning about
// non - unique IDs.
// See: https://core.trac.wordpress.org/ticket/23165
if ( text.includes( 'elements with non-unique id #_wpnonce' ) ) {
return;
}

const logFunction = OBSERVED_CONSOLE_MESSAGE_TYPES[ type ];

// As of Puppeteer 1.6.1, `message.text()` wrongly returns an object of
Expand Down

0 comments on commit 256f67c

Please sign in to comment.