Does not handle objects without prototype

Open Beginner friendly
#148 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
64/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript
Domain
testing

Research direction

Start with lib/interpolate-pos-arg.js, especially the String conversion shown in the stack trace, and reproduce the failure with the provided Node script using Object.create(null). Confirm the fix by ensuring assert.isUndefined reports a normal assertion error instead of a TypeError.

Written by the indexing model from the issue text.

Description

  • library version : 3.2.0
  • Environment : Node

What did you expect to happen?
That it would print a normal assertion error

What actually happens
It fails with

TypeError: Cannot convert object to primitive value
    at String (<anonymous>)
    at /tmp/test1/node_modules/@sinonjs/referee/lib/interpolate-pos-arg.js:12:44
    at Array.reduce (<anonymous>)
    at interpolatePosArg (/tmp/test1/node_modules/@sinonjs/referee/lib/interpolate-pos-arg.js:9:12)
    at Object.fail (/tmp/test1/node_modules/@sinonjs/referee/lib/define-assertion.js:30:27)
    at assertion (/tmp/test1/node_modules/@sinonjs/referee/lib/define-assertion.js:68:17)
    at Function.referee.<computed>.<computed> [as isUndefined] (/tmp/test1/node_modules/@sinonjs/referee/lib/define-assertion.js:93:26)
    at Object.<anonymous> (/tmp/test1/mytest.js:4:8)

How to reproduce

$ cat > mytest.js  << EOF
var referee = require("@sinonjs/referee");
var assert = referee.assert;

assert.isUndefined(Object.create(null));
EOF

node mytest.js 
Dominant language
JavaScript
Stars
43
Forks
21
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sinonjs/referee

All issues in sinonjs/referee

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.