-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix(Jasmine): Update Jasmine to support Node8 async/await #4608
Conversation
Code LGTM! I'd suggest updating the commit message to have a clear 'before/after' for breaking changes, like this: 5034c89 |
Sure, will squash and rewrite the comment after fixing all breaks. |
Breaking change for TypeScript: JasmineWD doesn't know anything about async/await, turns off JasmineWD if control flow was disabled. It will affect TypeScript tests that are using async/await and 1. miss some await keyword in the test.(Previously, this might cause the test failed silently and be reported as pass), or 2. use Promise in jasmine expect function Before ```ts await expect(getPromise()).toEqual(42); ``` After ```ts expect(await getPromise()).toEqual(42); ```
Just to clarify: "It will affect TypeScript tests that are using async/await and" It will affect ANY tests that turn off the control flow, not just TypeScript tests, right? Out of curiosity, what was broken? I recently migrated to async/await (I don't use TypeScript though) and my expect statements have been working as expected using:
|
It will affect ANY tests that turn off the control flow AND using async/await For JavaScript, if you write test like this : await expect(getPromise()).toEqual(42). it should throw an ugly error.
|
I'm sure I'm missing something obvious here, but I seem to have my 2000+ line repo running without issue using Protractor 5.2.0 (prior to this commit). I am using Here is a trivial example that seems to show everything working as I would expect:
|
@qiyigg, would you mind explaining briefly which issue this commit fixes? We've also been making use of the async expect as in |
@rdbaron hmm, that's also quite surprising for me. I double checked the JasmineWD github and found jasmineWD has already supported async/await in the new release, but we didn't have that change inside google and therefore we didn't notice async/await can be used directly externally. @renehamburger the original idea was to disable jasmineWD when disable control flow since previously jasmineWD didn't support async/await and we thought jasmineWD shouldn't be existed if we don't use control flow. JasmineWD change the original behavior of Jasmine expect, so that it can accept promise. "await expect(getPromise()).toEqual(42);" looks more readable: My personally understanding is when we make an assertion using "expect(a).toEqual(b)", a and b should be comparable. Only the process returns promise should be awaited. e.g. we don't actually wait for "button = element(by.css('button'))" (the locator is lazy loaded), but wait for button.getText() / button.click(). But anyway, this change was unnecessary at this point. Sorry for the inconvenience. |
…gular#4608)" This reverts commit 5d13b00. This commit is unnecessary, revert this commit to avoid breaking changes
Thanks for the quick fix, @qiyigg! |
Thanks for the reply, @qiyigg. Can you just clarify your previous comment for me though.
I am not using TypeScript and things seem to work. Is there something specific I should be aware of? |
@rdbaron no, you are right. Your test should work directly. As I mentioned above, JasmineWD(a wrapper of Jasmine) has already fixed the bug so that it can support native async/await right now; therefore my PR was not needed any more and I have already reverted it. If you already changed your test to the new style, you don't need to change it back, it will work both with and without this PR. |
Breaking change for TypeScript: JasmineWD doesn't know anything about async/await, turns off JasmineWD if control flow was disabled. It will affect TypeScript tests that are using async/await and 1. miss some await keyword in the test.(Previously, this might cause the test failed silently and be reported as pass), or 2. use Promise in jasmine expect function Before ```ts await expect(getPromise()).toEqual(42); ``` After ```ts expect(await getPromise()).toEqual(42); ```
…gular#4608)" (angular#4625) This reverts commit 5d13b00. This commit is unnecessary, revert this commit to avoid breaking changes
fix(jasmine): Update Jasmine to support Node8 async/await
Breaking change for TypeScript:
JasmineWD doesn't know anything about async/await, turns off JasmineWD if control flow was disabled.
It will affect TypeScript tests that are using async/await and
test failed silently and be reported as pass), or
Before
After