vscode-test/README.md

135 строки
3.5 KiB
Markdown
Исходник Обычный вид История

2019-05-24 03:00:27 +03:00
<p>
<h1 align="center">vscode-test</h1>
</p>
<p align="center">
<a href="https://dev.azure.com/vscode/VSCode/_build?definitionId=14">
<img src="https://img.shields.io/azure-devops/build/vscode/a4cdce18-a05c-4bb8-9476-5d07e63bfd76/14.svg?label=Azure%20DevOps&logo=Azure%20Devops&style=flat-square">
</a>
</p>
2019-03-14 21:33:54 +03:00
2019-03-20 08:20:11 +03:00
This module helps you test VS Code extensions.
2019-03-14 21:33:54 +03:00
Supported:
2019-05-23 21:17:22 +03:00
- Node >= 8.x
2019-05-24 11:41:00 +03:00
- Windows >= Windows Server 2012+ / Win10+ (anything with Powershell >= 5.0)
- macOS
- Linux
2019-03-14 21:33:54 +03:00
## Usage
2019-05-24 03:00:27 +03:00
See [./sample](./sample) for a runnable sample, with [Azure Devops Pipelines](https://github.com/microsoft/vscode-test/blob/master/azure-pipelines.yml) configuration.
2019-03-14 21:44:45 +03:00
2019-03-14 21:33:54 +03:00
```ts
import * as path from 'path'
2019-03-20 08:20:11 +03:00
import { runTests, downloadAndUnzipVSCode } from 'vscode-test'
2019-03-14 21:33:54 +03:00
async function go() {
const extensionPath = path.resolve(__dirname, '../../')
const testRunnerPath = path.resolve(__dirname, './suite')
const testWorkspace = path.resolve(__dirname, '../../test-fixtures/fixture1')
2019-03-14 21:44:45 +03:00
/**
* Basic usage
*/
2019-03-14 21:33:54 +03:00
await runTests({
extensionPath,
testRunnerPath,
testWorkspace
})
2019-03-14 21:44:45 +03:00
2019-03-20 08:20:11 +03:00
const testRunnerPath2 = path.resolve(__dirname, './suite2')
const testWorkspace2 = path.resolve(__dirname, '../../test-fixtures/fixture2')
/**
* Running a second test suite
*/
await runTests({
extensionPath,
testRunnerPath: testRunnerPath2,
testWorkspace: testWorkspace2
})
/**
* Use 1.31.0 release for testing
*/
await runTests({
version: '1.31.0',
extensionPath,
testRunnerPath,
testWorkspace
})
2019-04-17 23:32:38 +03:00
/**
* Use Insiders release for testing
*/
await runTests({
version: 'insiders',
extensionPath,
testRunnerPath,
testWorkspace
})
2019-03-20 08:20:11 +03:00
/**
* Manually download VS Code 1.30.0 release for testing.
*/
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.30.0')
await runTests({
vscodeExecutablePath,
extensionPath,
testRunnerPath,
testWorkspace
})
2019-04-13 22:36:15 +03:00
/**
2019-04-18 20:10:36 +03:00
* - Add additional launch flags for VS Code
* - Pass custom environment variables to test runner
2019-04-13 22:36:15 +03:00
*/
await runTests({
vscodeExecutablePath,
extensionPath,
testRunnerPath,
testWorkspace,
2019-05-24 01:25:33 +03:00
// This disables all extensions except the one being tested
2019-04-18 20:10:36 +03:00
additionalLaunchArgs: ['--disable-extensions'],
// Custom environment variables for test runner
testRunnerEnv: { foo: 'bar' }
2019-04-13 22:36:15 +03:00
})
/**
* Manually specify all launch flags for VS Code
*/
await runTests({
vscodeExecutablePath,
launchArgs: [
testWorkspace,
`--extensionDevelopmentPath=${extensionPath}`,
`--extensionTestsPath=${testRunnerPath}`
]
})
2019-03-14 21:33:54 +03:00
}
go()
```
## License
[MIT](LICENSE)
## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.