Skip to content

Error "any must be an array" even if an array is passed #124

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

Closed
thegeorgeous opened this issue Apr 16, 2019 · 1 comment · Fixed by #128
Closed

Error "any must be an array" even if an array is passed #124

thegeorgeous opened this issue Apr 16, 2019 · 1 comment · Fixed by #128

Comments

@thegeorgeous
Copy link

thegeorgeous commented Apr 16, 2019

The condition in this line evaluates to false under certain conditions even if Array.isArray(someArray) evaluates to true and Object.prototype.toString.call(someArray) returns [Object Array].

Could these edge cases be the problem?

I'm using supertest and nock to test a Cloudflare worker.

Using Array.isArray() instead of instanceof doesn't seem to be causing any problems for tests. https://github.com/thegeorgeous/json-rules-engine/commit/c2da34fc59d94cc4f8e6f54eaca431b079220f12

Happy to provide any more details if necessary.

UPDATE:
The issue seems to be a jest issue. Would you consider using Array.isArray() instead?

@CacheControl
Copy link
Owner

@thegeorgeous looks like Array.isArray is faster anyway. if you submit a PR I'll happily merge it

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