javascript - What is the purpose of Mocha's before() function? -
There are several "hooks" to run collaborative functionality in a separate test for testing in Mocha (to clean itself For making fake files, etc.).
However, before >> Logic triggers once , why do I need to wrap it in the function even before all tests in the current suit? << P> There is no difference between the following: and semantics semantique This is probably the biggest one Sometimes you may need to do one thing, such as populating some dummy data in your database, before running the actual database. You can certainly do this in testing, but it throws your reporting. If you were to pre-populating E error occurs, and before the run all terms of the actual exam. Cleaner for Async Test P> Mocha Tests can be asynchronous, so your Integration with other hooks: Mocha also offers several other hooks, namely: () ( not
first () , that one I get), it seems very redundant
Description ('some', function () (before (doSomePreTestLogic); // test Ahoy});
Description ('some', function () {doSomePreTestLogic ( ); // Test Ahoy});
before ?
first () might be a hook logic. Returning to pre-populations example is easy because it means that all your ASINCC Pre-Test Logic will not inspire any other level indentation on all your actual test logic.
after () ,
beforeEach () , and
afterEach () . You probably can ask the same question about all these other hooks, but if you buy in this belief that any of these is a valid existence, then
first () Need to be included in the API.
Comments
Post a Comment