Skip to content
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

Explicitly check null and undefined values in exports.type #1761

Merged
merged 2 commits into from Jul 4, 2015

Conversation

chromakode
Copy link
Contributor

Some older JS engines, such as PhantomJS, return the window object instead of "[object Null]", as would be expected here, crashing the test runner.

@boneskull
Copy link
Member

@chromakode thanks, but where does the test runner crash? can you please add a test as well?

@chromakode
Copy link
Contributor Author

Thanks for the review :) I believe the test runner crashes in the process of formatting object diff output. For a test like:

chai.assert.deepEqual({a: null}, {a: 'test'})

I get a relatively inscrutable output like:

TypeError: 'null' is not an object (evaluating 'value.toString')

With an unrelated traceback.

I considered writing a test case that shimmed Object.prototype.toString, but wasn't sure this would be a valid test. I'll add it and update this PR.

Some older JS engines, such as PhantomJS, return the `window` object
instead of "[object Null]", as would be expected here.
@chromakode
Copy link
Contributor Author

Ok @boneskull , added a test to replicate the behavior of PhantomJS and rebased. I also added a test for type(undefined) in the general case, for consistency.

@jbnicolai
Copy link

Thanks for the work, @chromakode, and including a testcase!

jbnicolai pushed a commit that referenced this pull request Jul 4, 2015
Explicitly check `null` and `undefined` values in exports.type
@jbnicolai jbnicolai merged commit fc3fee6 into mochajs:master Jul 4, 2015
@chromakode
Copy link
Contributor Author

Great! Thanks for merging 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 this pull request may close these issues.

None yet

3 participants