chai-datetime | common date equality assertions against JavaScript Date | Assertion library
kandi X-RAY | chai-datetime Summary
kandi X-RAY | chai-datetime Summary
Matchers for chai to help with common date equality assertions against JavaScript Date objects.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of chai-datetime
chai-datetime Key Features
chai-datetime Examples and Code Snippets
Community Discussions
Trending Discussions on chai-datetime
QUESTION
I have written some tests in my Node project using Mocha and Chai. In one of my tests I create an agenda.js job, and then save it to the database. Then I retrieve that document from my MongoDB database and run some checks on it. After numerous configurations, I've found a construction for the test that works. But to get this to work I had to add a setTimeout()
within the first it
block, because otherwise the it
checks start running before the document is retrieved from the database.
While the following construction works, I'd like to know what would be a better way of doing this. It seems to me the whole point of the before
block in Mocha is to ensure that whatever work is defined within it is done BEFORE the it
checks run. That doesn't seem to be happening in my case - hence the need for the setTimeout()
. So how can I accomplish that without resorting to using the `setTimeout()?:
ANSWER
Answered 2019-Oct-25 at 13:04The async function inside before may be resolving early. In that case I would wrap it in a new Promise and resolve when I am sure all async code has resolved to completion.
QUESTION
I am creating some tests using Mocha/Chai in my Node project. In one particular test I need to first save a document
to the database, then later retrieve it and run some checks on the found document.
The problem I'm running into is that the it
checks are running before the document is finished being saved to the database. I don't understand why this is happening because I am doing the saving in the before()
block -- which, according to the Mocha documentation, should run before the tests in that same describe block, see below from the documentation:
ANSWER
Answered 2019-Oct-24 at 19:10It's not it
running before before
finished, but this is ran before everything:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install chai-datetime
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page