487 lines
14 KiB
JSON
487 lines
14 KiB
JSON
{
|
|
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
|
|
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
|
|
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
|
|
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
|
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
|
|
// Placeholders with the same ids are connected.
|
|
// Example:
|
|
// "Print to console": {
|
|
// "scope": "javascript,typescript",
|
|
// "prefix": "log",
|
|
// "body": [
|
|
// "console.log('$1');",
|
|
// "$2"
|
|
// ],
|
|
// "description": "Log output to console"
|
|
// }
|
|
"private readonly ...": {
|
|
"scope": "typescript",
|
|
"prefix": "prr",
|
|
"body": [
|
|
"private readonly _${1:name}: ${2:Type}"
|
|
]
|
|
},
|
|
"props": {
|
|
"scope": "typescriptreact",
|
|
"prefix": "props",
|
|
"body": [
|
|
"{ className }: { className?: string }"
|
|
]
|
|
},
|
|
"prop": {
|
|
"scope": "typescript",
|
|
"prefix": "prop",
|
|
"body": [
|
|
"private _${1:name}: ${3:Type}",
|
|
"get${2:Name}(): ${3:Type} {",
|
|
" return this._${1:name}",
|
|
"}",
|
|
"set${2:Name}(${1:name}: ${3:Type}) {",
|
|
" this._${1:name} = ${1:name}",
|
|
"}"
|
|
]
|
|
},
|
|
"roprop": {
|
|
"scope": "typescript",
|
|
"prefix": "ro",
|
|
"body": [
|
|
"private readonly _${1:name}: ${3:Type};",
|
|
"get${2:Name}(): ${3:Type} {",
|
|
" return this._${1:name}",
|
|
"}"
|
|
]
|
|
},
|
|
"vs": {
|
|
"scope": "typescript",
|
|
"prefix": "vs",
|
|
"body": [
|
|
"vi.spyOn(${1:class}, \"${2:method}\")${3:.mock$4};"
|
|
]
|
|
},
|
|
"faker lorem word": {
|
|
"scope": "typescript",
|
|
"prefix": "flw",
|
|
"body": [
|
|
"faker.lorem.word();"
|
|
]
|
|
},
|
|
"react prop": {
|
|
"scope": "typescript",
|
|
"prefix": "comp",
|
|
"body": [
|
|
"import React from \"react\";",
|
|
"",
|
|
"export default function ${1:name}({className}: {className?: string}) {",
|
|
" return (",
|
|
" <${2:div} className={`${className}`}>",
|
|
" $0",
|
|
" </${2:div}>",
|
|
" )",
|
|
"}"
|
|
]
|
|
},
|
|
// ╭─────────────────────────────────────────────────────────╮
|
|
// │ Jest (vitest) snippets down below │
|
|
// ╰─────────────────────────────────────────────────────────╯
|
|
"afterAll": {
|
|
"body": "afterAll(() => {\n\t$0\n});",
|
|
"description": "afterAll function is called once after all specs",
|
|
"prefix": "aa",
|
|
"scope": "typescript"
|
|
},
|
|
"afterEach": {
|
|
"body": "afterEach(() => {\n\t$0\n});",
|
|
"description": "afterEach function is called once after each spec",
|
|
"prefix": "ae",
|
|
"scope": "typescript"
|
|
},
|
|
"beforeAll": {
|
|
"body": "beforeAll(() => {\n\t$0\n});",
|
|
"description": "beforeAll function is called once before all specs",
|
|
"prefix": "ba",
|
|
"scope": "typescript"
|
|
},
|
|
"beforeAll:async": {
|
|
"body": "beforeAll(async () => {\n\t$0\n});",
|
|
"description": "beforeAll with async function is called once before all specs",
|
|
"prefix": "baa",
|
|
"scope": "typescript"
|
|
},
|
|
"beforeEach": {
|
|
"body": "beforeEach(() => {\n\t$0\n});",
|
|
"description": "beforeEach function is called once before each spec",
|
|
"prefix": "be",
|
|
"scope": "typescript"
|
|
},
|
|
"beforeEach:async": {
|
|
"body": "beforeEach(async () => {\n\t$0\n});",
|
|
"description": "beforeEach with async callback function is called once before each spec",
|
|
"prefix": "bea",
|
|
"scope": "typescript"
|
|
},
|
|
"describe": {
|
|
"body": "describe('${1:Name of the group}', () => {\n\t$0\n});",
|
|
"description": "creates a describe block",
|
|
"prefix": "desc",
|
|
"scope": "typescript"
|
|
},
|
|
"describe.each": {
|
|
"body": [
|
|
"describe.each([${1:[1, 2], [2, 4]}])(",
|
|
"\t'${2:double(%d)}',",
|
|
"\t(${3:input, expected}) => {",
|
|
"\t\ttest(`returns \\${expected}`, () => {",
|
|
"\t\t\t${4:expect(double(input)).toBe(expected);}",
|
|
"\t\t});",
|
|
"\t}",
|
|
");"
|
|
],
|
|
"description": "creates a describe block with different test data sets",
|
|
"prefix": "desce",
|
|
"scope": "typescript"
|
|
},
|
|
"describe.only": {
|
|
"body": "describe.only('${1:Name of the group}', () => {\n\t$0\n});",
|
|
"description": "creates a describe block that runs only",
|
|
"prefix": "desco",
|
|
"scope": "typescript"
|
|
},
|
|
"describe.skip": {
|
|
"body": "describe.skip('${1:Name of the group}', () => {\n\t$0\n});",
|
|
"description": "creates a describe block that will be skipped",
|
|
"prefix": "descs",
|
|
"scope": "typescript"
|
|
},
|
|
"expect": {
|
|
"body": "expect($0)",
|
|
"description": "expect actual value",
|
|
"prefix": "exp",
|
|
"scope": "typescript"
|
|
},
|
|
"expect.assertions": {
|
|
"body": "expect.assertions($0);",
|
|
"description": "expects the test to make the indicated number of assertions (useful for async)",
|
|
"prefix": "expas",
|
|
"scope": "typescript"
|
|
},
|
|
"expect.hasAssertions": {
|
|
"body": "expect.hasAssertions();$0",
|
|
"description": "expects the test to make at least one assertion (useful for async)",
|
|
"prefix": "expha",
|
|
"scope": "typescript"
|
|
},
|
|
"expect.rejects": {
|
|
"body": "expect($1).rejects$0",
|
|
"description": "expect promise rejects to",
|
|
"prefix": "exprj",
|
|
"scope": "typescript"
|
|
},
|
|
"expect.resolves": {
|
|
"body": "expect($1).resolves$0",
|
|
"description": "expect promise resolves to",
|
|
"prefix": "expr",
|
|
"scope": "typescript"
|
|
},
|
|
"it": {
|
|
"body": "it('${1:should }', () => {\n\t$0\n});",
|
|
"description": "creates an it block",
|
|
"prefix": "it",
|
|
"scope": "typescript"
|
|
},
|
|
"it.each": {
|
|
"body": [
|
|
"it.each([${1:[1, 2], [2, 4]}])(",
|
|
"\t'${2:double(%d)}',",
|
|
"\t(${3:input, expected}) => {",
|
|
"\t\t${0:expect(double(input)).toBe(expected);}",
|
|
"\t}",
|
|
");"
|
|
],
|
|
"description": "creates an it block with different test data sets",
|
|
"prefix": "ite",
|
|
"scope": "typescript"
|
|
},
|
|
"it.only": {
|
|
"body": "it.only('${1:should }', () => {\n\t$0\n});",
|
|
"description": "creates an it block that runs only",
|
|
"prefix": "ito",
|
|
"scope": "typescript"
|
|
},
|
|
"it.skip": {
|
|
"body": "it.skip('${1:should }', () => {\n\t$0\n});",
|
|
"description": "creates an it block that will be skipped",
|
|
"prefix": "its",
|
|
"scope": "typescript"
|
|
},
|
|
"it.todo": {
|
|
"body": "it.todo('${1:should }');",
|
|
"description": "creates a test placeholder",
|
|
"prefix": "itt",
|
|
"scope": "typescript"
|
|
},
|
|
"it:async": {
|
|
"body": "it('${1:should }', async () => {\n\t$0\n});",
|
|
"description": "creates an it block with async callback function",
|
|
"prefix": "ita",
|
|
"scope": "typescript"
|
|
},
|
|
"jest.fn": {
|
|
"body": "jest.fn($0)",
|
|
"description": "creates jest.fn()",
|
|
"prefix": "jfn",
|
|
"scope": "typescript"
|
|
},
|
|
"template:cut": {
|
|
"body": [
|
|
"describe('${1:Name of the group}', () => {\n",
|
|
"\tlet ${2:cut};\n",
|
|
"\tbeforeEach(() => {\n\t\t$2 = $3;\n\t});\n",
|
|
"\ttest('${1:should }', () => {",
|
|
"\t\texpect($2).toBe($0);",
|
|
"\t});\n",
|
|
"});"
|
|
],
|
|
"description": "creates a template to test a class under test",
|
|
"prefix": "cut",
|
|
"scope": "typescript"
|
|
},
|
|
"test": {
|
|
"body": "test('${1:should }', () => {\n\t$0\n});",
|
|
"description": "creates a test block",
|
|
"prefix": "test",
|
|
"scope": "typescript"
|
|
},
|
|
"test.each": {
|
|
"body": [
|
|
"test.each([${1:[1, 2], [2, 4]}])(",
|
|
"\t'${2:double(%d)}',",
|
|
"\t(${3:input, expected}) => {",
|
|
"\t\t${0:expect(double(input)).toBe(expected);}",
|
|
"\t}",
|
|
");"
|
|
],
|
|
"description": "creates an test block with different test data sets",
|
|
"prefix": "teste",
|
|
"scope": "typescript"
|
|
},
|
|
"test.each (table)": {
|
|
"body": [
|
|
"test.each`",
|
|
"\t${1:input}\t| ${2:expected}",
|
|
"\t\\${1}\t| \\${2}",
|
|
"\t\\${2}\t| \\${4}",
|
|
"`('${3:double($${1:input})}', ({ ${1:input}, ${2:expected} }) => {",
|
|
"\t${0:expect(double(${1:input})).toBe(${2:expected});}",
|
|
"});"
|
|
],
|
|
"description": "creates a test block using a permutation table",
|
|
"prefix": "testet",
|
|
"scope": "typescript"
|
|
},
|
|
"test.only": {
|
|
"body": "test.only('${1:should }', () => {\n\t$0\n});",
|
|
"description": "creates a test block that runs only",
|
|
"prefix": "testo",
|
|
"scope": "typescript"
|
|
},
|
|
"test.skip": {
|
|
"body": "test.skip('${1:should }', () => {\n\t$0\n});",
|
|
"description": "creates a test block that will be skipped",
|
|
"prefix": "tests",
|
|
"scope": "typescript"
|
|
},
|
|
"test.todo": {
|
|
"body": "test.todo('${1:should }');",
|
|
"description": "creates a test placeholder",
|
|
"prefix": "testt",
|
|
"scope": "typescript"
|
|
},
|
|
"test:async": {
|
|
"body": "test('${1:should }', async () => {\n\t$0\n});",
|
|
"description": "creates an test block with async callback function",
|
|
"prefix": "testa",
|
|
"scope": "typescript"
|
|
},
|
|
"toBe": {
|
|
"body": "expect($1).toBe($2);$0",
|
|
"description": "expects the first argument to be equal with the second one",
|
|
"prefix": "tb",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeCloseTo": {
|
|
"body": "expect($1).toBeCloseTo(${2:number}, ${3:delta});$0",
|
|
"description": "expects the first argument to be close to the second one base on the delta",
|
|
"prefix": "tbct",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeDefined": {
|
|
"body": "expect($1).toBeDefined();$0",
|
|
"description": "expects the argument is defined",
|
|
"prefix": "tbd",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeFalsy": {
|
|
"body": "expect($1).toBeFalsy();$0",
|
|
"description": "expects the argument is falsy",
|
|
"prefix": "tbf",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeGreaterThan": {
|
|
"body": "expect($1).toBeGreaterThan($2);$0",
|
|
"description": "expects the argument is greater than or equal",
|
|
"prefix": "tbgt",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeGreaterThanOrEqual": {
|
|
"body": "expect($1).toBeGreaterThanOrEqual($2);$0",
|
|
"description": "expects the argument is greater than",
|
|
"prefix": "tbgte",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeInstanceOf": {
|
|
"body": "expect($1).toBeInstanceOf($2);$0",
|
|
"description": "expects the argument is less than",
|
|
"prefix": "tbi",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeLessThan": {
|
|
"body": "expect($1).toBeLessThan($2);$0",
|
|
"description": "expects the argument is less than",
|
|
"prefix": "tblt",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeLessThanOrEqual": {
|
|
"body": "expect($1).toBeLessThanOrEqual($2);$0",
|
|
"description": "expects the argument is less than or equal",
|
|
"prefix": "tblte",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeNull": {
|
|
"body": "expect($1).toBeNull();$0",
|
|
"description": "expects the argument is null",
|
|
"prefix": "tbn",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeTruthy": {
|
|
"body": "expect($1).toBeTruthy();$0",
|
|
"description": "expects the argument is truthy",
|
|
"prefix": "tbt",
|
|
"scope": "typescript"
|
|
},
|
|
"toBeUndefined": {
|
|
"body": "expect($1).toBeUndefined();$0",
|
|
"description": "expects the argument is undefined",
|
|
"prefix": "tbu",
|
|
"scope": "typescript"
|
|
},
|
|
"toContain": {
|
|
"body": "expect(${1:list}).toContain($2);$0",
|
|
"description": "expects the list contains the item (===)",
|
|
"prefix": "tc",
|
|
"scope": "typescript"
|
|
},
|
|
"toContainEqual": {
|
|
"body": "expect(${1:list}).toContainEqual($2);$0",
|
|
"description": "expects the list contains the item (equals)",
|
|
"prefix": "tce",
|
|
"scope": "typescript"
|
|
},
|
|
"toEqual": {
|
|
"body": "expect($1).toEqual($2);$0",
|
|
"description": "expects the first argument to be equal with the second one",
|
|
"prefix": "te",
|
|
"scope": "typescript"
|
|
},
|
|
"toHaveBeenCalled": {
|
|
"body": "expect($1).toHaveBeenCalled();$0",
|
|
"description": "returns true if the spy was called",
|
|
"prefix": "thbc",
|
|
"scope": "typescript"
|
|
},
|
|
"toHaveBeenCalledTimes": {
|
|
"body": "expect($1).toHaveBeenCalledTimes($2);$0",
|
|
"description": "returns true if the spy has been called given times",
|
|
"prefix": "thbct",
|
|
"scope": "typescript"
|
|
},
|
|
"toHaveBeenCalledWith": {
|
|
"body": "expect($1).toHaveBeenCalledWith($2);$0",
|
|
"description": "returns true if the spy has been called with",
|
|
"prefix": "thbcw",
|
|
"scope": "typescript"
|
|
},
|
|
"toHaveBeenLastCalledWith": {
|
|
"body": "expect($1).toHaveBeenLastCalledWith($2);$0",
|
|
"description": "returns true if the spy has been last called with",
|
|
"prefix": "thblcw",
|
|
"scope": "typescript"
|
|
},
|
|
"toHaveLength": {
|
|
"body": "expect($1).toHaveLength($2);$0",
|
|
"description": "expects the object to have length",
|
|
"prefix": "thl",
|
|
"scope": "typescript"
|
|
},
|
|
"toHaveProperty": {
|
|
"body": "expect($1).toHaveProperty(${2:keyPath}, ${3:value});$0",
|
|
"description": "returns true if the argument matches the second object",
|
|
"prefix": "thp",
|
|
"scope": "typescript"
|
|
},
|
|
"toMatch": {
|
|
"body": "expect($1).toMatch($2);$0",
|
|
"description": "returns true if the argument matches the second value",
|
|
"prefix": "tm",
|
|
"scope": "typescript"
|
|
},
|
|
"toMatchInlineSnapshot": {
|
|
"body": "expect($1).toMatchInlineSnapshot($2);$0",
|
|
"description": "returns true if the argument matches the most recent inline snapshot",
|
|
"prefix": "tmis",
|
|
"scope": "typescript"
|
|
},
|
|
"toMatchObject": {
|
|
"body": "expect($1).toMatchObject($2);$0",
|
|
"description": "returns true if the argument matches the second object",
|
|
"prefix": "tmo",
|
|
"scope": "typescript"
|
|
},
|
|
"toMatchSnapshot": {
|
|
"body": "expect($1).toMatchSnapshot($2);$0",
|
|
"description": "returns true if the argument matches the most recent snapshot",
|
|
"prefix": "tms",
|
|
"scope": "typescript"
|
|
},
|
|
"toStrictEqual": {
|
|
"body": "expect($1).toStrictEqual($2);$0",
|
|
"description": "expects the first argument to be strictly equal with the second one",
|
|
"prefix": "tse",
|
|
"scope": "typescript"
|
|
},
|
|
"toThrow": {
|
|
"body": "expect(() => {\n\t$0\n}).toThrow($1);",
|
|
"description": "expects that the method will throw an error",
|
|
"prefix": "tt",
|
|
"scope": "typescript"
|
|
},
|
|
"toThrowError": {
|
|
"body": "expect(() => {\n\t$0\n}).toThrowError($1);",
|
|
"description": "expects that the method will throw an error",
|
|
"prefix": "tte",
|
|
"scope": "typescript"
|
|
},
|
|
"toThrowErrorMatchingInlineSnapshot": {
|
|
"body": "expect(() => {\n\t$0\n}).toThrowErrorMatchingInlineSnapshot();",
|
|
"description": "expects that the method will throw an error matching the inline snapshot",
|
|
"prefix": "ttemis",
|
|
"scope": "typescript"
|
|
},
|
|
"toThrowErrorMatchingSnapshot": {
|
|
"body": "expect(() => {\n\t$0\n}).toThrowErrorMatchingSnapshot();",
|
|
"description": "expects that the method will throw an error mathing the snapshpot",
|
|
"prefix": "ttems",
|
|
"scope": "typescript"
|
|
}
|
|
}
|