-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Unexpected behavior with undefined #58
Comments
Hey there! Thanks for bringing this lack of My intention with |
Definitely see where your thought process is coming from, and it makes sense. It's possible the way in which I use Must.js is a bit atypical. In my mind, I'd expect Must to lean toward accommodating the reality that, in Javascript, despite one's best efforts there's no way to guarantee that something will only ever be a particular type or types. Given the patterns I'm using today, I could address this with something like: const somePromise = promiseReturningMethod()
.then(someArray => {
// I'd really rather prefer to keep logic like this out of tests
someArray = someArray || []
expect(someArray).to.not.be.empty()
someArray.forEach(element => {
// Ensure each array element is an object with particular keys
expect(element).to.have.keys(['foo', 'bar'])
})
return someArray
})
expect(somePromise)
.to.resolve
.to.be.an.array() What about adding some type of |
Are you basically checking whether that promise resolves to either |
I'm attempting to ensure the promise resolves to an array of objects, each of which has a set of keys. The test should fail in all other cases (promise rejection, returning undefined, null, an object, a string, etc).
…On Feb 20, 2017 4:03 AM, "Andri Möll" ***@***.***> wrote:
Are you basically checking whether that promise resolves to either
undefined or null OR to an array matching some other requirements?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#58 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAjBxdum2_TKpGu2TXBgjo-z0G-xNCKiks5reVbMgaJpZM4MFnU->
.
|
If you don't mind, I'd like to keep this open as I think something should be done to handle the |
Using
0.13.4
:Does must.js treat
undefined
as a distinct case? In the above cases, I'd expect it to fail likenull
and[]
, especially considering the frequency ofx is undefined
errors in Javascript due to incorrect object properties being accessed, etc.Appreciate all the work you're doing moll! :)
The text was updated successfully, but these errors were encountered: