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

TypeError: Cannot read property 'object' of undefined #114

Open
Justkant opened this issue May 11, 2018 · 2 comments
Open

TypeError: Cannot read property 'object' of undefined #114

Justkant opened this issue May 11, 2018 · 2 comments

Comments

@Justkant
Copy link

I just encountered the error on this line I think:

const next = callExpression.callee.object;

This code was the problem:

expect(u)
  .toContainKeys(['id', 'name', 'pic'])
  .toNotContainKeys(['mail', 'token']);

But those 2 work:

expect(u)
  .toContainKeys(['id', 'name', 'pic']);

or

expect(u)
  .toNotContainKeys(['mail', 'token']);

It's trivial for me to fix on my codebase but I thought it could be useful for anyone getting the same error on a larger codebase.

@skovhus
Copy link
Owner

skovhus commented May 14, 2018

Thanks for reporting this!

Let me know if you would like to look at submitting a PR to either demonstrate the error with a failing test case or if you want to try to fix the transformer.

@Justkant
Copy link
Author

Hi,

In the same way but I don't know if it's related because no errors.

  describe('get', () => {
    it('should return the host status', function() {
      return this.client.send('host:get').then(res =>
        expect(res)
          .toContainKeys(['active', 'hostSocketId'])
          .toContain({ active: false }),
      );
    });
  });

Get transform to:

  describe('get', () => {});

But this version:

  describe('get', () => {
    it('should return the host status', function() {
      return this.client.send('host:get').then(res => {
        expect(res).toContainKeys(['active', 'hostSocketId']);
        expect(res).toContain({ active: false });
      });
    });
  });

Get transform correctly:

  describe('get', () => {
    it('should return the host status', function() {
      return this.client.send('host:get').then(res => {
        ['active', 'hostSocketId'].forEach(e => {
          expect(Object.keys(res)).toContain(e);
        });
        expect(res).toContain({ active: false });
      });
    });
  });

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

No branches or pull requests

2 participants