Skip to content

Commit 28c2526

Browse files
authored
tests/acceptance/support-test: Add debugging information for flaky tests (#10795)
1 parent 01ba12d commit 28c2526

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

tests/acceptance/support-test.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { click, currentURL, fillIn, findAll, waitFor } from '@ember/test-helpers';
1+
import { click, currentURL, fillIn, findAll, getSettledState, waitFor } from '@ember/test-helpers';
22
import { module, test } from 'qunit';
33

44
import percySnapshot from '@percy/ember';
@@ -206,7 +206,34 @@ test detail
206206

207207
await visit('/crates/nanomsg');
208208
assert.strictEqual(currentURL(), '/crates/nanomsg');
209-
await waitFor('[data-test-id="link-crate-report"]');
209+
210+
try {
211+
await waitFor('[data-test-id="link-crate-report"]');
212+
} catch (error) {
213+
console.error(error);
214+
console.log(getSettledState());
215+
// display DOM tree for debugging
216+
const walker = document.createTreeWalker(
217+
document.querySelector('main'),
218+
NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT,
219+
);
220+
while (walker.nextNode()) {
221+
let current = walker.currentNode;
222+
if (current.nodeName === '#text') {
223+
let text = current.textContent.trim();
224+
if (text) {
225+
console.log(current.textContent, { current });
226+
}
227+
} else if (current.tagName && current.tagName !== 'path') {
228+
console.log(
229+
current.tagName,
230+
[...(current.attributes ?? [])].map(({ value, name }) => `${name}=${value}`).join(','),
231+
);
232+
}
233+
}
234+
throw error;
235+
}
236+
210237
await click('[data-test-id="link-crate-report"]');
211238
assert.strictEqual(currentURL(), '/support?crate=nanomsg&inquire=crate-violation');
212239
assert.dom('[data-test-id="crate-input"]').hasValue('nanomsg');

0 commit comments

Comments
 (0)