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

Can't run it.each or test.each in fakeAsync zone #339

Closed
andrewalderson opened this issue Dec 31, 2019 · 1 comment · Fixed by #340
Closed

Can't run it.each or test.each in fakeAsync zone #339

andrewalderson opened this issue Dec 31, 2019 · 1 comment · Fixed by #340

Comments

@andrewalderson
Copy link

I ran into an issue with not being able to run it.each or test.each in a fakeAsync zone. This sample test

  it.each([[1]])('should be equal', fakeAsync((val) => {
    expect(val).toEqual(val);
  }));

results in the following error

  Expected to be running in 'ProxyZone', but it was not found.

      at Function.Object.<anonymous>.ProxyZoneSpec.assertPresent (../node_modules/zone.js/dist/proxy.js:42:19)

After some investigation it turns out that describe.each does work so as a test I modified the zone-patch file by adding

 const bindTest = originalJestFn =>
  function() {
    const eachArguments = arguments;
    return function(description, specDefinitions, timeout) {
      arguments[1] = wrapTestInZone(specDefinitions);
      return originalJestFn.apply(this, eachArguments).apply(this, arguments);
    };
  };

and then changing line 96 from

env[methodName].each = originaljestFn.each;

to

env[methodName].each = bindTest(originaljestFn.each);

This fixed the issue.

I am a little confused as to why the describe blocks were patched but the other blocks weren't. Was there a reason?
I could submit a pull request for this once I understand if this is the correct fix.

@JiaLiPassion
Copy link
Contributor

JiaLiPassion commented Jan 8, 2020

This is a bug, I will create a PR to fix this one (with some other minor fixes), and finally will move those code into angular/zone.js repo.

JiaLiPassion added a commit to JiaLiPassion/jest-preset-angular that referenced this issue Jan 8, 2020
@wtho wtho closed this as completed in #340 Mar 10, 2020
wtho pushed a commit that referenced this issue Mar 10, 2020
* fix: test.each and describe.each is in ProxyZone

Closes #339
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

Successfully merging a pull request may close this issue.

2 participants