Skip to content

"Convenience aliases" breaking unit tests, code coverage #991

Closed
@GeoffreyPlitt

Description

@GeoffreyPlitt

I'm using Istanbul to run code coverage (and tests) on some code. We use socket.io-client in our codebase.

The tests are failing with the following problem, caused by some weird "Convenience aliases" in the socket.io-client codebase around line 5235. Here's the code around socket.io.js:5235:

    // Native constructor aliases.
    var Number = context["Number"] || root["Number"],
        String = context["String"] || root["String"],
        Object = context["Object"] || root["Object"],
        Date = context["Date"] || root["Date"],
        SyntaxError = context["SyntaxError"] || root["SyntaxError"],
        TypeError = context["TypeError"] || root["TypeError"],
        Math = context["Math"] || root["Math"],
        nativeJSON = context["JSON"] || root["JSON"];

And here's the error I'm getting:

$ npm test

> mocha src/**/*.spec.js

/Users/giro/stardust-app/node_modules/socket.io-client/socket.io.js:5251
    var objectProto = Object.prototype,
                            ^

TypeError: Cannot read property 'prototype' of undefined
    at runInContext (/Users/giro/stardust-app/node_modules/socket.io-client/socket.io.js:5251:29)
    at Object.<anonymous> (/Users/giro/stardust-app/node_modules/socket.io-client/socket.io.js:6070:5)
    at Object.<anonymous> (/Users/giro/stardust-app/node_modules/socket.io-client/socket.io.js:6103:4)

Please advise, thanks.

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