Pest: Plans for `describe` blocks?

Created on 23 May 2020  路  8Comments  路  Source: pestphp/pest

Curious, what are your thoughts about implementing the standard describe blocks?

Ala?

https://jestjs.io/docs/en/api#describename-fn

Example

describe('my block', function() {
  test('is delicious', function() {
    assertTrue(true);
  });
});

Most helpful comment

@nunomaduro I think describe blocks are very important in order to make your tests efficient, readable, and expressive.
The "Testing Best Practices" repo explains it a few times:

It would be very meaningful to have describe in Pest. Please consider it. 馃檹

All 8 comments

It's a good idea, but no plans for now.

This is pretty important, as without it we have no idea what "it" is referring to in tests.

Currently, it('can log in') gets translated directly as "it can log in" which is ambiguous. It would be preferable to be able to describe the subject:

describe(User::class, function () {
  it('can log in if verified')->assertAuthenticated();
});

=> "User can log in if verified"

Or even allow nested descriptions, using context as an alias for describe, like in RSpec.

describe('User', function () {
  context('is verified', function () {
    it('can log in')->assertAuthenticated();
  });

  context('is not verified', function () {
    it('can not log in')->assertGuest();
  });
});

=> "User is verified can log in", "User is not verified can not log in"

Would tend to agree with you 馃憤

@nunomaduro I think describe blocks are very important in order to make your tests efficient, readable, and expressive.
The "Testing Best Practices" repo explains it a few times:

It would be very meaningful to have describe in Pest. Please consider it. 馃檹

Would be a nice to have for sure. Given that this issue was re-opened recently, I am curious what everyone has in mind for how describe works; what is it doing under the hood with how Pest works now? If no one else takes this soon or hasn't already started it, I might be interested in starting work on it.

@jordanbrauer seeing as @nunomaduro was the one to reopen, I am guessing he is (or will be) working on this personally.

@jordanbrauer I think it's totally fine for you to try and work out a PR for this and figure out what it's supposed to do.

One note about adding this is that it will be a breaking change for the IntelliJ Plugin, so changes has to be made before the IntelliJ plugin can work with it.

Sorry - if considering this once again, we are going to put this on hold.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nunomaduro picture nunomaduro  路  7Comments

nunomaduro picture nunomaduro  路  7Comments

rihardssceredins picture rihardssceredins  路  5Comments

dingo-d picture dingo-d  路  6Comments

JacobBennett picture JacobBennett  路  6Comments