.vscode-test.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. //@ts-check
  6. const path = require('path');
  7. const { defineConfig } = require('@vscode/test-cli');
  8. const os = require('os');
  9. /**
  10. * A list of extension folders who have opted into tests, or configuration objects.
  11. * Edit me to add more!
  12. *
  13. * @type {Array<string | (Partial<import("@vscode/test-cli").TestConfiguration> & { label: string })>}
  14. */
  15. const extensions = [
  16. {
  17. label: 'markdown-language-features',
  18. workspaceFolder: `extensions/markdown-language-features/test-workspace`,
  19. mocha: { timeout: 60_000 }
  20. },
  21. {
  22. label: 'ipynb',
  23. workspaceFolder: path.join(os.tmpdir(), `ipynb-${Math.floor(Math.random() * 100000)}`),
  24. mocha: { timeout: 60_000 }
  25. },
  26. {
  27. label: 'notebook-renderers',
  28. workspaceFolder: path.join(os.tmpdir(), `nbout-${Math.floor(Math.random() * 100000)}`),
  29. mocha: { timeout: 60_000 }
  30. },
  31. {
  32. label: 'vscode-colorize-tests',
  33. workspaceFolder: `extensions/vscode-colorize-tests/test`,
  34. mocha: { timeout: 60_000 }
  35. },
  36. {
  37. label: 'configuration-editing',
  38. workspaceFolder: path.join(os.tmpdir(), `confeditout-${Math.floor(Math.random() * 100000)}`),
  39. mocha: { timeout: 60_000 }
  40. },
  41. {
  42. label: 'github-authentication',
  43. workspaceFolder: path.join(os.tmpdir(), `msft-auth-${Math.floor(Math.random() * 100000)}`),
  44. mocha: { timeout: 60_000 }
  45. }
  46. ];
  47. const defaultLaunchArgs = process.env.API_TESTS_EXTRA_ARGS?.split(' ') || [
  48. '--disable-telemetry', '--skip-welcome', '--skip-release-notes', `--crash-reporter-directory=${__dirname}/.build/crashes`, `--logsPath=${__dirname}/.build/logs/integration-tests`, '--no-cached-data', '--disable-updates', '--use-inmemory-secretstorage', '--disable-extensions', '--disable-workspace-trust'
  49. ];
  50. module.exports = defineConfig(extensions.map(extension => {
  51. /** @type {import('@vscode/test-cli').TestConfiguration} */
  52. const config = typeof extension === 'object'
  53. ? { files: `extensions/${extension.label}/out/**/*.test.js`, ...extension }
  54. : { files: `extensions/${extension}/out/**/*.test.js`, label: extension };
  55. config.mocha ??= {};
  56. if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) {
  57. let suite = '';
  58. if (process.env.VSCODE_BROWSER) {
  59. suite = `${process.env.VSCODE_BROWSER} Browser Integration ${config.label} tests`;
  60. } else if (process.env.REMOTE_VSCODE) {
  61. suite = `Remote Integration ${config.label} tests`;
  62. } else {
  63. suite = `Integration ${config.label} tests`;
  64. }
  65. config.mocha.reporter = 'mocha-multi-reporters';
  66. config.mocha.reporterOptions = {
  67. reporterEnabled: 'spec, mocha-junit-reporter',
  68. mochaJunitReporterReporterOptions: {
  69. testsuitesTitle: `${suite} ${process.platform}`,
  70. mochaFile: path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${process.arch}-${suite.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`)
  71. }
  72. };
  73. }
  74. if (!config.platform || config.platform === 'desktop') {
  75. config.launchArgs = defaultLaunchArgs;
  76. config.useInstallation = {
  77. fromPath: process.env.INTEGRATION_TEST_ELECTRON_PATH || `${__dirname}/scripts/code.${process.platform === 'win32' ? 'bat' : 'sh'}`,
  78. };
  79. config.env = {
  80. ...config.env,
  81. VSCODE_SKIP_PRELAUNCH: '1',
  82. };
  83. } else {
  84. // web configs not supported, yet
  85. }
  86. return config;
  87. }));