acquit icon indicating copy to clipboard operation
acquit copied to clipboard

Support for "given", "when" and so on

Open vinci-mz opened this issue 6 years ago • 3 comments

Hello, first of all - thanks for the nice tool, which "acquit" is. Let me notice that there exist some BDD extensions allowing to declare additional behavior of the tests - eg. "given" or "when" ( jasmine-rowtests or jasmine-given ). Currently acquit completely ignores such clauses eg.:

> var acquit = require('acquit');
> var parser = acquit();
> parser.parse('describe("test", function() { given("xx").it("bla", function() {} )}); ');

Though it nicely supports: > parser.parse('describe("test", function() { for(i=1; i<10; i++) { it("bla", function() {} ); } }); ');

Would you like to add to acquit support for such cases ?

Kind regards,

vinci-mz avatar Jan 06 '18 18:01 vinci-mz

Thanks for your kind words! Unfortunately I've never used these tools, so I don't have any ideas on how acquit might surface these. How do you imagine the acquit output for given() and when() would look?

vkarpov15 avatar Jan 10 '18 21:01 vkarpov15

I imagine that acquit can analyse the results of some functions (like given() or when()) as objects, which method/property it() can be treated in the same way as a call of the "global" it(). The minimal support could be even limited just to the syntax given(...).it(...) and could produce the same output as in the case of global it(). For example, the acquit's result in the case of:

> parser.parse('describe("test", function() { given("xx").it("bla", function() {} )}); ');

could be even the same as in the case of:

> parser.parse('describe("test", function() { it("bla", function() {} )}); ');

At this moment it is [ { type: 'it', contents: 'bla', comments: [], code: '' } ].

Of course having an access to the additional information about the context would be useful - eg.

[ { type: 'it', contents: 'bla', comments: [], code: '',
   context: {type: 'given', arguments: ['xx']}
} ]

But such rich approach is not required from my point of view.

vinci-mz avatar Jan 15 '18 14:01 vinci-mz

This would also be very useful for those of us using the mocha-steps plugin to split up deep nested callback tests into promise based steps.

https://github.com/rprieto/mocha-steps

ricick avatar Apr 01 '19 02:04 ricick