Skip to content

Commit bcddb46

Browse files
authored
Merge pull request #6837 from Mikejo5000/mikejo-br17
TypeScript unit testing updates
2 parents f9e44f5 + 20c7d51 commit bcddb46

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

docs/javascript/TOC.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
href: nodejs-interactive-repl.md
3939
- name: JavaScript IntelliSense
4040
href: /visualstudio/ide/javascript-intellisense?toc=/visualstudio/javascript/toc.json
41-
- name: Debug a JavaScript application
41+
- name: Debug
4242
href: debug-nodejs.md
43-
- name: Unit testing JavaScript
43+
- name: Unit testing
4444
href: unit-testing-javascript-with-visual-studio.md
4545
- name: Resources
4646
items:

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Unit testing JavaScript and TypeScript"
33
description: Visual Studio provides support unit testing JavaScript and TypeScript code using the Node.js Tools for Visual Studio
4-
ms.date: "06/06/2018"
4+
ms.date: "07/06/2020"
55
ms.topic: "how-to"
66
ms.devlang: javascript
77
author: "mikejo5000"
@@ -72,26 +72,32 @@ After opening Test Explorer (choose **Test** > **Windows** > **Test Explorer**),
7272
![Test Explorer](../javascript/media/UnitTestsDiscoveryMocha.png)
7373

7474
> [!NOTE]
75-
> Do not use the `outdir` or `outfile` option in *tsconfig.json*, because Test Explorer won't be able to find your unit tests in TypeScript files.
75+
> 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.
7676
7777
## Run tests
7878

79-
You can run tests in Visual Studio 2017 or from the command line.
79+
You can run tests in Visual Studio or from the command line.
8080

81-
### Run tests in Visual Studio 2017
81+
### Run tests in Visual Studio
8282

83+
::: moniker range=">=vs-2019"
84+
You can run the tests by clicking the **Run All** link in Test Explorer. Or, you can run tests by selecting one or more tests or groups, right-clicking, and selecting **Run** from the shortcut menu. Tests run in the background, and Test Explorer automatically updates and shows the results. Furthermore, you can also debug selected tests by right-clicking and selecting **Debug**.
85+
::: moniker-end
86+
::: moniker range="vs-2017"
8387
You can run the tests by clicking the **Run All** link in Test Explorer. Or, you can run tests by selecting one or more tests or groups, right-clicking, and selecting **Run Selected Tests** from the shortcut menu. Tests run in the background, and Test Explorer automatically updates and shows the results. Furthermore, you can also debug selected tests by selecting **Debug Selected Tests**.
88+
::: moniker-end
8489

85-
> [!Warning]
86-
> Debugging unit tests using Node 8+ currently only works for JavaScript test files,
87-
> TypeScript test files will fail to hit breakpoints. As a workaround use the `debugger` keyword.
90+
For TypeScript, unit tests are run against the generated JavaScript code.
91+
92+
> [!NOTE]
93+
> 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.
8894
8995
> [!NOTE]
9096
> We don't currently support profiling tests, or code coverage.
9197
9298
### Run tests from the command line
9399

94-
You can run the tests from the [Developer Command Prompt](/dotnet/framework/tools/developer-command-prompt-for-vs) for Visual Studio 2017 using the following command:
100+
You can run the tests from the [Developer Command Prompt](/dotnet/framework/tools/developer-command-prompt-for-vs) for Visual Studio using the following command:
95101

96102
```
97103
vstest.console.exe <path to project file>\NodejsConsoleApp23.njsproj /TestAdapterPath:<VisualStudioFolder>\Common7\IDE\Extensions\Microsoft\NodeJsTools\TestAdapter

0 commit comments

Comments
 (0)