Skip to content
  • There are no suggestions because the search field is empty.

.cbconfig file

Allow running unit tests separately or modify the main run commands

Overriding run and compile commands

When creating a custom challenge or interview question, certain languages load with a .cbconfig file that contains a compile and/or a run command. You are able to override these depending on your challenge requirements. 

For example, in TypeScript if you want to run Playwright tests you can change the run command to the following: 

{
  "run": "npx playwright test"
}

In C++ for example, you can modify both the compile and run commands:

{
  "compile": "clang++ -std=c++20 -g -O0 -o a.out ENV_SOURCE_FILES",
  "run": "./a.out"
}

Custom unit tests button

While you're able to create a custom unit testing challenge, you may want to provide candidates the option to run arbitrary code along with running a test case suite as separate options.

In your .cbconfig you're able to provide a separate run command for your unit tests. The contents should be a JSON object like the one below:

{
  "unitTests": {
    "label": "Run unit tests",
    "run": "python run_tests.py"
  }
}

This will then load a button with your text in the top-right of the IDE allowing you to Run code and Run unit tests separately.

Alternatively, for some languages that only support a single main function in the project (e.g. C++) you can provide separate compile and run commands. The example below allows you to run separate C++ files in your project.

{
  "compile": "clang++ -std=c++20 -g -O0 -o a.out Main.cpp",
  "run": "./a.out",
  "unitTests": {
    "label": "Run tests",
    "compile": "clang++ -std=c++20 -g -O0 -o b.out tests.cpp",
    "run": "./b.out"
  }
}

The variable ENV_SOURCE_FILES represents all the source files in the project. For example, if you want to compile all C++ files you would replace "Main.cpp" with ENV_SOURCE_FILES.