/vim-jest-snippets

Vim editor UltiSnips snippets for Jest

Primary LanguageVim ScriptMIT LicenseMIT

Vim Jest Snippets

Snippets for UltiSnips

An Vim snippet library for Jest. This library uses ES6 syntax.

Based on Atom Jest Snippets.

Installation

Using Vundle

Add this line to your .vimrc file

Plugin 'joaohkfaria/vim-jest-snippets'

Snippet Available

[exp]

expect(value)

expect($1)$2;

[ebe]

expect(value).toBe(value)

expect($1).toBe($2);

[ecall]

expect(mockFn).toHaveBeenCalled()

expect($1).toHaveBeenCalled();

[ecallt]

expect(mockFn).toHaveBeenCalledTimes(number)

expect($1).toHaveBeenCalledTimes($2);

[ecallw]

expect(mockFn).toHaveBeenCalledWith(arg1, arg2, ...)

expect($1).toHaveBeenCalledWith($2);

[ecloseto]

expect(number).toBeCloseTo(number, numDigits)

expect($1).toBeCloseTo($2, $3);

[edef]

expect(value).toBeDefined()

expect($1).toBeDefined();

[efalsy]

expect(value).toBeFalsy()

expect($1).toBeFalsy();

[egreater]

expect(number).toBeGreaterThan(number)

expect($1).toBeGreaterThan($2);

[egreateror]

expect(number).toBeGreaterThanOrEqual(number)

expect($1).toBeGreaterThanOrEqual($2);

[eless]

expect(number).toBeLessThan(number)

expect($1).toBeLessThan($2);

[elessor]

expect(number).toBeLessThanOrEqual(number)

expect($1).toBeLessThanOrEqual($2);

[einst]

expect(obj).toBeInstanceOf(Class)

expect($1).toBeInstanceOf($2);

[enull]

expect(value).toBeNull()

expect($1).toBeNull();

[etruthy]

expect(value).toBeTruthy()

expect($1).toBeTruthy();

[eundef]

expect(value).toBeUndefined()

expect($1).toBeUndefined();

[econ]

expect(list).toContain(value)

expect($1).toContain($2);

[econeq]

expect(list).toContainEqual(value)

expect($1).toContainEqual($2);

[eeq]

expect(value).toEqual(value)

expect($1).toEqual($2);

[eleng]

expect(list).toHaveLength(number)

expect($1).toHaveLength($2);

[emat]

expect(string).toMatch(regexpOrString)

expect($1).toMatch($2);

[ematob]

expect(obj).toMatchObject(obj)

expect($1).toMatchObject($2);

[ematsnap]

expect(value).toMatchSnapshot(optionalString)

expect($1).toMatchSnapshot($2);

[ethrow]

expect(func).toThrow(error)

expect($1).toThrow($2);

[desc]

describe(name, fn)

describe('$1', () => {
  $2
});

[test]

test(name, fn)

test('$1', () => {
  $2
});

[it]

alias for test()

it('$1', () => {
  $2
});

[aftera]

afterAll(fn)

afterAll(() => {
  $1
})

[aftere]

afterEach(fn)

afterEach(() => {
  $1
})

[beforea]

beforeAll(fn)

beforeAll(() => {
  $1
})

[beforee]

beforeEach(fn)

beforeEach(() => {
  $1
})

[jcleartimers]

jest.clearAllTimers();

[jdisableautomock]

jest.disableAutomock();

[jenableautomock]

jest.enableAutomock();

[jfn]

jest.fn($1);

[jismock]

jest.isMockFunction($1);

[jgenmock]

jest.genMockFromModule($1);

[jmock]

jest.mock($1);

[jresetallmocks]

jest.resetAllMocks();

[jresetmodules]

jest.resetModules();

[jrunticks]

jest.runAllTicks();

[jruntimers]

jest.runAllTimers();

[jrunpendtimers]

jest.runOnlyPendingTimers();

[jsetmock]

jest.setMock($1);

[junmock]

jest.unmock($1);

[jfaketimers]

jest.useFakeTimers($1);

[jrealtimers]

jest.useRealTimers($1);

[mclear]

.mockClear();

[mreset]

.mockReset();

[mimpl]

.mockImplementation($1);

[mimplonce]

.mockImplementationOnce($1);

[mrett]

.mockReturnThis();

[mretval]

.mockReturnValue($1);

[mretvalo]

.mockReturnValueOnce($1);