Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>TDD SnippetsNew to Visual Studio Code? Get it now.

TDD Snippets

Hai Hua

|
1,181 installs
| (2) | Free
Code snippets for test driven development
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

VS Code TDD snippets

Who says writing test cases have to be boring?

This extension contains code snippets for common test driven development (TDD) functions that will speed up your testing and make it that much more enjoyable.

Installation

To install any extension, launch Command Pallette (Ctrl + Shift + P or Cmd + Shift + P) and type in Extensions. You will be shown 2 sections, 1) extensions already installed, 2) new extensions to install.

Features

This code snippet extension brings many common test cases to your fingertips:

![feature X](images/feature-x.png)

Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.

Supported languages

  • JavaScript (.js) [ES6+]
  • TypeScript (.ts) [ES6+]
  • ReactJS (.js)

Supported frameworks/libraries

  • Jest/Enzyme
  • Jasmine
  • Sinon

Snippets

Here is the list of all snippets and how to trigger them. The → at the end means you need to press the TAB key.

Common Triggers Effect
des→ 'describe, set up test suite'
bfa→ 'beforeAll, set up initial values for all test cases'
bfe→ 'beforeEach, set up initial values for each test case'
Basic it() Triggers Effect
itb→ 'it() be a result'
ieq→ 'it() equal a result'
ide→ 'it() existence of a result'
iud→ 'it() non-existence of a result'
ima→ 'it() match a result'
itr→ 'it() truthiness of a result'
ifa→ 'it() falsiness of a result'
ict→ 'it() contain a result'
igt→ 'it() greater than a result'
igte→ 'it() greater than or equal to a result'
ilt→ 'it() less than a result'
ilte→ 'it() less than or equal to a result'
ict→ 'it() close to a result'
inn→ 'it() not a number'
inu→ 'it() is null'
ini→ 'it() negative infinity of a result'
ipi→ 'it() positive infinity of a result'
iex→ 'it() exception of a result'
iee→ 'it() exception of a result with an error'
iem→ 'it() exception of a result with a matching'
ihc→ 'it() result to have class'
Basic test() Triggers Effect
ttb→ 'test() be a result'
teq→ 'test() equal a result'
tde→ 'test() existence of a result'
tud→ 'test() non-existence of a result'
tma→ 'test() match a result'
ttr→ 'test() truthiness of a result'
tfa→ 'test() falsiness of a result'
tct→ 'test() contain a result'
tgt→ 'test() greater than a result'
tgte→ 'test() greater than or equal to a result'
tlt→ 'test() less than a result'
tlte→ 'test() less than or equal to a result'
tct→ 'test() close to a result'
tnn→ 'test() not a number'
tnu→ 'test() is null'
tni→ 'test() negative infinity of a result'
tpu→ 'test() positive infinity of a result'
tex→ 'test() exception of a result'
tee→ 'test() exception of a result with an error'
tem→ 'test() exception of a result with a matching'
thc→ 'test() result to have class'
Complex it() Triggers Effect
isp→ 'it() spy to have been called'
isp1→ 'it() sinon spy to have been called once'
isp2→ 'it() sinon spy to have been called twice'
isp3→ 'it() sinon spy to have been called thrice (three times)'
isto→ 'it() sinon stub to have been called'
imoc→ 'it() sinon mock to have been called'
Complex test() Triggers Effect
tsp→ 'test() spy to have been called'
tsp1→ 'test() sinon spy to have been called once'
tsp2→ 'test() sinon spy to have been called twice'
tsp3→ 'test() sinon spy to have been called thrice (three times)'
tsto→ 'test() sinon stub to have been called'
tmoc→ 'test() sinon mock to have been called'
Concurrency it() Triggers Effect
iprs→ 'it() promise to resolve'
iprj→ 'it() promise to reject'
iaar→ 'it() async-await to resolve'
iaaj→ 'it() async-await to reject'
icbs→ 'it() callback to resolve'
Concurrency test() Triggers Effect
tprs→ 'test() promise to resolve'
tprj→ 'test() promise to reject'
taar→ 'test() async-await to resolve'
taaj→ 'test() async-await to reject'
tcbs→ 'test() callback to resolve'
ReactJS Triggers Effect
r-s→ 'shallow with props declared'
r-sn→ 'shallow with no props declared'
r-m→ 'mount with props declared'
r-mn→ 'mount with no props declared'
ReactJS Triggers Chain Effect
r-cp→ 'creates a mock props structure'
r-fn→ 'calls props function by using r-cp→'

Note: for simplicity

1.0.0

Initial release of TDD Snippets


  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft