Skip to content

Type check for parsePath variable would be nice to have #1043

Closed
@sverrirs

Description

When calling the parsePath function (https://github.com/chaijs/chai/blob/master/chai.js#L10117) type checking can help users identify incorrect usage of API.

Problematic line:

function parsePath(path) {
   var str = path.replace(/([^\\])\[/g, '$1.[');

When running this (slightly incorrect) code:

expect(data).to.have.nested.property({'a':'1'})

The following error is thrown:

TypeError: path.replace is not a function

Because path in this case is an object {'a':'1'}
Would be nice to throw a more descriptive error :)

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions