What is 'spec' used for in packages?


#1

Just wondering what the ‘spec’ folder is used for in a package.


#2

A spec is a fancy word for a testing script. It is written in jasmine, which is where the word spec comes from. I guess the theory is that you write that before you write the code so it is a spec. Of course no one uses it that way.


#3

So it’s not necessary unless I want to use it to test the code?


#4

That is correct.


#5

Or, of course, if you’re a TDD fan, you indeed start by writing your specs, have them fail left and right, and then start creating the code to make them succeed.


#6

As someone who has been a developer a long time and written packages for Sublime Text, Emacs and Atom, I highly recommend taking the time to write tests for any package that you intend to publish. It’s just a huge time saver in the long run. One of my biggest pleasures in working with Atom is its support for automated testing.


#7

And it’s now well proved that TDD doesn’t decrease team velocity, quite the contrary. And it forces you to understand what you’re actually trying to achieve: if you don’t know how to test it it’s probably that you don’t know what you are doing.



#8

I quite like the new BDD trend.
It helps to start with user stories as abstract tests for whole features, then work inwards via more detailed, technical specs, and eventually just filling in the needed code to make them all succeed.

That way, you’re sure you do know what you’re doing.