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

Unable to assert invalid dates #1660

Closed
meandmycode opened this issue Apr 18, 2015 · 3 comments
Closed

Unable to assert invalid dates #1660

meandmycode opened this issue Apr 18, 2015 · 3 comments
Assignees

Comments

@meandmycode
Copy link

When asserting something that may return an invalid date mocha will error trying to report the invalid date due to calling toISOString on an invalid date.

Example (using should):

describe('mocha', function() {
  it('should not error when comparing invalid dates', function() {
    new Date('').should.equal(new Date(''));
  })
})

I can submit a PR if it helps, I think the stringify utility just needs to call toString() in the event that the date is invalid, which will result in "[Date: Invalid Date]"

a8m added a commit to a8m/mocha that referenced this issue Apr 18, 2015
Use toString for invalid date object
@a8m a8m self-assigned this Apr 18, 2015
@a8m
Copy link
Contributor

a8m commented Apr 18, 2015

Thanks @meandmycode
PTAL on #1661

@meandmycode
Copy link
Author

Much appreciated, speedy work!

boneskull added a commit that referenced this issue Apr 18, 2015
fix(utils/stringify): fix issue #1660
@boneskull
Copy link
Contributor

closed via #1661

boneskull added a commit to boneskull/mocha that referenced this issue Jun 30, 2015
* commit '3b02d830c0c5f20c5be9acaa9ef45b824bcbf965': (29 commits)
  Add cross-frame compatible Error checking for fail
  Remove moot `version` property from bower.json
  HISTORY: fix typo in 2.2.5
  HISTORY: improve 2.2.5 changelog
  removing duplicate flags adding additional iojs flags
  Prevent default browser behavior for failure/pass links
  Removes return statement irt mochajs#1700.
  Removes accidentally commited test.js
  Add support of --harmony_arrow_functions V8 option
  Release 2.2.5
  Upgrade jsdiff to v1.4.0
  fix 'location is not defined' error
  Update json-stream.js
  Sanity check: update fixtures/regression/issue-1327.js to be closer to orig test
  Fix diff colors
  use a valid SPDX license identifier
  Add integration tests
  Handling of error.htmlMessage in the HTML reporter
  Split message and stack into two separate variables
  fix(utils/stringify): fix issue mochajs#1660
  ...

Conflicts:
	test/acceptance/misc/asyncOnly.js
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

No branches or pull requests

3 participants