0

I've seen some tests written this way and I would like to know if anyone knows what is the name of this convention:

describe("users/domains/services/user-service", () => {
  describe("UserService", () => {
    describe(".create()", () => {
      ...
    });

   describe(".update()", () => {
      ...
   });
    
    // Static method
    describe("#new()", () => {
      ...
    });
  });
});

If someone can help me I would be very grateful.

  • Maybe related [Referring to javascript instance methods with a pound/hash sign](https://stackoverflow.com/q/2587896/691711) – zero298 Oct 29 '21 at 14:10

1 Answers1

1

This way of referring to a method or variable comes from jsdoc and is called a namepath. For example, MyClass#myMethod could be used in a doc comment to refer the method named #myMethod in the class named MyClass.

The use of this convention for JavaScript tests is very prominent in the mocha.js documentation. An equivalent style has also been proposed by betterspecs.org as a best practice in Ruby, and there's some discussion about it there. I don't know who first adopted the style, and I don't think it has a name.

There's some more relevant answers in this related StackOverflow question.

Sam
  • 8,330
  • 2
  • 26
  • 51