config.d.cts 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import { ProgressReporter } from '@vscode/test-electron';
  2. export interface IBaseTestConfiguration {
  3. /**
  4. * A file or list of files in which to find tests. Non-absolute paths will
  5. * be treated as glob expressions relative to the location of
  6. * the `.vscode-test.js` file.
  7. */
  8. files: string | readonly string[];
  9. /**
  10. * Version to download and install. This may be:
  11. * - A quality, like `stable` or `insiders`
  12. * - A version number, like `1.82.0`
  13. * - A commit hash of a version to install
  14. *
  15. * Defaults to `stable`, which is latest stable version.
  16. */
  17. version?: 'insiders' | 'stable' | string;
  18. /**
  19. * Defines extension directories to load during tests. Defaults to the directory
  20. * of the `.vscode-test.js` file. Must include a `package.json` Extension Manifest.
  21. */
  22. extensionDevelopmentPath?: string | readonly string[];
  23. /**
  24. * Path to a folder or workspace file that should be opened.
  25. */
  26. workspaceFolder?: string;
  27. /**
  28. * Additional options to pass to the Mocha runner. Any options given on the
  29. * command line will be merged into and override these defaults.
  30. * @see https://mochajs.org/api/mocha
  31. */
  32. mocha?: Mocha.MochaOptions & {
  33. /**
  34. * Specify file(s) to be loaded prior to root suite.
  35. * @deprecated use `require` instead
  36. */
  37. preload?: string | string[];
  38. /**
  39. * Path to a reporter to use.
  40. * @see https://mochajs.org/api/tutorial-custom-reporter
  41. */
  42. reporter?: string | undefined;
  43. };
  44. /**
  45. * Optional label for this configuration, which can be used to specify which
  46. * configuration to run if multiple configurations are provided.
  47. */
  48. label?: string;
  49. /**
  50. * Sources directory relative to the `extensionDevelopmentPath`. Currently
  51. * this is used to report coverage. Defaults to "src" if not specified.
  52. */
  53. srcDir?: string;
  54. }
  55. export interface IDesktopTestConfiguration extends IBaseTestConfiguration {
  56. /**
  57. * Platform to use for running the tests.
  58. */
  59. platform?: 'desktop';
  60. /**
  61. * The VS Code desktop platform to download. If not specified, it defaults
  62. * to the current platform.
  63. *
  64. * Possible values are:
  65. * - `win32-archive`
  66. * - `win32-x64-archive`
  67. * - `win32-arm64-archive `
  68. * - `darwin`
  69. * - `darwin-arm64`
  70. * - `linux-x64`
  71. * - `linux-arm64`
  72. * - `linux-armhf`
  73. */
  74. desktopPlatform?: string;
  75. /**
  76. * A list of launch arguments passed to VS Code executable, in addition to `--extensionDevelopmentPath`
  77. * and `--extensionTestsPath` which are provided by `extensionDevelopmentPath` and `extensionTestsPath`
  78. * options.
  79. *
  80. * If the first argument is a path to a file/folder/workspace, the launched VS Code instance
  81. * will open it.
  82. *
  83. * See `code --help` for possible arguments.
  84. */
  85. launchArgs?: string[];
  86. /**
  87. * Environment variables to set when running the test.
  88. */
  89. env?: Record<string, string | undefined>;
  90. /**
  91. * Configures a specific VS Code installation to use instead of automatically
  92. * downloading the {@link version}
  93. */
  94. useInstallation?: {
  95. /**
  96. * Whether VS Code should be launched using default settings and extensions
  97. * installed on this machine. If `false`, then separate directories will be
  98. * used inside the `.vscode-test` folder within the project.
  99. *
  100. * Defaults to `false`.
  101. */
  102. fromMachine: boolean;
  103. } | {
  104. /**
  105. * The VS Code executable path used for testing.
  106. *
  107. * If not passed, will use `options.version` to download a copy of VS Code for testing.
  108. * If `version` is not specified either, will download and use latest stable release.
  109. */
  110. fromPath?: string;
  111. };
  112. download?: {
  113. /**
  114. * Progress reporter to use while VS Code is downloaded. Defaults to a
  115. * console reporter. A {@link SilentReporter} is also available, and you
  116. * may implement your own.
  117. */
  118. reporter: ProgressReporter;
  119. /**
  120. * Number of milliseconds after which to time out if no data is received from
  121. * the remote when downloading VS Code. Note that this is an 'idle' timeout
  122. * and does not enforce the total time VS Code may take to download.
  123. */
  124. timeout?: number;
  125. };
  126. /**
  127. * A list of vscode extensions to install prior to running the tests.
  128. * Can be specified as 'owner.extension', 'owner.extension@2.3.15',
  129. * 'owner.extension@prerelease', or the path to a vsix file (/path/to/extension.vsix)
  130. */
  131. installExtensions?: string[];
  132. /**
  133. * Skips the automatic installation of extensionDependencies from the
  134. * extension's package.json.
  135. */
  136. skipExtensionDependencies?: boolean;
  137. }
  138. /**
  139. * Configuration that runs in browsers.
  140. * @todo: this is incomplete, and does not yet function
  141. */
  142. export interface IWebTestConfiguration extends IBaseTestConfiguration {
  143. platform: 'firefox' | 'webkit' | 'chromium';
  144. }
  145. export type TestConfiguration = IDesktopTestConfiguration | IWebTestConfiguration;
  146. export interface ICoverageConfiguration {
  147. /**
  148. * List of files/folders/globs to exclude from coverage. By default, excludes
  149. * common test and dependency files.
  150. */
  151. exclude?: string[];
  152. /**
  153. * List of files/folders/globs to include in coverage. By default, excludes
  154. * common test and dependency files.
  155. */
  156. include?: string | string[];
  157. /**
  158. * One or more reporters to use, either an array or an object of options.
  159. * Defaults to `['html']`.
  160. */
  161. reporter?: string[] | Record<string, Record<string, unknown>>;
  162. /**
  163. * By default, coverage will only include files that were imported at runtime
  164. * in your extension. You can pass `true` here to include all files in the
  165. * source directories instead. See {@link IBaseTestConfiguration.srcDir} to
  166. * configure the source directories.
  167. *
  168. * `include` and `exclude` patterns are still respected.
  169. */
  170. includeAll?: boolean;
  171. /**
  172. * Directory where coverage reports are written, defaults to `./coverage`
  173. */
  174. output?: string;
  175. }
  176. export interface IConfigurationWithGlobalOptions {
  177. /**
  178. * Test configurations to run.
  179. */
  180. tests: TestConfiguration[];
  181. /**
  182. * Configuration used for handling coverage.
  183. */
  184. coverage?: ICoverageConfiguration;
  185. }