Skip to content
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

Deprecation warning from jasmine 3.7.0 for async before/it/after with done callback and returned promise #38

Open
kussmaul opened this issue Sep 5, 2021 · 4 comments

Comments

@kussmaul
Copy link

kussmaul commented Sep 5, 2021

After I updated to jasmine 3.8, every test suite that uses ng-bullet produces this warning, discussed in detail here: jasmine/jasmine#1893

DEPRECATION: An asynchronous before/it/after function took a done callback but also returned a promise. This is not supported and will stop working in the future. Either remove the done callback (recommended) or change the function to not return a promise.

Looking at ng-bullet/src/testing.ts, the problem appears to be here:

    // original code
    if (configureAction) {
        beforeAll((done: DoneFn) => (async () => {
            configureAction();
            await TestBed.compileComponents();
        })().then(done).catch(done.fail));
    }

I copied testing.ts to a local file, and changed the above code as shown below, following an example in the jasmine discussion:

    // modified code
    if (configureAction) {
      beforeAll((done: DoneFn) => {
        (async function() {
          configureAction();
          await TestBed.compileComponents();
        }().then(done).catch(done.fail));
      });
    }

The tests now run without the deprecation warning, and appear to behave as they did before.
However, I don't have enough knowledge or experience with async, done callbacks, and returned promises to know if this change introduces new problems or if there is a better fix.
I hope other people can provide further insights, or will find this workaround useful.
I understand that ng-bullet is no longer active maintained (unfortunately),

sinsunsan added a commit to sinsunsan/ng-bullet-workspace that referenced this issue Nov 27, 2021
@sinsunsan
Copy link

thanks @kussmaul I applied the workaround here sinsunsan@6fec51b

Since then, are you still using it ?

@kussmaul
Copy link
Author

@sinsunsan, yes, I am still using it. Thank you for submitting a PR.

@sinsunsan
Copy link

I deployed the lib with a different name https://www.npmjs.com/package/sinsunsan-ng-bullet-workspace

the content of my PR
so in my package.json I use

"sinsunsan-ng-bullet-workspace": "1.0.4",

@VictorSholomickiy
Copy link

@sinsunsan hello, I tried to use your package, but what about the performance? It looks like app speed improvement is gone... I have around 5000 tests and it usually needs about 7-8 minutes to run all of them, but with your package, it is about 25 min... any ideas why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants