-
Notifications
You must be signed in to change notification settings - Fork 11
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
exclude property path #9
Comments
Not really sure how helpful this is going to be. Also, |
I’m not sure I understand so here are a few other examples of what I have in mind : expect({
id: 123,
a: {
id: 345,
b: "c",
}
}).excludingPath(["a"]).to.deep.equals({
id: 123,
}) expect({
id: 123,
a: {
id: 345,
b: "c",
a: {
id: 678
}
}
}).excludingPath(["a", "id"]).to.deep.equals({
id: 123,
a: {
b: "c",
a: {
id: 678
}
}
}) expect({
id: 123,
a: {
id: 345,
b: "c",
a: {
id: 678
}
}
}).excludingPath(["a", "a", "id"]).to.deep.equals({
id: 123,
a: {
id: 456,
b: "c",
a: {}
}
}) just realized that the arguments don’t need to be in an array, a variadic function works well here: expect({
id: 123,
a: {
id: 345,
b: "c",
a: {
id: 678
}
}
}).excludingPath("a", "id").to.deep.equals({
id: 123,
a: {
b: "c",
a: {
id: 678
}
}
}) does that answer your question ? this is mainly to avoid removing all properties having the same name from the object |
And how do you go about excluding various paths and not one? Maybe an array of strings?
{
a: {
b: 'c',
z: 'y'
},
d: {
e: 'd',
f: 'g'
}
} I feel we are trying to do too much here? |
@mesaugat you can always call imho, excluding path one at a time is enough so I don’t mind having
I don’t want to force anything, if you think this outside the scope of chai-exclude, I’ll just add this into my project until I have time to make another plugin |
My only requirement is that the API should be simple to understand. Feel free to send a pull request and then we can discuss about the code itself. |
@mathroc I am closing this issue. Hope you have figured out the solution. If you want to reopen this issue feel free to do so. We can discuss further. |
sometime I might want to ignore properties only at certain level, eg:
do you think
excludingPath
would be useful ? I’ve worked around it for now by not testing some properties but I’d like to make a PR sometime if you think that would be usefulThe text was updated successfully, but these errors were encountered: