Chai.js Assertions


I noticed Vow test runner only provides Chai’s assert interface for assertions. Are there any plans to include expect or should styles?

How to test asyn functions with chai assert

Nope I want to kill these kind of choices, since there is no benefit of it


Ah. Seems like you want to remove any form of bikeshedding. Good to know! :ok_hand:


Yes, since once you allow things to be configured for no reason, you are allowing knowledge and learning material to be scattered. A new comer may see assert in official docs and expect in a blog post, thinking which is the right way or is he following the writing blog post tutorial or not.

Same goes for template engine


Actually expect and should allow us to chain methods.
I agree with you that it’s just bad design, but at that point adonis shouldn’t have chosen chaijs in the first place.


What are the reasons we should use should or expect instead of assert?

I want to see some code that you cannot do with assert.


If you would have read the chaijs doc page, you’d know :slight_smile:
To understand this, you should know first what is BDD and why is different than TDD (just saying, don’t know if you’re familiar with it).

This page states

  • The Expect / Should API covers the BDD assertion styles.
  • The Assert API covers the TDD assertion style.

In what do expect and should differ in practice then?
With assert you’ll have:

and so on

with expect you can write:


So if you’ve tested for a long time, you know that testing is also important to document your code and BDD is actually clearer (but it comes with a price), as a matter of fact, it is just a different style of explicating tests.


Exactly, you don’t miss any feature with assert, it’s simply a different syntax.

So there’s nothing wrong about Adonis choosing one or the other. Nothing keeps you from creating your own testing trait that will add should or expect to the testing context.


Never said you’d miss a feature… it’s also true that actually the ability to express something in different syntaxes is a feature.
But there isn’t any problem :slight_smile:


I agree that everyone has their style of doing everything. However, Adonis is not about giving too many options, when it comes to personal preferences.

If something is technically required, we love to build abstractions over them and give multiple options. For example: 3 drivers to store sessions, multiple databases to choose from and so on.

Certainly there are people, who love freedom in every choice and AdonisJs may isn’t for them and express, koa will fit better. However, people who want decisions to be made for them (to some extent), will certainly enjoy AdonisJs.

Again, my point is not to say that you are wrong or incorrect. It’s simply I don’t want framework to have open ends, when it comes to personal preference.

For example, if you want, you can ditch the assert library shipped with Adonis. Import chai manually and use whatever style you like.