Create a JavaScript project in Visual Studio Code
In Visual Studio Code, on Windows, macOS, and Linux, you can create Jasmine or Mocha testing projects using the installed templates.
Prerequisites
Internet connectivity is required when creating projects.
Create a project
Using the extension GUI
-
Select the Functional Testing for Developers extension in the Activity Bar.
-
Expand the Templates menu.
-
Expand the JavaScript menu.
-
Click the desired template type (Jasmine or Mocha).
-
Enter a name for the new project.
-
Select a project location. By default, Visual Studio Code suggests the user's Documents folder if there is no open workspace. Otherwise, it suggests the open workspace.
Using the Command Palette
-
Open the Command Palette (Ctrl + Shift + P).
-
Type >FTD: Create JavaScript Project.
-
Select the JavaScript project type (Jasmine or Mocha).
-
Enter a name for the new project.
-
Select a project location. By default, Visual Studio Code suggests the user's Documents folder if there is no open workspace. Otherwise, it suggests the open workspace.
Visual Studio Code template content
The Jasmine/Mocha FTD project templates include the following:
- package.json, which contains your project's settings, including the references to the LeanFT SDK and the @hpe/leanft-mocha-runner / @hpe/leanft-jasmine-runner, and the script for launching tests.
- Node_modules folder, which contains the LeanFT SDK, testing framework, and the LeanFT SDK runner module. (npm installs this automatically.)
-
A basic ftdtest file template where you write your code.
You can include multiple tests in one file, and you can use the Object Identification Center or Test Recorder to help generate the code.
The exact structure of this template depends on whether you are using Jasmine or Mocha:
- In a Mocha project, test files are saved with the .js extension. You can save test files in any folder under your project.
- In a Jasmine project, test files are saved with the -spec.js extension and must be placed in the spec or test folder.
The template includes initialization hooks that control what happens during the different phases of your run:
- In Mocha projects, a before hook initializes the SDK engine and an after hook cleans up after execution completes.
- In Jasmine projects, a beforeAll function initializes the SDK engine and an afterAll function cleans up after execution completes.
- jsconfig.json - Optionally, you can create this file to customize test settings and enable IntelliSense support for LeanFT SDK JavaScript test objects and methods. For details, see Customize test settings.
- For details on using the Mocha framework, see the Mocha documentation.
- For details on using the Jasmine framework, see the Jasmine documentation.
Next steps:

