Skip to content

Tobi incompatible with should-style Chai #76

@zzen

Description

@zzen
tobi = require('tobi')
chai = require('chai').should()

Produces an error:

TypeError: Property 'should' of object #<Object> is not a function
    at Object.<anonymous> (/Users/jakub/Documents/apiary/test.coffee:6:26)
    at Object.<anonymous> (/Users/jakub/Documents/apiary/test.coffee:8:4)
    at Module._compile (module.js:404:26)
    at Object.run (/Users/jakub/.nvm/v0.4.7/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:68:25)
    at /Users/jakub/.nvm/v0.4.7/lib/node_modules/coffee-script/lib/coffee-script/command.js:135:29
    at /Users/jakub/.nvm/v0.4.7/lib/node_modules/coffee-script/lib/coffee-script/command.js:110:18
    at [object Object].<anonymous> (fs.js:107:5)
    at [object Object].emit (events.js:61:17)
    at afterRead (fs.js:878:12)
    at wrapper (fs.js:245:17)

The opposite require order works fine. This is super non-intuitive, just spent the last 30mins debugging this.

The reason for this is that tobi tries to require should.js, should.js extends Object.prototype including nuking the setter for the Object.prototype.should property. A while later, chai#should also tries to extend Object.prototype in the same way but is blocked by the empty setter.

Since should.js seems to be a convenience anyway, could we remove it out of the instantiation (perhaps make the attaching of tobi extensions to should.js optional?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions