Skip to content

Commit 516293d

Browse files
committed
Add command line instructions for JSTS unit testing with vstest.console
1 parent cf78ae7 commit 516293d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docs/javascript/unit-testing-javascript-with-visual-studio.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Unit testing JavaScript and TypeScript"
33
description: Explore unit testing support in Visual Studio for JavaScript and TypeScript code by using the Node.js Tools for Visual Studio.
4-
ms.date: "7/31/2025"
4+
ms.date: "8/6/2025"
55
ms.topic: "how-to"
66
ms.devlang: javascript
77
author: "mikejo5000"
@@ -115,7 +115,7 @@ The following example is based on the TypeScript React project template provided
115115
> For TypeScript, don't use the `outfile` option in *tsconfig.json*, because Test Explorer won't be able to find your unit tests. You can use the `outdir` option, but make sure that configuration files such as `package.json` and `tsconfig.json` are in the project root.
116116
117117
> [!IMPORTANT]
118-
> If the output from **Tests** in the Output window shows a `ReadOnlySpan` error during test discovery, use this workaround for a known [MSBuild issue](https://github.com/dotnet/msbuild/issues/7873). Open the folder, *Program Files\Microsoft Visual Studio\2022\\<version\>\Common7\IDE\Extensions\TestPlatform*, and rename *System.Memory.dll* to a different name. This fix enables test discovery.
118+
> If the output from **Tests** in the Output window shows a `ReadOnlySpan` error during test discovery, use the following workaround for a known [MSBuild issue](https://github.com/dotnet/msbuild/issues/7873). Open the folder, *Program Files\Microsoft Visual Studio\2022\\<version\>\Common7\IDE\Extensions\TestPlatform*, and rename *System.Memory.dll* to a different name. This fix enables test discovery.
119119
120120
### Run tests (.esproj)
121121

@@ -133,6 +133,16 @@ For some unit test frameworks, unit tests are typically run against the generate
133133
> [!NOTE]
134134
> Profiling tests and code coverage aren't currently supported.
135135
136+
## Run unit tests from the command line for a CLI-based project (.esproj)
137+
138+
You can run unit tests directly from the command line for your unit test framework the same way you would if you weren't using Visual Studio.
139+
140+
You may also choose to run the tests from the command line using *vstest.console*. For example, you may want to use vstest.console to maintain consistency with C# unit tests, or to run in Azure DevOps. Use the following command, but replace `MyProj` with your project name.
141+
142+
```
143+
vstest.console .\MyProj.esproj /TestAdapterPath:"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\JavaScript"
144+
```
145+
136146
::: moniker-end
137147

138148
## Write unit tests for ASP.NET Core
@@ -356,7 +366,7 @@ The following example is based on the ASP.NET Core Model-View-Controller project
356366
357367
::: moniker range="vs-2022"
358368
> [!IMPORTANT]
359-
> If the output from **Tests** in the Output window shows a `ReadOnlySpan` error during test discovery, use this workaround for a known [MSBuild issue](https://github.com/dotnet/msbuild/issues/7873). Open the folder, *Program Files\Microsoft Visual Studio\2022\\<version\>\Common7\IDE\Extensions\TestPlatform*, and rename *System.Memory.dll* to a different name. This fix enables test discovery.
369+
> If the output from **Tests** in the Output window shows a `ReadOnlySpan` error during test discovery, use the following workaround for a known [MSBuild issue](https://github.com/dotnet/msbuild/issues/7873). Open the folder, *Program Files\Microsoft Visual Studio\2022\\<version\>\Common7\IDE\Extensions\TestPlatform*, and rename *System.Memory.dll* to a different name. This fix enables test discovery.
360370
::: moniker-end
361371

362372
### Run tests (ASP.NET Core)

0 commit comments

Comments
 (0)