I see many test descriptions such as in Mocha using the # symbol in front of methods. What is the purpose and origin of this? I've been doing it for years like a lemming so I figured it was time to ask why :)
describe('#myMethod()', function() { ... })
I first saw this convention in Ruby, where class methods are referred to in text as Class.method
(or, less frequently, Class::method
) and instance methods as Class#method
. The difference in punctuation is needed both to tell the reader what kind the method is and to disambiguate class and instance methods with the same name (not that having those is usually a good idea).
The test naming convention probably came to Javascript along with RSpec syntax (describe
, it
, etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With