Skip to content

Commit

Permalink
Better errors from visitable
Browse files Browse the repository at this point in the history
This adds the actual error message from Ember's router to the (too generic) message from `visitable`. This is especially important when your test needs to know what kind of error was triggered. For example some tests might want to handle `TransitionAborted` errors differently, see emberjs/ember-test-helpers#332 (comment).
  • Loading branch information
simonihmig committed Feb 28, 2024
1 parent a290565 commit 2eed933
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions addon/src/properties/visitable.js
Expand Up @@ -138,8 +138,8 @@ export function visitable(path) {

return getAdapter()
.visit(fullPath)
.catch(() => {
throw new Error(`Failed to visit URL '${fullPath}'`);
.catch((e) => {
throw new Error(`Failed to visit URL '${fullPath}': ${e.message}`);
});
});
}
2 changes: 1 addition & 1 deletion test-app/tests/unit/-private/properties/visitable-test.ts
Expand Up @@ -108,7 +108,7 @@ module('visitable', function (hooks) {
} catch (e) {
assert.strictEqual(
e?.toString(),
`Error: Failed to visit URL '/non-existing-url/value'
`Error: Failed to visit URL '/non-existing-url/value': /non-existing-url/value
PageObject: 'page.foo("[object Object]")'
Selector: '.scope'`
Expand Down

0 comments on commit 2eed933

Please sign in to comment.