Import JS Files

Import Javascript files

This feature is available in the paid version.
  • You can import functions from other js files. Useful for code re-use and check-in to your git repo.

Create JS File

  • Create a new JS file in the workspace.
  • Add the function you want to import in the file.
  • Export the function using module.exports
// test-import.js file
function helloWorld(){
   return "hello world";
module.exports = {

Import JS File

  • Import js file using require
  • The path should be relative to workspace if you use Git-Sync, otherwise use full-path.
  • You can right click on the file and choose Copy Path or Copy Relative Path accordingly
var { helloWorld } = require("thunder-tests/test-import.js");
var result = helloWorld();

Save Path in Env Variable

  • You can also save the path in the Environment variable, so you don't have to change the path in every request if you move the file to different folder.
var scriptPath = tc.getVar("scriptPath");
var {helloWorld} = require(scriptPath);
var result = helloWorld();


  • To enable autocompletion, you can refer to the tc-types.d.ts file.
  • Copy the tc-types.d.ts file to your project and reference it at the top for VS Code autocomplete suggestions.
// @ts-check
/// copy tc-types.d.ts file for vscode autocompletion on tc object
/// <reference path="./tc-types.d.ts" />

TS Validation

  • Use // @ts-check at the top of the script to enable TypeScript validation.