Skip to content

Commit

Permalink
E2E Test Utils: Display page error message in failure output
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Apr 7, 2020
1 parent 965900a commit 228aad3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/e2e-test-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Master

### Enhancements

- `visitAdminPage` will now throw an error (emit a test failure) when there are unexpected errors on hte page.

### New Features

- Added `getPageError` function, returning a promise which resolves to an error message present in the page, if any exists.
Expand Down
5 changes: 4 additions & 1 deletion packages/e2e-test-utils/src/visit-admin-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ export async function visitAdminPage( adminPath, query ) {
await visitAdminPage( adminPath, query );
}

expect( await getPageError() ).toBe( null );
const error = await getPageError();
if ( error ) {
throw new Error( 'Unexpected error in page content: ' + error );
}
}

0 comments on commit 228aad3

Please sign in to comment.