|
2 | 2 | ## VS Code JavaScript testing framework snippets
|
3 | 3 | -------------------
|
4 | 4 |
|
5 |
| -<!-- [](https://marketplace.visualstudio.com/items?itemName=xabikos.JasmineSnippets) |
6 |
| -[](https://marketplace.visualstudio.com/items?itemName=xabikos.JasmineSnippets) |
7 |
| -[](https://marketplace.visualstudio.com/items?itemName=xabikos.JasmineSnippets) --> |
| 5 | +<!-- [](https://marketplace.visualstudio.com/items?itemName=JaredE.javascript-test-snippets) |
| 6 | +[](https://marketplace.visualstudio.com/items?itemName=JaredE.javascript-test-snippets) |
| 7 | +[](https://marketplace.visualstudio.com/items?itemName=JaredE.javascript-test-snippets) --> |
8 | 8 |
|
9 |
| -This extension contains code snippets for various JavaScript testing frameworks, based off of the [Jasmine][jasmine] test framework and is based on the awesome [sublime-jasmine][sublime-jusmine] package by [@NicoSantangelo][NicoSantangelo]. |
| 9 | +This extension contains code snippets for the three main JavaScript testing frameworks: Jasmine, Jest and Mocha. You can switch between the code snippets available by setting your preferred framework at a User or Workspace level in the settings page. You can also choose the quote style (*"*, *'* or *\`*) you prefer at a User or Workspace level for your `desc` methods. |
10 | 10 |
|
11 |
| -[Original][original] credit should goto [xabikos][xabikos] for writing this extension. |
12 |
| - |
13 |
| -## Installation |
14 |
| - |
15 |
| -In order to install an extension you need to launch the Command Palette (Ctrl + Shift + P or Cmd + Shift + P) and type Extensions. |
16 |
| -There you have either the option to show the already installed snippets or install new ones. |
| 11 | +[Original][original] credit should goto [xabikos][xabikos] for writing this extension which was based off of the [Jasmine][jasmine] test framework and is based on the awesome [sublime-jasmine][sublime-jusmine] package by [@NicoSantangelo][NicoSantangelo]. |
17 | 12 |
|
18 | 13 | ## Supported languages (file extensions)
|
19 | 14 | * JavaScript (.js)
|
20 | 15 | * TypeScript (.ts)
|
21 |
| -* TypeScript React (.tsx) |
22 |
| -* JavaScript React (.jsx) |
23 | 16 |
|
24 | 17 | ## Snippets
|
25 | 18 |
|
26 | 19 | Below is a list of all available snippets and the triggers of each one. The **→** means the `TAB` key.
|
27 | 20 |
|
28 |
| -### Specs |
| 21 | +### Jest Commands |
| 22 | +| Trigger | Content | |
| 23 | +| -------: | ------- | |
| 24 | +| `aa→` | afterAll method | |
| 25 | +| `aaa→` | afterAllAsync method | |
| 26 | +| `ae→` | afterEach method | |
| 27 | +| `aea→` | afterEachAsync method | |
| 28 | +| `ba→` | beforeAll method | |
| 29 | +| `baa→` | beforeAllAsync method | |
| 30 | +| `be→` | beforeEach method | |
| 31 | +| `bea→` | beforeEachAsync method | |
| 32 | +| `desc→` | describe method | |
| 33 | +| `it→` | it method | |
| 34 | +| `ait→` | itAsync method | |
| 35 | +| `aat→` | afterAllTimeout method | |
| 36 | +| `aet→` | afterEachTimeout method | |
| 37 | +| `bat→` | beforeAllTimeout method | |
| 38 | +| `bet→` | beforeEachTimeout method | |
| 39 | +| `desce→` | describeEach method | |
| 40 | +| `desco→` | describeOnly method | |
| 41 | +| `desceo→` | describeOnlyEach method | |
| 42 | +| `descsk→` | describeSkip method | |
| 43 | +| `descse→` | describeSkipEach method | |
| 44 | +| `exp→` | expect method | |
| 45 | +| `expe→` | expect.extend method | |
| 46 | +| `expa→` | expect.anything method | |
| 47 | +| `exy→` | expect.any method | |
| 48 | +| `ac→` | expect.arrayContaining method | |
| 49 | +| `ass→` | expect.assertions method | |
| 50 | +| `ha→` | expect.hasAssertions method | |
| 51 | +| `nac→` | expect.not.arrayContaining method | |
| 52 | +| `noc→` | expect.not.objectContaining(object) method | |
| 53 | +| `nsc→` | expect.not.stringContaining method | |
| 54 | +| `nsm→` | expect.not.stringMatching method | |
| 55 | +| `oc→` | expect.objectContaining method | |
| 56 | +| `sc→` | expect.stringContaining method | |
| 57 | +| `sm→` | expect.stringMatching method | |
| 58 | +| `ass→` | expect.addSnapshotSerializer method | |
| 59 | +| `ito→` | itOnly method | |
| 60 | +| `itsk→` | itSkip method | |
| 61 | +| `not→` | not method | |
| 62 | +| `res→` | resolves method | |
| 63 | +| `rej→` | rejects method | |
| 64 | +| `te→` | test method | |
| 65 | +| `tea→` | testAsync method | |
| 66 | +| `tee→` | testEach method | |
| 67 | +| `teo→` | testOnly method | |
| 68 | +| `teoe→` | testOnlyEach method | |
| 69 | +| `tsk→` | testSkip method | |
| 70 | +| `tske→` | testSkipEach method | |
| 71 | +| `ttodo→` | testToDo method | |
| 72 | +| `tb→` | toBe method | |
| 73 | +| `tbc→` | toHaveBeenCalled method | |
| 74 | +| `bct→` | toHaveBeenCalledTimes method | |
| 75 | +| `bcw→` | toHaveBeenCalledWith method | |
| 76 | +| `bclw→` | toHaveBeenLastCalledWith method | |
| 77 | +| `bncw→` | toHaveBeenNthCalledWith method | |
| 78 | +| `hr→` | toHaveReturned method | |
| 79 | +| `hrt→` | toHaveReturnedTimes method | |
| 80 | +| `hrw→` | toHaveReturnedWith method | |
| 81 | +| `hlrw→` | toHaveLastReturnedWith method | |
| 82 | +| `tnrw→` | toHaveNthReturnedWith method | |
| 83 | +| `hl→` | toHaveLength method | |
| 84 | +| `hp→` | toHaveProperty method | |
| 85 | +| `bclt→` | toBeCloseTo method | |
| 86 | +| `tbd→` | toBeDefined method | |
| 87 | +| `tbf→` | toBeFalsy method | |
| 88 | +| `gt→` | toBeGreaterThan method | |
| 89 | +| `gte→` | toBeGreaterThanOrEqual method | |
| 90 | +| `lt→` | toBeLessThan method | |
| 91 | +| `lte→` | toBeLessThanOrEqual method | |
| 92 | +| `bio→` | toBeInstanceOf method | |
| 93 | +| `bnu→` | toBeNull method | |
| 94 | +| `btr→` | toBeTruthy method | |
| 95 | +| `bund→` | toBeUndefined method | |
| 96 | +| `bnan→` | toBeNaN method | |
| 97 | +| `tcon→` | toContain method | |
| 98 | +| `tce→` | toContainEqual method | |
| 99 | +| `te→` | toEqual method | |
| 100 | +| `tm→` | toMatch method | |
| 101 | +| `tmo→` | toMatchObject method | |
| 102 | +| `tms→` | toMatchSnapshot method | |
| 103 | +| `tmis→` | toMatchInlineSnapshot method | |
| 104 | +| `tse→` | toStrictEqual method | |
| 105 | +| `ttr→` | toThrow method | |
| 106 | +| `ttrer→` | toThrowErrorMatchingSnapshot method | |
| 107 | +| `tterrin→` | toThrowErrorMatchingInlineSnapshot method | |
| 108 | + |
| 109 | +### Jasmine Commands |
| 110 | + |
29 | 111 | | Trigger | Content |
|
30 | 112 | | -------: | ------- |
|
31 |
| -| `desc→` | describe method | |
32 |
| -| `xdesc→` | xdescribe method | |
33 |
| -| `fdesc→` | fdescribe method | |
34 |
| -| `it→` | it method | |
35 |
| -| `ait→` | async it method | |
36 |
| -| `xit→` | xit method | |
37 |
| -| `fit→` | fit method | |
38 |
| -| `ae→` | after each method | |
39 |
| -| `aa→` | after all methods | |
40 |
| -| `be→` | before each method | |
41 |
| -| `ba→` | before all methods | |
| 113 | +| `aa→` | afterAll method | |
| 114 | +| `aaa→` | afterAllAsync method | |
| 115 | +| `ae→` | afterEach method | |
| 116 | +| `aea→` | afterEachAsync method | |
| 117 | +| `ba→` | beforeAll method | |
| 118 | +| `baa→` | beforeAllAsync method | |
| 119 | +| `be→` | beforeEach method | |
| 120 | +| `bea→` | beforeEachAsync method | |
| 121 | +| `desc→` | describe method | |
| 122 | +| `it→` | it method | |
| 123 | +| `ait→` | itAsync method | |
| 124 | +| `aat→` | afterAllTimeout method | |
| 125 | +| `aet→` | afterEachTimeout method | |
| 126 | +| `bat→` | beforeAllTimeout method | |
| 127 | +| `bet→` | beforeEachTimeout method | |
| 128 | +| `exp→` | expect method | |
| 129 | +| `expa→` | expectAsync method | |
| 130 | +| `fa→` | fail method | |
| 131 | +| `fdesc→` | focusDescribe method | |
| 132 | +| `fit→` | focusedIt method | |
| 133 | +| `pen→` | pending method | |
| 134 | +| `ssp→` | setSpecProperty method | |
| 135 | +| `ssup→` | setSuiteProperty method | |
| 136 | +| `so→` | spyOn method | |
| 137 | +| `soaf→` | spyOnAllFunctions method | |
| 138 | +| `spg→` | spyOnProperty get method | |
| 139 | +| `sps→` | spyOnProperty set method | |
| 140 | +| `xdesc→` | xDescribe method | |
| 141 | +| `xit→` | xIt method | |
| 142 | +| `xait→` | xItAsync method | |
42 | 143 |
|
43 |
| -### Expectations |
44 |
| -| Trigger | Content | |
45 |
| -| -------: | ------- | |
46 |
| -| `exp→` | expect | |
47 |
| -| `tb→` | expect().toBe | |
48 |
| -| `tbct→` | expect().toBeCloseTo | |
49 |
| -| `tbd→` | expect().toBeDefined | |
50 |
| -| `tbf→` | expect().toBeFalsy | |
51 |
| -| `tbgt→` | expect().toBeGreaterThan | |
52 |
| -| `tblt→` | expect().toBeLessThan | |
53 |
| -| `tbn→` | expect().toBeNull | |
54 |
| -| `tbt→` | expect().toBeTruthy | |
55 |
| -| `tbu→` | expect().toBeUndefined | |
56 |
| -| `tc→` | expect().toContain | |
57 |
| -| `te→` | expect().toEqual | |
58 |
| -| `thbc→` | expect().toHaveBeenCalled | |
59 |
| -| `thbcw→` | expect().toHaveBeenCalledWith | |
60 |
| -| `tm→` | expect().toMatch | |
61 |
| -| `tt→` | expect().toThrow | |
62 |
| -| `tte→` | expect().toThrowError | |
63 |
| -| `nb→` | expect().not.toBe | |
64 |
| -| `nct→` | expect().not.toBeCloseTo | |
65 |
| -| `nd→` | expect().not.toBeDefined | |
66 |
| -| `nf→` | expect().not.toBeFalsy | |
67 |
| -| `ngt→` | expect().not.toBeGreaterThan | |
68 |
| -| `nlt→` | expect().not.toBeLessThan | |
69 |
| -| `nn→` | expect().not.toBeNull | |
70 |
| -| `nt→` | expect().not.toBeTruthy | |
71 |
| -| `nu→` | expect().not.toBeUndefined | |
72 |
| -| `nc→` | expect().not.toContain | |
73 |
| -| `ne→` | expect().not.toEqual | |
74 |
| -| `nm→` | expect().not.toMatch | |
75 |
| -| `nt→` | expect().not.toThrow | |
76 |
| -| `any→` | jasmine.any | |
77 |
| -| `oc→` | jasmine.objectContaining | |
| 144 | +### mocha commands |
78 | 145 |
|
79 |
| -### Spies |
80 |
| -| Trigger | Content | |
81 |
| -| -------: | ------- | |
82 |
| -|`so→` | spyOn | |
83 |
| -|`sct→` | spyOn.and.callThrough | |
84 |
| -|`scf→` | spyOn.and.callFake | |
85 |
| -|`spg→` | spyOnProperty($obj,'$property', 'get') | |
86 |
| -|`sps→` | spyOnProperty($obj,'$property', 'set') | |
87 |
| -|`srv→` | spyOn.and.returnValue | |
88 |
| -|`ss→` | spyOn.and.stub | |
89 |
| -|`ste→` | spyOn.and.throwError | |
90 |
| -|`ca→` | spy.calls.all | |
91 |
| -|`caa→` | spy.calls.allArgs | |
92 |
| -|`ca→` | spy.calls.any | |
93 |
| -|`caf→` | spy.calls.argsFor | |
94 |
| -|`cc→` | spy.calls.count | |
95 |
| -|`cf→` | spy.calls.first | |
96 |
| -|`cmr→` | spy.calls.mostRecent | |
97 |
| -|`cr→` | spy.calls.reset | |
98 |
| -|`cs→` | createSpy | |
99 |
| -|`cso→` | createSpyObj | |
| 146 | +| Trigger | Content | |
| 147 | +| -------: | ------- | |
| 148 | +| `aa→` | afterAll method | |
| 149 | +| `aaa→` | afterAllAsync method | |
| 150 | +| `ae→` | afterEach method | |
| 151 | +| `aea→` | afterEachAsync method | |
| 152 | +| `ba→` | beforeAll method | |
| 153 | +| `baa→` | beforeAllAsync method | |
| 154 | +| `be→` | beforeEach method | |
| 155 | +| `bea→` | beforeEachAsync method | |
| 156 | +| `desc→` | describe method | |
| 157 | +| `it→` | it method | |
| 158 | +| `ait→` | itAsync method | |
| 159 | +| `desco→` | describeOnly method | |
| 160 | +| `descsk→` | describeSkip method | |
| 161 | +| `ito→` | itOnly method | |
| 162 | +| `itsk→` | itSkip method | |
100 | 163 |
|
101 | 164 | [jasmine]: http://jasmine.github.io
|
102 | 165 | [sublime-jusmine]: https://github.com/NicoSantangelo/sublime-jasmine
|
|
0 commit comments