runTest.d.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { DownloadOptions } from './download';
  2. export interface TestOptions extends Partial<DownloadOptions> {
  3. /**
  4. * The VS Code executable path used for testing.
  5. *
  6. * If not passed, will use `options.version` to download a copy of VS Code for testing.
  7. * If `version` is not specified either, will download and use latest stable release.
  8. */
  9. vscodeExecutablePath?: string;
  10. /**
  11. * Whether VS Code should be launched using default settings and extensions
  12. * installed on this machine. If `false`, then separate directories will be
  13. * used inside the `.vscode-test` folder within the project.
  14. *
  15. * Defaults to `false`.
  16. */
  17. reuseMachineInstall?: boolean;
  18. /**
  19. * Absolute path to the extension root. Passed to `--extensionDevelopmentPath`.
  20. * Must include a `package.json` Extension Manifest.
  21. */
  22. extensionDevelopmentPath: string | string[];
  23. /**
  24. * Absolute path to the extension tests runner. Passed to `--extensionTestsPath`.
  25. * Can be either a file path or a directory path that contains an `index.js`.
  26. * Must export a `run` function of the following signature:
  27. *
  28. * ```ts
  29. * function run(): Promise<void>;
  30. * ```
  31. *
  32. * When running the extension test, the Extension Development Host will call this function
  33. * that runs the test suite. This function should throws an error if any test fails.
  34. *
  35. * The first argument is the path to the file specified in `extensionTestsPath`.
  36. *
  37. */
  38. extensionTestsPath: string;
  39. /**
  40. * Environment variables being passed to the extension test script.
  41. */
  42. extensionTestsEnv?: {
  43. [key: string]: string | undefined;
  44. };
  45. /**
  46. * A list of launch arguments passed to VS Code executable, in addition to `--extensionDevelopmentPath`
  47. * and `--extensionTestsPath` which are provided by `extensionDevelopmentPath` and `extensionTestsPath`
  48. * options.
  49. *
  50. * If the first argument is a path to a file/folder/workspace, the launched VS Code instance
  51. * will open it.
  52. *
  53. * See `code --help` for possible arguments.
  54. */
  55. launchArgs?: string[];
  56. }
  57. /**
  58. * Run VS Code extension test
  59. *
  60. * @returns The exit code of the command to launch VS Code extension test
  61. */
  62. export declare function runTests(options: TestOptions): Promise<number>;
  63. export declare class TestRunFailedError extends Error {
  64. readonly code: number | undefined;
  65. readonly signal: string | undefined;
  66. constructor(code: number | undefined, signal: string | undefined);
  67. }