|
1 | 1 | ---
|
2 | 2 | title: "Unit testing JavaScript and TypeScript"
|
3 | 3 | 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: "12/06/2024" |
| 4 | +ms.date: "7/31/2025" |
5 | 5 | ms.topic: "how-to"
|
6 | 6 | ms.devlang: javascript
|
7 | 7 | author: "mikejo5000"
|
@@ -107,6 +107,11 @@ The following example is based on the TypeScript React project template provided
|
107 | 107 | });
|
108 | 108 | ```
|
109 | 109 |
|
| 110 | + ::: moniker range="vs-2022" |
| 111 | + > [!IMPORTANT] |
| 112 | + > Due to 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. |
| 113 | + ::: moniker-end |
| 114 | + |
110 | 115 | 1. Open Test Explorer (choose **Test** > **Test Explorer**) and Visual Studio discovers and displays tests. If tests are not showing initially, then rebuild the project to refresh the list.
|
111 | 116 |
|
112 | 117 | 
|
@@ -148,9 +153,16 @@ The following example is based on the ASP.NET Core Model-View-Controller project
|
148 | 153 |
|
149 | 154 | 1. In the **Browse** tab, search for the following packages and install each one:
|
150 | 155 |
|
| 156 | + ::: moniker range=">=vs-2022" |
| 157 | + - [Microsoft.TypeScript.MSBuild](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild) |
| 158 | + - [Npm](https://www.nuget.org/packages/Npm) |
| 159 | + ::: moniker-end |
| 160 | + |
| 161 | + ::: moniker range="vs-2019" |
151 | 162 | - [Microsoft.TypeScript.MSBuild](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
|
152 | 163 | - [Npm](https://www.nuget.org/packages/Npm)
|
153 | 164 | - [Microsoft.JavaScript.UnitTest](https://www.nuget.org/packages/Microsoft.JavaScript.UnitTest/)
|
| 165 | + ::: moniker-end |
154 | 166 |
|
155 | 167 | Use the NuGet package to add TypeScript support instead of the npm TypeScript package.
|
156 | 168 |
|
@@ -337,6 +349,11 @@ The following example is based on the ASP.NET Core Model-View-Controller project
|
337 | 349 | })
|
338 | 350 | ```
|
339 | 351 |
|
| 352 | + ::: moniker range="vs-2022" |
| 353 | + > [!IMPORTANT] |
| 354 | + > Due to 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. |
| 355 | + ::: moniker-end |
| 356 | + |
340 | 357 | 1. Open Test Explorer (choose **Test** > **Windows** > **Test Explorer**) and Visual Studio discovers and displays tests. If tests are not showing initially, then rebuild the project to refresh the list. The following illustration shows the Jest example, with two different unit test files.
|
341 | 358 |
|
342 | 359 | 
|
|
0 commit comments