58

I'm fairly new to the Javascript world (coming from Android) so I've been reading up on how to setup Mocha/Jasmine to get my test environment in place. I've noticed a convention of "spec" in reference to test directories, file suffix, suite names, and/or tests/assertions.

Is this specific to testing in Javascript? And what does "spec" actually stand for? Specification, Expectation, or ?

basudz
  • 997
  • 1
  • 6
  • 14
  • 4
    specification (meaning test file). was idiomatic in jasmine I think. – Davin Tryon Oct 24 '16 at 16:01
  • 1
    It's loosely a way of writing tests, as a specification (or set of expectations) rather than a more assertive style. Related to the BDD fad. – ssube Oct 24 '16 at 16:02
  • So, would you say this is/should be a common standard for all test files I write? – tschaka1904 Apr 03 '18 at 14:30
  • @tschaka1904 I think it's ultimately a matter of preference and project consistency. If you work on an existing project using a specific convention then you should stick with that. If you are starting from scratch then it should be a team decision. If you are by yourself then I personally go with what my framework uses, again for consistency. – basudz Apr 05 '18 at 18:29

1 Answers1

62

Spec is short for "Specification" as @DavinTryon suggested above.

Specification in terms of a test refer to the technical details of a given feature or application which must be fulfilled. The best way to think of this is as the technical specifications for a given unit of code to pass successfully. https://en.wikipedia.org/wiki/Unit_testing

Benjamin Dean
  • 1,218
  • 11
  • 11