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

Cannot read property 'xxx' of undefined #34

Open
azachar opened this issue May 7, 2021 · 1 comment · May be fixed by #35
Open

Cannot read property 'xxx' of undefined #34

azachar opened this issue May 7, 2021 · 1 comment · May be fixed by #35

Comments

@azachar
Copy link

azachar commented May 7, 2021

Hello,

objectContent, got Cannot read property 'xxx' of undefined on the line index.js:235:21

It is because, the tested object is not having the nested structure, thus it should not be compared.

Consider this example for instance:

 assert.objectContent(
      {},
      {
        array: [
          {
            key: "1"
          },
          {
            key: "2"
          }
        ]
      }
    );

Btw. it would be cool to display real object diff.

Cheers,
Andrej

@azachar
Copy link
Author

azachar commented May 7, 2021

I look deeper, and your testing are not checking assertion error, so that kind of error you cannot find, this should be the better way of checking your behaviour:

  it('fails if deep nested object does not contain a key', () => {
      assert.throws(yoAssert.objectContent.bind(yoAssert, {
      }, {
        a: {b: 'foo'}
      }),  /.*AssertionError.*/);
    });

@azachar azachar linked a pull request May 7, 2021 that will close this issue
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.

1 participant