diff --git a/.github/workflows/insiders.yml b/.github/workflows/insiders.yml index 0c22f7b44..3c618e8ca 100644 --- a/.github/workflows/insiders.yml +++ b/.github/workflows/insiders.yml @@ -21,6 +21,7 @@ jobs: env: CODE_TYPE: insider + TEST_RESOURCES: test-resources steps: - name: Checkout Repository diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1e02848b1..bb1578f09 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,7 @@ jobs: env: CODE_VERSION: ${{ matrix.version }} + TEST_RESOURCES: test-resources steps: - name: Checkout Repository diff --git a/.gitignore b/.gitignore index 243307177..8d7358218 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ out node_modules -test-resources ./.vscode docs resources/api-handler.vsix diff --git a/src/browser.ts b/src/browser.ts index c2056c95d..1b6581205 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -7,6 +7,7 @@ import { WebDriver, Builder, until, initPageObjects, logging, By } from 'monaco- import { Options, ServiceBuilder } from 'selenium-webdriver/chrome'; import { getLocatorsPath } from 'vscode-extension-tester-locators'; import { CodeUtil, ReleaseQuality } from './util/codeUtil'; +import { DEFAULT_STORAGE_FOLDER } from './extester'; export class VSBrowser { static readonly baseVersion = '1.37.0'; @@ -21,7 +22,7 @@ export class VSBrowser { private static _instance: VSBrowser; constructor(codeVersion: string, releaseType: ReleaseQuality, customSettings: Object = {}, logLevel: logging.Level = logging.Level.INFO) { - this.storagePath = process.env.TEST_RESOURCES ? process.env.TEST_RESOURCES : path.resolve('test-resources'); + this.storagePath = process.env.TEST_RESOURCES ? process.env.TEST_RESOURCES : path.resolve(DEFAULT_STORAGE_FOLDER); this.extensionsFolder = process.env.EXTENSIONS_FOLDER ? process.env.EXTENSIONS_FOLDER : undefined; this.customSettings = customSettings; this.codeVersion = codeVersion; diff --git a/src/extester.ts b/src/extester.ts index 593787f23..c1cac2018 100644 --- a/src/extester.ts +++ b/src/extester.ts @@ -4,6 +4,7 @@ import { CodeUtil, DEFAULT_RUN_OPTIONS, ReleaseQuality, RunOptions } from './uti import { DriverUtil } from './util/driverUtil'; import * as fs from 'fs-extra'; import * as path from 'path'; +import * as os from 'os'; import { URL } from 'url'; export { ReleaseQuality } @@ -26,6 +27,8 @@ export const DEFAULT_SETUP_OPTIONS = { installDependencies: false } +export const DEFAULT_STORAGE_FOLDER = process.env.TEST_RESOURCES ? process.env.TEST_RESOURCES : path.join(os.tmpdir(), 'test-resources'); + export const VSCODE_VERSION_MIN = '1.81.1'; export const VSCODE_VERSION_MAX = '1.83.1'; @@ -42,7 +45,7 @@ export class ExTester { private code: CodeUtil; private chrome: DriverUtil; - constructor(storageFolder: string = 'test-resources', releaseType: ReleaseQuality = ReleaseQuality.Stable, extensionsDir?: string) { + constructor(storageFolder: string = DEFAULT_STORAGE_FOLDER, releaseType: ReleaseQuality = ReleaseQuality.Stable, extensionsDir?: string) { this.code = new CodeUtil(storageFolder, releaseType, extensionsDir); this.chrome = new DriverUtil(storageFolder); diff --git a/src/util/codeUtil.ts b/src/util/codeUtil.ts index 49a6fb282..83d78c180 100644 --- a/src/util/codeUtil.ts +++ b/src/util/codeUtil.ts @@ -8,6 +8,7 @@ import { VSRunner } from "../suite/runner"; import { Unpack } from "./unpack"; import { logging } from "selenium-webdriver"; import { Download } from './download'; +import { DEFAULT_STORAGE_FOLDER } from '../extester'; export enum ReleaseQuality { Stable = 'stable', @@ -60,7 +61,7 @@ export class CodeUtil { * @param folder Path to folder where all the artifacts will be stored. * @param extensionsFolder Path to use as extensions directory by VSCode */ - constructor(folder: string = 'test-resources', type: ReleaseQuality = ReleaseQuality.Stable, extensionsFolder?: string) { + constructor(folder: string = DEFAULT_STORAGE_FOLDER, type: ReleaseQuality = ReleaseQuality.Stable, extensionsFolder?: string) { this.availableVersions = []; this.downloadPlatform = this.getPlatform(); this.downloadFolder = path.resolve(folder); diff --git a/src/util/driverUtil.ts b/src/util/driverUtil.ts index b6d2ce12c..67873a15b 100644 --- a/src/util/driverUtil.ts +++ b/src/util/driverUtil.ts @@ -5,6 +5,7 @@ import * as path from 'path'; import * as child_process from 'child_process'; import { Unpack } from './unpack'; import { Download } from './download'; +import { DEFAULT_STORAGE_FOLDER } from '../extester'; /** * Handles version checks and download of ChromeDriver @@ -16,7 +17,7 @@ export class DriverUtil { * Create an instance of chrome driver handler * @param folder path to a folder to store all artifacts */ - constructor(folder: string = 'test-resources') { + constructor(folder: string = DEFAULT_STORAGE_FOLDER) { this.downloadFolder = path.resolve(folder); } diff --git a/wiki/Taking Screenshots.md b/wiki/Taking Screenshots.md index 834d80f4f..507dc1981 100644 --- a/wiki/Taking Screenshots.md +++ b/wiki/Taking Screenshots.md @@ -5,7 +5,7 @@ Screenshot can be captured by calling: VSBrowser.instance.takeScreenshot(basename: string) ``` -Captured screenshots will be saved in *screenshots* folder which can be found in *test-resources* folder. +Captured screenshots will be saved in *screenshots* folder which can be found in a test storage folder (`$TMPDIR/test-resources` by default). File name will be generated from given basename in the following format: `${basename}.png`. #### Mocha integration diff --git a/wiki/Test-Setup.md b/wiki/Test-Setup.md index 409bc4198..078310cd5 100644 --- a/wiki/Test-Setup.md +++ b/wiki/Test-Setup.md @@ -1,7 +1,7 @@ The Extension Tester offers both CLI and API to perform all the setup actions. That way you can simply integrate it into your npm scripts, or just call it from your code if that is more preferable. ## Using the CLI -All the CLI actions are available with the command ```extest``` which is available to your npm scripts once the package is installed. The default storage folder for all test resources is ```test-resources``` in the extension's root. To avoid build problems, make sure to exclude it from your ```tsconfig``` and ```vsce```. +All the CLI actions are available with the command ```extest``` which is available to your npm scripts once the package is installed. The default storage folder for all test resources is a ```$TMPDIR/test-resources```. #### Download VS Code If you wish to manually download VS Code of a given version