1

Here is what i've understood (please tell me if i am wrong):

  • Mocha (mochajs.org) is a testing framework
  • Waffle (getwaffle.io) is another testing framework
  • chai: This is not a framework, this is a library which contains helpers for assertions
  • openzeppelin-test-helpers: This is not a framework: This is just helpers. And some of this helpers are calling chai helpers

Mocha and Waffle syntaxes are very similar and looks like something like that:

describe(... it('...) =>  ...)

There is something i do not understand: Look at this project:

https://github.com/aave/protocol-v2/blob/master/package.json

I can see both mocha and waffle dependencies.

How is it possible to work with 2 testing frameworks ?

Thanks

1
  • 1
    Waffle uses mocha underneath.
    – Ismael
    Jan 20 at 0:24
1

While Waffle and Mocha are both test frameworks, they are used for different things.

  • Mocha runs your tests, as defined with describe, it, etc.
  • Chai asserts that the values in your tests are correct. (expect, assert)
  • Waffle provides tools for compiling and deploying contracts, functions for testing contracts, contract mocks, extra Chai assertions etc. It can be used in addition to Mocha (as well as other test runners like Jest), Waffle does not run tests itself.
6
  • so when i see "describe... it...", this is mocha ?
    – Bob5421
    Jan 20 at 8:16
  • Mocha is one of the frameworks that works with describe, it, etc., yes. Other test frameworks like Jest, Jasmine use a similar pattern.
    – Morten
    Jan 20 at 16:18
  • I mean if i see « describe... it... » in a project, it must be mocha ?
    – Bob5421
    Jan 20 at 16:20
  • Not by definition, cause, like I mentioned, Jest, Jasmine and possibly other test runners use describe, it, etc. as well.
    – Morten
    Jan 20 at 16:43
  • 2
    The exact implementation is likely different. Each framework has different features to offer, otherwise there would be no point in having multiple frameworks in the first place. If you're just talking about the use of the function names describe and it, then yes, it's the same.
    – Morten
    Jan 20 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.