New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw a TypeError
instead of the generic Error
#32585
Conversation
/cc @XhmikosR for review |
@rohit2sharma95 actually, shouldn't this test fail right now? bootstrap/js/tests/unit/util/index.spec.js Lines 213 to 215 in 206b9f4
Perhaps we should use |
js/src/dropdown.js
Outdated
@@ -263,7 +263,7 @@ class Dropdown extends BaseComponent { | |||
typeof config.reference.getBoundingClientRect !== 'function' | |||
) { | |||
// Popper virtual elements require a getBoundingClientRect method | |||
throw new Error(`${NAME}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`) | |||
throw new TypeError(`${NAME}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should make the related tests stricter, probably makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Also, changed the NAME
to upper case to make the consistency.
Should check for the same in jQueryInterface
also? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean should the tests be updated here? (To check if the error
is the instance of TypeError
)
bootstrap/js/tests/unit/dropdown.spec.js
Lines 1560 to 1564 in 7e6d7b8
try { | |
jQueryMock.fn.dropdown.call(jQueryMock, action) | |
} catch (error) { | |
expect(error.message).toEqual(`No method named "${action}"`) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah let's switch any other instances to toThrowError
Convert the `NAME` to upper case to make the consistency in the error message
Error
to TypeError
TypeError
instead of the generic Error
Ref: #32376 (comment)