Skip to content

gbritting/jasmine-jetbrains-live-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

#Introduction

###Jasmine Live Templates for use in JetBrains IDEs (WebStorm, PhpStorm, etc.)

Jasmine is "a behavior-driven development (BDD) testing framework for JavaScript, Jasmine doesn’t rely on browsers, the Document Object Model (DOM) or other JavaScript libraries. Great for websites, node.js server-side coding, or any project running JavaScript, its clean syntax makes writing tests a breeze". (Pivotal Labs)

Live templates are abbreviations that are expanded into code fragments that you use to insert frequently-used code into your source. Live templates are a huge productivity boost, especially when constructing unit-tests where you find yourself repetitively creating suites and specs. Live Templates are available in all JetBrains IDEs including IntelliJ, PyCharm, WebStorm, PhpStorm and RubyMine.

###Why These Are Different

There are other Jasmine live templates out there but with these we have simplified the act of remembering the abbreviations used as the expansion characters for the code fragment. Generally, you start with j for Jasmine, then use the humps in the camel-case Jasmine function or Jasmine matcher name.

For instance, jbe, Jasmine beforeEach, would expand the beforeEach live template giving you a Jasmine beforeEach setup function.

beforeEach(function () {

});

jtb, Jasmine toBe would expand the toBe matcher Live Template giving you a Jasmine toBe expect and matcher.

expect('actual').toBe('expected');

Every matcher Live Template also has a negative assertion (not) Live Template. For instance,

jntb, Jasmine not toBe would expand the negative toBe matcher Live Template giving you a Jasmine not.toBe expect and matcher.

expect('actual').not.toBe('expected');

##Installation Copy the xml file to the following location:

  • Windows: <your home directory>\.<product name><version number>\config\templates
  • Linux: ~\.<product name><version number>\config\templates
  • MacOS: ~/Library/Preferences/<product name><version number>/templates

Once copied, you should be able to immediately use the Live Templates in your IntelliJ, PyCharm, WebStorm, PhpStorm or RubyMine IDE. You can view all the Live Templates in you system under File -> Settings -> IDE Settings -> Live Templates.

##Jasmine Suite, Spec, Setup and Teardown Live Templates (NOTE: these first 3 do not follow the camel-case abbreviation)

jdes - Jasmine Suite (describe)

describe('suite title', function () {

});

jit - Jasmine Spec (it)

it('spec title', function () {

});

jits - Jasmine Spec (it and starts your spec with the word should)

it('should ', function () {

});

jbe - Jasmine beforeEach (setup)

beforeEach(function () {

});

jae - Jasmine afterEach (teardown)

afterEach(function () {

});

Jasmine Matchers

jtb - Jasmine toBe expect(x).toBe(y));

jtbd - toBeDefined expect(x).toBeDefined());

jtbf - toBeFalsy expect(x).toBeFalsy());

jtbgt - toBeGreaterThan expect(x).toBeGreaterThan(y));

jtblt - toBeLessThan expect(x).toBeLessThan(y));

jtbn - toBeNull expect(x).toBeNull());

jtbt - toBeTruthy expect(x).toBeTruthy());

jtbu - toBeUndefined expect(actual).toBeUndefined();

jtc - toContain expect(x).toContain(y));

jte - toEqual expect(x).toEqual(y));

jtm - toMatch expect(x).toMatch(y));

jtt - toThrow expect(fn).toThrow(e));

Negated Matchers

jntb - not toBe expect(x).not.toBe(y));

jntbd - not toBeDefined expect(x).not.toBeDefined());

jntbf - not toBeFalsy expect(x).not.toBeFalsy());

jntbgt - not toBeGreaterThan expect(x).not.toBeGreaterThan(y));

jntblt - not toBeLessThan expect(x).not.toBeLessThan(y));

jntbn - not toBeNull expect(x).not.toBeNull());

jntbt - not toBeTruthy expect(x).not.toBeTruthy());

jntbu - not toBeUndefined expect(actual).not.toBeUndefined();

jntc - not toContain expect(x).not.toContain(y));

jnte - not toEqual expect(x).not.toEqual(y));

jntm - not toMatch expect(x).not.toMatch(y));

jntt - not toThrow expect(fn).not.toThrow(e));

About

Live templates for Jasmine in Jetbrains IDEs (WebStorm, etc).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published