-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Clean up async tests using async/await #1337
Comments
Just a small nit, according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function: it('can be used before load()', function() {
await player.attach();
await player.load('test:sintel_compiled');
}); will need to be: it('can be used before load()', async function() {
await player.attach();
await player.load('test:sintel_compiled');
}); |
Updated. Thanks for catching that! |
This adds attach/detach methods to replace the media element in the Player constructor. Now applications can take back control of the media element or provide a reference later in the Player's life cycle. This also allows applications to decide whether or not to set up MediaSource in advance, through an optional argument on attach and unload. The default will be to set up MediaSource in advance, which maintains current behavior. This advanced setup of MediaSource can improve load latency later. This change also introduces async/await for the first time in the project, which required changes to eslint config, Closure build arguments, Babel & Babel-polyfill setup, and the esprima parser used by our extern generator. The use of async/await will improve readability in many places, and these infrastructure changes to enable async/await should also unblock issues #1336 and #1337. Closes #1087 Change-Id: I0d6b4e0e2af27a6520a3d070fa92b7139b2cb8b0
I started on this, but it will have to be put on hold for a while due to issues with Closure compiler type inference and async functions. |
Issue #1337 Change-Id: I0cb350ad87d0b5448d9f87f7823dbf307131108b
Jasmine has // Instead of:
try {
await foo();
fail();
} catch (e) {
expect(e).toEqual(expected);
}
// Instead we could add:
await expectAsync(foo()).toBeRejectedWith(expected);
// Or
await expectAsync(foo).toRejectWhenCalled(expected); |
Also fixed some formatting in media tests. Issue #1337 Change-Id: Ifc003e3cb8f4b7a9920a0d2a121089eea4cf1bcd
Unfortunately, due to problems with our version of Closure compiler, not all of the tests in player_unit.js and player_integration.js can be modified to use async/await. A lot of them can, though, so this modifies those tests. Issue #1337 Change-Id: I8e07283c1e51e5532ebcba5194d29466d950015d
Issue #1337 Change-Id: Ib4d0bdb3e61b2ff54585941d1b0e20452612a3eb
While working with DrmEngine I broke some tests. Why looking into what part of the tests I broke I updated the tests to ES6. Issue #1337 Change-Id: Ic865585c7ab0e8b858ef45fb02f1bcd0db6bcce2
Handled as part of #1157. |
Since Jasmine v2.7.0, Jasmine supports async functions and functions that return Promises. We should no longer have to do this:
Instead, we should be able to let the returned Promise manage both completion and failures:
Or even use async functions which implicitly return Promises:
The text was updated successfully, but these errors were encountered: