CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-jest-jasmine2

Jest test runner integration with Jasmine 2.x framework providing BDD-style testing capabilities

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

test-runner.mddocs/

Test Runner

The main test runner function that executes Jasmine tests within Jest's environment, handling configuration, setup, and result reporting.

Capabilities

Main Test Runner Function

The primary export that orchestrates test execution by integrating Jest configuration with Jasmine's test framework.

/**
 * Main test runner function that executes Jasmine tests within Jest environment
 * @param globalConfig - Jest global configuration
 * @param config - Jest project-specific configuration
 * @param environment - Jest test environment (jsdom, node, etc.)
 * @param runtime - Jest runtime instance for module resolution and execution
 * @param testPath - Absolute path to the test file being executed
 * @returns Promise resolving to Jest TestResult
 */
function jasmine2(
  globalConfig: Config.GlobalConfig,
  config: Config.ProjectConfig,
  environment: JestEnvironment,
  runtime: Runtime,
  testPath: string,
): Promise<TestResult>;

Usage Example:

import jasmine2 from "jest-jasmine2";

// Typically called by Jest's test runner infrastructure
const testResult = await jasmine2(
  globalConfig,
  projectConfig,
  testEnvironment,
  jestRuntime,
  "/path/to/test.spec.js"
);

console.log(`Tests: ${testResult.numPassingTests} passed, ${testResult.numFailingTests} failed`);

Test Result Integration

The function returns Jest's standardized TestResult format with complete test execution information.

interface TestResult {
  console?: ConsoleBuffer;
  coverage?: CoverageMapData;
  displayName?: Config.DisplayName;
  failureMessage?: string | null;
  leaks: boolean;
  memoryUsage?: Bytes;
  numFailingTests: number;
  numPassingTests: number;
  numPendingTests: number;
  numTodoTests: number;
  openHandles: Array<Error>;
  perfStats: {
    end: Milliseconds;
    runtime: Milliseconds;
    slow: boolean;
    start: Milliseconds;
  };
  skipped: boolean;
  snapshot: {
    added: number;
    fileDeleted: boolean;
    matched: number;
    unchecked: number;
    uncheckedKeys: Array<string>;
    unmatched: number;
    updated: number;
  };
  sourceMaps: {[sourcePath: string]: string};
  testExecError?: SerializableError;
  testFilePath: string;
  testResults: Array<AssertionResult>;
}

Test Execution Flow

The test runner follows this execution sequence:

  1. Environment Setup: Creates Jasmine reporter and factory instances
  2. Global Installation: Installs BDD interface (describe, it, etc.) into test environment
  3. Jest Integration: Sets up Jest-specific features (expect, snapshots, mocks)
  4. Async Support: Installs Promise/async support for test functions
  5. Test File Loading: Loads and executes the test file
  6. Test Execution: Runs all registered tests through Jasmine
  7. Result Collection: Gathers results and converts to Jest format
  8. Snapshot Processing: Handles snapshot state and cleanup

Configuration Integration

The test runner integrates with Jest's configuration system:

Global Configuration

  • testTimeout: Default timeout for test functions
  • maxConcurrency: Maximum concurrent tests for it.concurrent
  • expand: Expand diff output in test results
  • testNamePattern: Filter tests by name pattern
  • errorOnDeprecated: Throw errors on deprecated Jasmine APIs

Project Configuration

  • testLocationInResults: Include test location in results
  • fakeTimers.enableGlobally: Enable fake timers globally
  • fakeTimers.legacyFakeTimers: Use legacy fake timer implementation
  • resetModules: Reset module registry between tests
  • clearMocks/resetMocks/restoreMocks: Mock management settings
  • setupFilesAfterEnv: Setup files to run after environment setup
  • snapshotSerializers: Custom snapshot serializers

Usage Example:

// Jest configuration affecting jest-jasmine2 behavior
module.exports = {
  testRunner: "jest-jasmine2",
  testTimeout: 10000,
  testEnvironment: "node",
  setupFilesAfterEnv: ["<rootDir>/setup-tests.js"],
  fakeTimers: {
    enableGlobally: true,
    legacyFakeTimers: false
  }
};

docs

async-support.md

index.md

jasmine-framework.md

jest-integration.md

reporting.md

test-runner.md

tile.json