Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "spec" mean in Javascript Testing

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 ?

like image 217
basudz Avatar asked Oct 24 '16 16:10

basudz


People also ask

What is spec in JavaScript?

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.

What does it mean spec file?

Spec files are plain-text files that are used to construct spec strings. They consist of a sequence of directives separated by blank lines. The type of directive is determined by the first non-whitespace character on the line, which can be one of the following: % command. Issues a command to the spec file processor.

How do I run a test spec in JavaScript?

In order to run a specific test, you'll need to use the jest command. npm test will not work. To access jest directly on the command line, install it via npm i -g jest-cli or yarn global add jest-cli . Then simply run your specific test with jest bar.

What is spec in Jasmine?

A spec contains one or more expectations that test the state of the code. An expectation in Jasmine is an assertion that is either true or false. A spec with all true expectations is a passing spec. A spec with one or more false expectations is a failing spec.


1 Answers

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

like image 192
Benjamin Dean Avatar answered Sep 21 '22 16:09

Benjamin Dean