Created
August 11, 2016 17:10
-
-
Save danielo515/d563c4a20be510edeb656ed0ac85a188 to your computer and use it in GitHub Desktop.
My javascript snippets for VSCode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
/* | |
// Place your snippets for JavaScript here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. 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, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected. | |
// Example: | |
"Print to console": { | |
"prefix": "log", | |
"body": [ | |
"console.log('$1');", | |
"$2" | |
], | |
"description": "Log output to console" | |
} | |
*/ | |
"use strict": { | |
"prefix": "use", | |
"body": [ | |
"'use strict';", | |
"$2" | |
], | |
"description": "use strict statement" | |
}, | |
"require package": { | |
"prefix": "req", | |
"body": [ | |
"require('$1');", | |
"$2" | |
], | |
"description": "require statement" | |
}, | |
"require Hook package": { | |
"prefix": "Hoek", | |
"body": [ | |
"const Hoek = require('Hoek');" | |
], | |
"description": "require Hoek" | |
}, | |
"JSON stringify": { | |
"prefix": "JSON.s", | |
"body": "JSON.stringify(${1:obj});", | |
"description": "stringify an object" | |
}, | |
//Unit test basic file | |
"Unit test headers": { | |
"prefix": "testheaders", | |
"body": [ | |
"'use strict'", | |
"\n\n// Load modules", | |
"\n\nconst Code = require('code');", | |
"\nconst Lab = require('lab');", | |
"\nconst Lib = require('../lib');", | |
"\nconst Version = require('../lib/version')", | |
"\nconst Hapi = require('hapi')", | |
"\nconst internals = {};", | |
"\n\n// Test shortcuts", | |
"\n\nconst lab = exports.lab = Lab.script();", | |
"\nconst describe = lab.describe;", | |
"\nconst it = lab.it;", | |
"\nconst expect = Code.expect;" | |
] | |
}, | |
//Unit test snippets stolen from VSCode.unitTestSnippets | |
"Unit Test Describe with it": { | |
"prefix": "det", | |
"body": [ | |
"describe ('$1', () => {\n", | |
"\tit('$2', (done) => {", | |
"\t\t$3", | |
"\t});", | |
"});" | |
], | |
"description": "Describe with it" | |
}, | |
"Unit Test Describe without it": { | |
"prefix": "deb", | |
"body": [ | |
"describe ('$1', (done) => {\n", | |
"\t$2", | |
"});" | |
], | |
"description": "Describe without it" | |
}, | |
"Unit Test it": { | |
"prefix": "dit", | |
"body": [ | |
"it ('$1', (done) => {\n", | |
"\t$2", | |
"});" | |
], | |
"description": "Unit Test it" | |
}, | |
"Expect toExist": { | |
"prefix": "ete", | |
"body": "expect(${object}).to.exist($1);$0", | |
"description": "Expect to exist" | |
}, | |
"Expect toNotExist": { | |
"prefix": "ene", | |
"body": "expect(${object}).to.not.exist($1);$0", | |
"description": "Expect to not Exist" | |
}, | |
"Expect toBe": { | |
"prefix": "etb", | |
"body": "expect(${object}).to.be.$1($2);$0", | |
"description": "Expect to be" | |
}, | |
"toNotBeNull": { | |
"prefix": "enb", | |
"body": "expect(${object}).to.not.be.null();$0", | |
"description": "Expect to not be null" | |
}, | |
"toBeNull": { | |
"prefix": "enb", | |
"body": "expect(${object}).to.be.null();$0", | |
"description": "Expect to be null" | |
}, | |
"Expect toEqual": { | |
"prefix": "etq", | |
"body": "expect(${object}).to.equal($1);$0", | |
"description": "Expect to be equal" | |
}, | |
"Expect toNotEqual": { | |
"prefix": "enq", | |
"body": "expect(${object}).to.not.equal($1);$0", | |
"description": "Expect toEqtoNotEqualual" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment