🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@testgorilla/tgo-coding-test

Package Overview
Dependencies
Maintainers
15
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@testgorilla/tgo-coding-test

Coding test component

npmnpm
Version
5.0.0
Version published
Weekly downloads
412
-42.54%
Maintainers
15
Weekly downloads
 
Created
Source

@testgorilla/tgo-coding-test

Coding test component for TestGorilla assessments.

Installation

npm install @testgorilla/tgo-coding-test

Configuration

The library requires runtime configuration to be provided by the consuming application. This follows the Dependency Injection pattern for NPM libraries, where the library artifact is immutable and configuration is provided at runtime.

Setup

In your application's app.config.ts (for standalone apps) or module providers:

import { ApplicationConfig } from '@angular/core';
import { TGO_CODING_TEST_CONFIG } from '@testgorilla/tgo-coding-test';
import { environment } from './environments/environment';

export const appConfig: ApplicationConfig = {
  providers: [
    // Provide TGO Coding Test library configuration
    {
      provide: TGO_CODING_TEST_CONFIG,
      useValue: {
        apiUrl: environment.apiUrl,
        coderunnerV2Endpoint: environment.coderunnerV2Endpoint,
      }
    },
    // ... other providers
  ],
};

Configuration Interface

interface TgoCodingTestConfig {
  /**
   * The base URL for the main API endpoint.
   * Example: 'https://api-talent-staging.testgorilla.com/api/'
   */
  apiUrl: string;

  /**
   * The base URL for the CodeRunner V2 API endpoint.
   * Example: 'https://cr-v2-staging.testgorilla.com'
   */
  coderunnerV2Endpoint: string;
}

Note: The configuration must be provided at the application level. If you're using TgoCodingTestCandidateViewComponent in a demo or test environment, you can provide the configuration directly in the component's providers array, but this is not recommended for production use.

Usage

TgoCodingTestComponent

The core coding test component for rendering code editors and test cases.

import { TgoCodingTestComponent } from '@testgorilla/tgo-coding-test';

@Component({
  imports: [TgoCodingTestComponent],
  template: `
    <tgo-coding-test
      [languages]="languages"
      [initCode]="initCode"
      [questionText]="questionText"
      [mode]="mode"
      [viewMode]="viewMode"
      [isLAT]="isLAT"
      [isSQL]="isSQL"
      [applicationTheme]="applicationTheme"
      (codeChange)="onCodeChange($event)"
      (languageChange)="onLanguageChange($event)"
      (runTestClick)="onRunTestClick($event)"
      (pasteEvent)="onPasteEvent($event)"
    ></tgo-coding-test>
  `,
})
export class MyComponent {}

TgoCodingTestCandidateViewComponent

The candidate view component that wraps TgoCodingTestComponent with full test management, API integration, and anti-cheating features.

import { TgoCodingTestCandidateViewComponent } from '@testgorilla/tgo-coding-test';

@Component({
  imports: [TgoCodingTestCandidateViewComponent],
  template: `
    <tgo-coding-test-candidate-view
      [question]="question"
      [test]="test"
      [assessment]="assessment"
      [expirationObservable]="expirationObservable"
      [completeObservable]="completeObservable"
      (submissionStateChanged)="onSubmissionStateChanged($event)"
      (loadingStateChanged)="onLoadingStateChanged($event)"
      (antiCheatingConfigurationChanged)="onAntiCheatingConfigurationChanged($event)"
      (fullscreenChanged)="onFullscreenChanged($event)"
      (themeChanged)="onThemeChanged($event)"
      (navigationButtonStateChanged)="onNavigationButtonStateChanged($event)"
      (configurationStateChanged)="onConfigurationStateChanged($event)"
    ></tgo-coding-test-candidate-view>
  `,
})
export class MyComponent {}

Assets (translations)

This package ships its translations under assets/i18n. Consumer apps must copy these assets into their build output so Transloco can load them at runtime.

  • Angular CLI / Nx: add an assets entry pointing at the package:
{
  "assets": [
    "src/favicon.ico",
    "src/assets",
    {
      "glob": "**/*",
      "input": "node_modules/@testgorilla/tgo-coding-test/assets",
      "output": "assets/tgo-coding-test"
    }
  ]
}

If you develop inside this repo (consuming the workspace sources), also include the local path:

{
  "glob": "**/*",
  "input": "packages/tgo-coding-test/src/assets",
  "output": "assets/tgo-coding-test"
}

After adding the asset entries, rebuild/re-serve your app so /assets/tgo-coding-test/i18n/en.json is available.

Mocking ApiService for demo/local runs

The candidate view includes a mocked API service for demos. To use it:

  • In tgo-coding-test-candidate-view.component.ts, uncomment the mock provider and comment the real one:
// use MockedApiService for local demo only
{ provide: ApiService, useClass: MockedApiService },
// ApiService,
  • Ensure MockedApiService is imported at the top of the file.

This lets the component run without live backend calls when serving the demo app.

API

TgoCodingTestComponent

Inputs

NameTypeRequiredDefaultDescription
languagesLATLanguagesYes-Array of available programming languages
initCodestringNo-Initial code to display in the editor
snapshotCodingSnapshotNo-Snapshot of coding state for restoration
functionParamsCodeEditorFuncParam[]No-Function parameters for function-based questions
functionNamestringNo-Function name for function-based questions
returnTypekeyof CodeEditorTypesMapNo-Return type for function-based questions
isLATbooleanNo-Whether this is a Language-Agnostic Test
isSQLbooleanNo-Whether this is an SQL test
shouldGenerateInitCodebooleanNotrueWhether to generate initial code automatically
canAddCustomTestCasesbooleanNotrueWhether users can add custom test cases
selectedProgrammingLanguageLATLanguageNo-Pre-selected programming language
isReadonlybooleanNo-Whether the editor is in read-only mode
autoHeightbooleanNo-Whether the editor should auto-adjust height
translationsRecord<string, unknown>No-Translation object for UI text
questionTextstringNo-Question text to display
modeModesNo-Test mode (Running, Preview, NonAssessmentPreview)
assessmentIdstringNo-Assessment ID for storage and tracking
companyColorstringNo-Company brand color for theming
testCasesStatusanyNo-Status of test case execution
loadingbooleanNo-Loading state indicator
runTestResponseany[]No[]Response from test execution
viewModeViewModeNo-View mode (Full, Compact)
exampleTestCasesExampleTestCase[]No-Example test cases to display
hideTestCasesbooleanNo-Whether to hide test cases UI (legacy property)
applicationThemeApplicationThemeNo'light'Application theme (light/dark)
questionIdnumberNo-Question ID for storage and tracking

Outputs

NameTypeDescription
pasteEventEventEmitter<PasteData>Emits when paste event is detected
codeChangeEventEmitter<string>Emits when code content changes
runTestClickEventEmitter<boolean>Emits when run test button is clicked
languageChangeEventEmitter<CodeEditorLanguages>Emits when programming language is changed

TgoCodingTestCandidateViewComponent

Inputs

NameTypeRequiredDefaultDescription
questionQuestionYes-Question data containing coding test context
testTestResultReadYes-Test configuration and metadata
assessmentAssessmentNo-Assessment context
expirationObservableObservable<void>No-Observable to trigger test expiration externally
completeObservableObservable<void>No-Observable to trigger test completion externally

Outputs

NameTypeDescription
submissionStateChangedEventEmitter<ISubmissionState | null>Emits submission state when answer is submitted
loadingStateChangedEventEmitter<boolean>Emits loading state changes
antiCheatingConfigurationChangedEventEmitter<IAntiCheatingState | null>Emits anti-cheating configuration changes
fullscreenChangedEventEmitter<boolean>Emits when fullscreen state changes
themeChangedEventEmitter<ApplicationTheme>Emits when application theme changes
codingFullscreenChangedEventEmitter<boolean>Emits when coding editor fullscreen changes
navigationButtonStateChangedEventEmitter<INavigationButtonState | null>Emits navigation button state changes
configurationStateChangedEventEmitter<IConfigurationState | null>Emits configuration state changes
validationStatusChangedEventEmitter<any>Emits validation status changes

Peer Dependencies

This library requires the following peer dependencies:

  • @angular/common ^18.2.13
  • @angular/core ^18.2.13
  • @angular/animations ^18.2.13
  • @angular/forms ^18.2.13
  • @angular/material 18.2.14
  • @angular/router ^18.2.13
  • @ngneat/transloco ~4.3.0
  • @ngneat/until-destroy 10.0.0
  • @testgorilla/tgo-ui ^3.0.0
  • angular-split ^18.0.0
  • monaco-editor 0.50.0
  • ngx-guided-tour ^2.0.1
  • ngx-monaco-editor-v2 ^18.1.0
  • ngx-quill ^26.0.10
  • ngx-webstorage ^18.0.0
  • quill ^2.0.3
  • rxjs ~7.8.1

Internal Dependencies

All required services, models, and components are included within this library:

  • LibCodingTestService - Manages coding test state, language selection, and code management
  • StorageCodingService - Handles localStorage persistence for code and test cases
  • CodingTestService - Handles test execution, API calls, and test case management
  • CandidatureApiService - API service for candidate-related operations
  • CoderunnerApiService - API service for code execution
  • CodingTestConfigService - Provides access to library configuration (injects configuration token internally)
  • ThemeService - Provides theme/company color configuration
  • Question, TestResultRead, Assessment, ISubmissionState - Type definitions (bundled from shared code)
  • CodeEditorComponent, CodingQuestionComponent, RunnableEditorComponent - UI components
  • TranslocoLazyModuleUtils, getAvailableLangs - Translation utilities

Accessing Configuration

If you need to access the library configuration in your services or components, inject CodingTestConfigService:

import { CodingTestConfigService } from '@testgorilla/tgo-coding-test';

@Injectable()
export class MyService {
  private readonly configService = inject(CodingTestConfigService);
  
  doSomething() {
    const endpoint = this.configService.getCoderunnerV2Endpoint();
    // Use endpoint...
  }
}

Features

  • Multi-language code editor support (Language-Agnostic Tests)
  • SQL test support
  • Custom test case creation and management
  • Code auto-save and restoration
  • Test execution with real-time results
  • Fullscreen mode support
  • Theme support (light/dark)
  • Guided tour for new users
  • Anti-cheating configuration
  • Translation support via Transloco
  • Preview mode support
  • Code paste detection and tracking
  • Periodic storage maintenance

FAQs

Package last updated on 19 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts