From 5f84e726b8ab7d0796e4eab20320cda2f683bc73 Mon Sep 17 00:00:00 2001 From: eth3lbert Date: Mon, 10 Mar 2025 20:26:08 +0800 Subject: [PATCH] tests/acceptance/support-test: Add debugging information for flaky tests --- tests/acceptance/support-test.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/support-test.js b/tests/acceptance/support-test.js index f49b3e51ed0..22a7f092204 100644 --- a/tests/acceptance/support-test.js +++ b/tests/acceptance/support-test.js @@ -1,4 +1,4 @@ -import { click, currentURL, fillIn, findAll, waitFor } from '@ember/test-helpers'; +import { click, currentURL, fillIn, findAll, getSettledState, waitFor } from '@ember/test-helpers'; import { module, test } from 'qunit'; import percySnapshot from '@percy/ember'; @@ -206,7 +206,34 @@ test detail await visit('/crates/nanomsg'); assert.strictEqual(currentURL(), '/crates/nanomsg'); - await waitFor('[data-test-id="link-crate-report"]'); + + try { + await waitFor('[data-test-id="link-crate-report"]'); + } catch (error) { + console.error(error); + console.log(getSettledState()); + // display DOM tree for debugging + const walker = document.createTreeWalker( + document.querySelector('main'), + NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT, + ); + while (walker.nextNode()) { + let current = walker.currentNode; + if (current.nodeName === '#text') { + let text = current.textContent.trim(); + if (text) { + console.log(current.textContent, { current }); + } + } else if (current.tagName && current.tagName !== 'path') { + console.log( + current.tagName, + [...(current.attributes ?? [])].map(({ value, name }) => `${name}=${value}`).join(','), + ); + } + } + throw error; + } + await click('[data-test-id="link-crate-report"]'); assert.strictEqual(currentURL(), '/support?crate=nanomsg&inquire=crate-violation'); assert.dom('[data-test-id="crate-input"]').hasValue('nanomsg');