Skip to content

Commit b1a44dd

Browse files
committed
testrunner
1 parent e9f996b commit b1a44dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+13329
-160
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ out
22
node_modules
33
.vscode-test/
44
*.vsix
5+
yarn-error.log

Diff for: .prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/src/vs/**/*

Diff for: README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,29 @@ Install and open [Visual Studio Code](https://code.visualstudio.com/). Press `Ct
2727

2828
## Configuration options
2929

30-
| Property | Type | Default | Allowed Values | Description |
31-
| :------------------------------------ | :-------------- | :------------------------------------------------- | :---------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
32-
| `createTests.defaultLocationForFiles` | string | `same location as source file` | 1. `same location as source file`,     2. `project root` | Location where you want to keep the test files. |
33-
| `createTests.sourceDir` | string | `src` | any string value | Name of directory which contains all source files. This directory is not created when generating the directory structure for the test file. |
34-
| `createTests.directoryName` | string | `tests` | any string value (allows empty string) | Name of the directory which should contain all the test files. If this config option value is set to an empty string then it keeps the test file next to the source file. |
35-
| `createTests.customLocationForFiles` | string | - | any valid path | Set this property in case you want to specify the custom location for test files. |
36-
| `createTests.filesSuffix` | string | 'test' | any string value | Suffix to append for every created test file |
37-
| `createTests.shouldSwitchToFile` | boolean | true | true \| false | Whether to switch to the created test file or not |
38-
| `createTests.template.default` | array \| object | `["import {${moduleName}} from '${modulePath}';"]` | any string array or object | Default template to use for all test file |
39-
| `createTests.template.*` | array \| object | - | string array or object | Language specific templates that you want to use. |
30+
| Property | Type | Default | Allowed Values | Description |
31+
| :----------------------------------- | :-------------- | :------------------------------------------------- | :---------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
32+
| `testRunner.defaultLocationForFiles` | string | `same location as source file` | 1. `same location as source file`,     2. `project root` | Location where you want to keep the test files. |
33+
| `testRunner.sourceDir` | string | `src` | any string value | Name of directory which contains all source files. This directory is not created when generating the directory structure for the test file. |
34+
| `testRunner.directoryName` | string | `tests` | any string value (allows empty string) | Name of the directory which should contain all the test files. If this config option value is set to an empty string then it keeps the test file next to the source file. |
35+
| `testRunner.customLocationForFiles` | string | - | any valid path | Set this property in case you want to specify the custom location for test files. |
36+
| `testRunner.filesSuffix` | string | 'test' | any string value | Suffix to append for every created test file |
37+
| `testRunner.shouldSwitchToFile` | boolean | true | true \| false | Whether to switch to the created test file or not |
38+
| `testRunner.template.default` | array \| object | `["import {${moduleName}} from '${modulePath}';"]` | any string array or object | Default template to use for all test file |
39+
| `testRunner.template.*` | array \| object | - | string array or object | Language specific templates that you want to use. |
4040

4141
## Template types
4242

4343
Templates are used to initialize test files with default content. It eases the task and removes boilerplate code. Following template types are supported.
4444

4545
### 1. Default template
4646

47-
The default template for any file can be specified by overriding the configuration `createTests.template.default`.
47+
The default template for any file can be specified by overriding the configuration `testRunner.template.default`.
4848
Default value for this template is: `"import ${moduleName} from '${modulePath}';"` Here, `moduleName` and `modulePath` are special placeholders, which gets replaces with the source file name and the relative path to the source file respectively.
4949

5050
### 2. Language-specific templates
5151

52-
When creating the test files, this extension reads the configuration for the template specified by `createTests.template.<file-extension>`. So if your file name is `MyFile.js` then the extension will read the configuration `createTests.template.js` for the template. If it finds one then it will write the content of the template into the created test file.
52+
When creating the test files, this extension reads the configuration for the template specified by `testRunner.template.<file-extension>`. So if your file name is `MyFile.js` then the extension will read the configuration `testRunner.template.js` for the template. If it finds one then it will write the content of the template into the created test file.
5353

5454
**Note**: Language-specific templates have higher priority over the default template.
5555

Diff for: package.json

+176-23
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,58 @@
3434
"contributes": {
3535
"commands": [
3636
{
37-
"command": "createTests.create",
37+
"command": "testRunner.create",
3838
"title": "Create test file"
3939
},
4040
{
4141
"command": "createStory.create",
4242
"title": "Create story file"
43+
},
44+
{
45+
"command": "testRunner.test",
46+
"title": "Test this file"
4347
}
4448
],
4549
"menus": {
4650
"explorer/context": [
4751
{
4852
"when": "resourceLangId == typescript",
49-
"command": "createTests.create",
53+
"command": "testRunner.create",
5054
"group": "2_workspace"
5155
},
5256
{
5357
"when": "resourceLangId == javascript",
54-
"command": "createTests.create",
58+
"command": "testRunner.create",
5559
"group": "2_workspace"
5660
},
5761
{
5862
"when": "resourceLangId == typescriptreact",
59-
"command": "createTests.create",
63+
"command": "testRunner.create",
6064
"group": "2_workspace"
6165
},
6266
{
6367
"when": "resourceLangId == javascriptreact",
64-
"command": "createTests.create",
68+
"command": "testRunner.create",
69+
"group": "2_workspace"
70+
},
71+
{
72+
"when": "resourceLangId == typescript",
73+
"command": "testRunner.test",
74+
"group": "2_workspace"
75+
},
76+
{
77+
"when": "resourceLangId == javascript",
78+
"command": "testRunner.test",
79+
"group": "2_workspace"
80+
},
81+
{
82+
"when": "resourceLangId == typescriptreact",
83+
"command": "testRunner.test",
84+
"group": "2_workspace"
85+
},
86+
{
87+
"when": "resourceLangId == javascriptreact",
88+
"command": "testRunner.test",
6589
"group": "2_workspace"
6690
},
6791
{
@@ -88,22 +112,42 @@
88112
"editor/title/context": [
89113
{
90114
"when": "resourceLangId == typescript",
91-
"command": "createTests.create",
115+
"command": "testRunner.create",
92116
"group": "2_workspace"
93117
},
94118
{
95119
"when": "resourceLangId == javascript",
96-
"command": "createTests.create",
120+
"command": "testRunner.create",
97121
"group": "2_workspace"
98122
},
99123
{
100124
"when": "resourceLangId == typescriptreact",
101-
"command": "createTests.create",
125+
"command": "testRunner.create",
102126
"group": "2_workspace"
103127
},
104128
{
105129
"when": "resourceLangId == javascriptreact",
106-
"command": "createTests.create",
130+
"command": "testRunner.create",
131+
"group": "2_workspace"
132+
},
133+
{
134+
"when": "resourceLangId == typescript",
135+
"command": "testRunner.test",
136+
"group": "2_workspace"
137+
},
138+
{
139+
"when": "resourceLangId == javascript",
140+
"command": "testRunner.test",
141+
"group": "2_workspace"
142+
},
143+
{
144+
"when": "resourceLangId == typescriptreact",
145+
"command": "testRunner.test",
146+
"group": "2_workspace"
147+
},
148+
{
149+
"when": "resourceLangId == javascriptreact",
150+
"command": "testRunner.test",
107151
"group": "2_workspace"
108152
},
109153
{
@@ -130,22 +174,42 @@
130174
"editor/context": [
131175
{
132176
"when": "resourceLangId == typescript",
133-
"command": "createTests.create",
177+
"command": "testRunner.create",
178+
"group": "2_workspace"
179+
},
180+
{
181+
"when": "resourceLangId == javascript",
182+
"command": "testRunner.create",
183+
"group": "2_workspace"
184+
},
185+
{
186+
"when": "resourceLangId == typescriptreact",
187+
"command": "testRunner.create",
188+
"group": "2_workspace"
189+
},
190+
{
191+
"when": "resourceLangId == javascriptreact",
192+
"command": "testRunner.create",
193+
"group": "2_workspace"
194+
},
195+
{
196+
"when": "resourceLangId == typescript",
197+
"command": "testRunner.test",
134198
"group": "2_workspace"
135199
},
136200
{
137201
"when": "resourceLangId == javascript",
138-
"command": "createTests.create",
202+
"command": "testRunner.test",
139203
"group": "2_workspace"
140204
},
141205
{
142206
"when": "resourceLangId == typescriptreact",
143-
"command": "createTests.create",
207+
"command": "testRunner.test",
144208
"group": "2_workspace"
145209
},
146210
{
147211
"when": "resourceLangId == javascriptreact",
148-
"command": "createTests.create",
212+
"command": "testRunner.test",
149213
"group": "2_workspace"
150214
},
151215
{
@@ -173,7 +237,7 @@
173237
"configuration": {
174238
"title": "Where to keep the test files?",
175239
"properties": {
176-
"createTests.defaultLocationForFiles": {
240+
"testRunner.defaultLocationForFiles": {
177241
"type": "string",
178242
"default": "same location as source file",
179243
"enum": [
@@ -182,47 +246,136 @@
182246
],
183247
"description": "Where to keep the created test files?"
184248
},
185-
"createTests.sourceDir": {
249+
"testRunner.sourceDir": {
186250
"type": "string",
187251
"default": "src",
188252
"description": "Name of directory which contains all source files. This directory is not created when generating the directory structure for the test file."
189253
},
190-
"createTests.directoryName": {
254+
"testRunner.directoryName": {
191255
"type": "string",
192256
"default": "__tests__",
193257
"description": "Name of the test directory."
194258
},
195-
"createTests.customLocationForFiles": {
259+
"testRunner.customLocationForFiles": {
196260
"type": "string",
197261
"description": "Set this property in case you want to specify the custom location for test files."
198262
},
199-
"createTests.filesSuffix": {
263+
"testRunner.filesSuffix": {
200264
"type": "string",
201265
"default": "test",
202266
"description": "Suffix to use for the test files."
203267
},
204-
"createTests.shouldSwitchToFile": {
268+
"testRunner.shouldSwitchToFile": {
205269
"type": "boolean",
206270
"default": true,
207271
"description": "Whether to switch to the test file or not after creating it."
208272
},
209-
"createTests.template.*": {
273+
"testRunner.template.*": {
210274
"type": [
211275
"array",
212276
"object"
213277
],
214278
"description": "Language specific templates that you want to use."
215279
},
216-
"createTests.template.default": {
280+
"testRunner.template.default": {
217281
"type": [
218282
"array",
219283
"object"
220284
],
221285
"default": [
222-
"import {${moduleName}} from '${modulePath}';"
286+
""
223287
],
224288
"description": "Default template to use for all test file"
225289
},
290+
"testRunner.framework": {
291+
"type": "string",
292+
"default": "jest",
293+
"description": "Test framework"
294+
},
295+
"testRunner.useForwardSlash": {
296+
"type": "boolean",
297+
"default": "jest",
298+
"description": "If set to true will make backslash to forward slash, useful for windows and jest."
299+
},
300+
"testRunner.supportedExtension": {
301+
"type": "array",
302+
"items": {
303+
"type": "string"
304+
},
305+
"default": [
306+
"ts",
307+
"tsx",
308+
"js",
309+
"jsx",
310+
"cs"
311+
],
312+
"description": "Test supported Extension"
313+
},
314+
"testRunner.watchCommands": {
315+
"type": "array",
316+
"items": {
317+
"type": "string"
318+
},
319+
"default": [
320+
"--watch",
321+
"dotnet watch"
322+
],
323+
"description": "If file created for the firs time test will not run,unless a watch command detected."
324+
},
325+
"testRunner.tasks": {
326+
"type": "array",
327+
"items": {
328+
"type": "object",
329+
"title": "task",
330+
"properties": {
331+
"label": {
332+
"type": "string",
333+
"description": "Name of task"
334+
},
335+
"args": {
336+
"type": "array",
337+
"items": {
338+
"type": "string",
339+
"title": "task"
340+
},
341+
"description": "Arguments to pass to test"
342+
},
343+
"useForwardSlash": {
344+
"type": "boolean",
345+
"default": true,
346+
"description": "Will convert back slash to forward slash, Required for jest when running in windows"
347+
},
348+
"usePathFromBaseDirectory": {
349+
"type": "boolean",
350+
"default": true,
351+
"description": "When set to true the workspace root path will be removed, Required for jest"
352+
},
353+
"shouldSwitchToFile": {
354+
"type": "boolean",
355+
"default": true,
356+
"description": "Whether to switch to the test file or not."
357+
},
358+
"openInNewTerminal": {
359+
"type": "boolean",
360+
"default": true,
361+
"description": "Will open new terminal for each run."
362+
},
363+
"command": {
364+
"type": "string",
365+
"default": "jest"
366+
},
367+
"default": {
368+
"type": "boolean",
369+
"description": "When unable to detect task, will run task with default set to true"
370+
}
371+
},
372+
"required": [
373+
"label",
374+
"command"
375+
]
376+
},
377+
"description": "Whether to switch to the story file or not after creating it."
378+
},
226379
"createStory.defaultLocationForFiles": {
227380
"type": "string",
228381
"default": "same location as source file",
@@ -292,7 +445,7 @@
292445
"@types/mocha": "^2.2.42",
293446
"@types/node": "^7.0.43",
294447
"tslint": "^5.10.0",
295-
"typescript": "^2.6.1",
448+
"typescript": "^3.8.3",
296449
"vscode": "^1.1.35"
297450
},
298451
"dependencies": {

0 commit comments

Comments
 (0)