You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/javascript/unit-testing-javascript-with-visual-studio.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,13 +33,13 @@ The supported frameworks are:
33
33
::: moniker-end
34
34
35
35
::: moniker range="<=vs-2019"
36
-
If your favorite framework is not supported, see [Add support for a unit test framework](#addingFramework) for information on adding support.
36
+
If your favorite framework isn't supported, see [Add support for a unit test framework](#addingFramework) for information on adding support.
37
37
::: moniker-end
38
38
39
39
::: moniker range=">=vs-2022"
40
40
## Write unit tests for a CLI-based project (.esproj)
41
41
42
-
The [CLI-based projects](../javascript/javascript-in-vs-2022.md#project-templates) supported in Visual Studio 2022 work with Test Explorer. Vitest is the built-in test framework for React and Vue projects (previously Jest), and Karma and Jasmine is used for Angular projects. By default, you will be able to run the default tests provided by each framework, as well as any additional tests you write. Just hit the **Run** button in Test Explorer. If you don’t already have Test Explorer open, you can find it by selecting **Test** > **Test Explorer** in the menu bar.
42
+
The [CLI-based projects](../javascript/javascript-in-vs-2022.md#project-templates) supported in Visual Studio 2022 work with Test Explorer. Vitest is the built-in test framework for React and Vue projects (previously Jest), and Karma and Jasmine is used for Angular projects. By default, you'll be able to run the default tests provided by each framework, as well as any additional tests you write. Just hit the **Run** button in Test Explorer. If you don’t already have Test Explorer open, you can find it by selecting **Test** > **Test Explorer** in the menu bar.
43
43
44
44
To run unit tests from the command-line, right-click the project in Solution Explorer, choose **Open in Terminal**, and run the command specific to the test type.
45
45
@@ -107,12 +107,12 @@ The following example is based on the TypeScript React project template provided
107
107
});
108
108
```
109
109
110
-
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.
110
+
1. Open Test Explorer (choose **Test** > **Test Explorer**) and Visual Studio discovers and displays tests. If tests aren't showing initially, then rebuild the project to refresh the list.
111
111
112
112

113
113
114
114
> [!NOTE]
115
-
> For TypeScript, do not 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.
115
+
> 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.
116
116
117
117
> [!IMPORTANT]
118
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.
@@ -131,7 +131,7 @@ For some unit test frameworks, unit tests are typically run against the generate
131
131
> In most TypeScript scenarios, you can debug a unit test by setting a breakpoint in TypeScript code, right-clicking a test in Test Explorer, and choosing **Debug**. In more complex scenarios, such as some scenarios that use source maps, you may have difficulty hitting breakpoints in TypeScript code. As a workaround, try using the `debugger` keyword.
132
132
133
133
> [!NOTE]
134
-
> Profiling tests and code coverage are not currently supported.
134
+
> Profiling tests and code coverage aren't currently supported.
135
135
136
136
::: moniker-end
137
137
@@ -347,12 +347,12 @@ The following example is based on the ASP.NET Core Model-View-Controller project
347
347
})
348
348
```
349
349
350
-
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.
350
+
1. Open Test Explorer (choose **Test** > **Windows** > **Test Explorer**) and Visual Studio discovers and displays tests. If tests aren't showing initially, then rebuild the project to refresh the list. The following illustration shows the Jest example, with two different unit test files.
351
351
352
352

353
353
354
354
> [!NOTE]
355
-
> For TypeScript, do not 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.
355
+
> 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.
356
356
357
357
::: moniker range="vs-2022"
358
358
> [!IMPORTANT]
@@ -373,7 +373,7 @@ For some unit test frameworks, unit tests are typically run against the generate
373
373
> In most TypeScript scenarios, you can debug a unit test by setting a breakpoint in TypeScript code, right-clicking a test in Test Explorer, and choosing **Debug**. In more complex scenarios, such as some scenarios that use source maps, you may have difficulty hitting breakpoints in TypeScript code. As a workaround, try using the `debugger` keyword.
374
374
375
375
> [!NOTE]
376
-
> Profiling tests and code coverage are not currently supported.
376
+
> Profiling tests and code coverage aren't currently supported.
377
377
378
378
::: moniker range="<=vs-2019"
379
379
## <aname="addingFramework"></a>Add support for a unit test framework
@@ -402,7 +402,7 @@ Discovery of available test frameworks occurs at Visual Studio start. If a frame
402
402
403
403
## Unit tests in .NET Framework
404
404
405
-
You are not limited to writing unit tests in just your Node.js and ASP.NET Core projects. When you add the TestFramework and TestRoot properties to any C# or Visual Basic project, those tests will be enumerated and you can run them using the Test Explorer window.
405
+
You aren't limited to writing unit tests in just your Node.js and ASP.NET Core projects. When you add the TestFramework and TestRoot properties to any C# or Visual Basic project, those tests will be enumerated and you can run them using the Test Explorer window.
406
406
407
407
To enable this, right-click the project node in the Solution Explorer, choose **Unload Project**, and then choose **Edit Project**. Then in the project file, add the following two elements to a property group.
408
408
@@ -470,12 +470,12 @@ property in the **Properties** window is set to the correct test framework for y
470
470
> [!NOTE]
471
471
> The unit test options will take preference over the settings for individual files.
472
472
473
-
After opening Test Explorer (choose **Test** > **Windows** > **Test Explorer**), Visual Studio discovers and displays tests. If tests are not showing initially, then rebuild the project to refresh the list.
473
+
After opening Test Explorer (choose **Test** > **Windows** > **Test Explorer**), Visual Studio discovers and displays tests. If tests aren't showing initially, then rebuild the project to refresh the list.
474
474
475
475

476
476
477
477
> [!NOTE]
478
-
> For TypeScript, do not use the `outdir` or `outfile` option in *tsconfig.json*, because Test Explorer won't be able to find your unit tests.
478
+
> For TypeScript, don't use the `outdir` or `outfile` option in *tsconfig.json*, because Test Explorer won't be able to find your unit tests.
0 commit comments