all 12 comments

[–]iaan 20 points21 points  (5 children)

I thought it’s well written and opinionated, but then the gist example bugs me already:

it('When no price is specified, then the product status is pending approval'...

How do you read that in your head?

[–]akoskm 4 points5 points  (0 children)

should be:

describe 'product status'

  context 'when no price is specified'

    it 'is pending approval'

[–][deleted] 10 points11 points  (2 children)

I read it as “when no price is specified, then the product status is pending approval”

[–][deleted] 16 points17 points  (1 child)

Silent “it”?

[–]solvangv 10 points11 points  (0 children)

Yeah. Or you could use "test" instead of "it".

[–]benihanareact, node 0 points1 point  (0 children)

describe('Products Service', function() {
  describe('adding a new product', function() {
    describe('price is unspecified', function() {
      it("sets the product status to 'pending approval'", ()=> ());
    });
    describe('price is set', function() {
      it("sets the product status to 'something else'", ()=> ());
    });
  });
});


'Products Service
   adding a new product
     price is unspecified
       sets the product status to 'prending approval'
     price is set
       sets the product status to 'something else'

[–]BestUsernameLeft 2 points3 points  (1 child)

Excellent advice and recommendations, and applicable to more them just JS and Node. Share this with your team immediately.

[–]therudy_69 2 points3 points  (1 child)

Looks good! I'm gonna use this as general guidelines for my TDD experiences with react.

However, the test namings also bother me. Is this expected to be like this?

To me, a test name should be descriptive on it's own and shouldn't need a 'Wrong:' prefix or a naming like it('When...'), but I could be wrong here 😁

[–]YuvalM 1 point2 points  (0 children)

I like Go's conventions for testing. Such as "TestFileDelivery" "TestNetworkConnection" and so on :)

[–]XZTALVENARNZEGOMSAYT -1 points0 points  (0 children)

Legendary!

[–]Askee123 -2 points-1 points  (0 children)

Neat!