Template Assistant
Template Assistant is a Visual Studio Code extension designed to streamline your workflow by providing a collection of useful snippets for various tasks. This extension is particularly useful for developers who frequently work with BrowserStack TCM, Cypress feature files, custom commands, Postman Newman deployments, and YAML templates.
Features
Snippets
The extension provides the following snippets to help you quickly scaffold your configurations and tests:
- BrowserStack Test Case Template
- Cypress Feature Example
- Cypress Custom Command
- Newman Deploy Template
- Newman Deploy Job
- Basic YAML Example
Installation
- Open Visual Studio Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing
Ctrl+Shift+X
.
- Search for "Template Assistant".
- Click Install.
Usage
BrowserStack Test Case Template
To use the BrowserStack Test Case Template snippet:
Open a file where you want to insert the BrowserStack test case template.
Type bsTemplate
and press Tab
or Enter
.
The snippet will expand to:
# Test Cases for BrowserStack TCM
test_cases:
- test_case_id: TC-001
title: Login Functionality
folder_id: 1
folder_path: Authentication
state: Active
owner: User1
priority: High
type_of_test_case: Functional
automation_status: Automated
description: Verify login with valid credentials
automation_type: UI
steps:
- Open the application
- Enter valid username and password
- Click on the login button
expected_result: User should be redirected to the dashboard
- test_case_id: TC-002
title: Logout Functionality
folder_id: 1
folder_path: Authentication
state: Active
owner: User1
priority: Medium
type_of_test_case: Functional
automation_status: Manual
description: Verify logout functionality
automation_type: UI
steps:
- Log in to the application
- Click on the logout button
expected_result: User should be redirected to the login page
Cypress Feature Example
To use the Cypress Feature Example snippet:
Open a file where you want to insert the Cypress feature example.
Type cypressFeatureExample
and press Tab
or Enter
.
The snippet will expand to:
Feature: Some Feature Description
Scenario: Some Scenario Description
Given some given
When some when
Then some then
Cypress Custom Command
To use the Cypress Custom Command snippet:
Open a file where you want to insert the Cypress custom command.
Type cypressCustomCommand
and press Tab
or Enter
.
The snippet will expand to:
Cypress.Commands.add('${1:customCommand}', (${2:param1}, ${3:param2}) => {
// Write your custom command code here
});
Newman Deploy Template
To use the Newman Deploy Template snippet:
Open a YAML file where you want to insert the Newman deploy template.
Type newmanDeployTemplate
and press Tab
or Enter
.
The snippet will expand to:
.post-deploy:newman:
stage: post-deploy
inherit:
default: true
variables:
CONFIG_ENV: $CONFIG_ENV
PROJECT_NAME: $PROJECT_NAME
SCHEDULE_TYPE: $SCHEDULE_TYPE
COLLECTION_REQ: "https://api.getpostman.com/collections/$COLLECTION_ID?apikey=$POSTMAN_KEY"
ENVIRONMENT_REQ: "https://api.getpostman.com/environments/$ENVIRONMENT_ID?apikey=$POSTMAN_KEY"
SLACK_MSG_CONFIG_FILE: '[{"name":"","id":"","setting":"onlyFail"}]'
SLACK_MSG_SILENT_FLAG: ''
UPLOAD_TO_S3: false
trigger:
project: peachpayments/qa-newman-scheduler
branch: main
strategy: depend
allow_failure: true
Newman Deploy Job
To use the Newman Deploy Job snippet:
Open a YAML file where you want to insert the Newman deploy job.
Type newmanDeployJob
and press Tab
or Enter
.
The snippet will expand to:
${1:PROJECTNAME}:newman:monitor:qa:
extends: .post-deploy:newman
variables:
PROJECT_NAME: "${1:PROJECTNAME}"
CONFIG_ENV: qa
SCHEDULE_TYPE: "monitor"
ENVIRONMENT_ID: "${2:ENVIRONMENT_ID}"
COLLECTION_ID: "${3:COLLECTION_ID}"
rules:
- if: $CI_COMMIT_BRANCH == '${4:branchName}'
Basic YAML Example
To use the Basic YAML Example snippet:
Open a YAML file where you want to insert the basic YAML example.
Type yamlExample
and press Tab
or Enter
.
The snippet will expand to:
example:
key: value
list:
- item1
- item2
Configuration
The extension supports the following languages and file types:
- YAML: Snippets for BrowserStack TCM, Postman Newman deployment configurations, and basic YAML examples
- JavaScript: Snippets for Cypress custom commands
- Plaintext: Snippets for Cypress feature files
VS Code Extension update
Install vsce
npm package with npm install -g vsce
Templates Available
- bsTemplate
- cypressCustomCommand
- newmanTriggerTemplate
- newmanTriggerJob
- cypressTriggerTemplate
- cypressTriggerJob