Jest test runner integration with Jasmine 2.x framework providing BDD-style testing capabilities
npx @tessl/cli install tessl/npm-jest-jasmine2@30.1.0Jest Jasmine2 is a Jest test runner adapter that integrates the Jasmine 2.x testing framework with Jest's testing environment. It provides a bridge between Jest's modern testing infrastructure and Jasmine's behavior-driven development (BDD) testing style, offering features like describe/it syntax, async test support, custom matchers, and test suite organization.
import jasmine2 from "jest-jasmine2";
import type { Jasmine, Reporter } from "jest-jasmine2";For CommonJS:
const jasmine2 = require("jest-jasmine2").default;Jest Jasmine2 is primarily used internally by Jest as a test runner. It integrates with Jest's configuration and runtime systems:
import jasmine2 from "jest-jasmine2";
import type { Config } from "@jest/types";
import type { JestEnvironment } from "@jest/environment";
import type Runtime from "jest-runtime";
// Used within Jest's test execution pipeline
const result = await jasmine2(
globalConfig,
config,
environment,
runtime,
testPath
);Jest Jasmine2 is built around several key components:
jasmine2 function orchestrates test execution by integrating Jest configuration with Jasmine's test frameworkThe primary function that executes Jasmine tests within Jest's environment, handling configuration, setup, and result reporting.
function jasmine2(
globalConfig: Config.GlobalConfig,
config: Config.ProjectConfig,
environment: JestEnvironment,
runtime: Runtime,
testPath: string,
): Promise<TestResult>;Jasmine to Jest test result reporting system that converts Jasmine's test results into Jest's standardized format.
class JasmineReporter implements Reporter {
constructor(
globalConfig: Config.GlobalConfig,
config: Config.ProjectConfig,
testPath: string,
);
getResults(): Promise<TestResult>;
specDone(result: SpecResult): void;
jasmineDone(runDetails: RunDetails): void;
}
interface Reporter {
jasmineDone(runDetails: RunDetails): void;
jasmineStarted(runDetails: RunDetails): void;
specDone(result: SpecResult): void;
specStarted(spec: SpecResult): void;
suiteDone(result: SuiteResult): void;
suiteStarted(result: SuiteResult): void;
}Core Jasmine 2.x implementation with Jest-specific enhancements for test execution, spying, and BDD syntax.
interface Jasmine {
_DEFAULT_TIMEOUT_INTERVAL: number;
DEFAULT_TIMEOUT_INTERVAL: number;
currentEnv_: ReturnType<typeof Env>['prototype'];
getEnv(): ReturnType<typeof Env>['prototype'];
createSpy: typeof createSpy;
addMatchers(matchers: JasmineMatchersObject): void;
version: string;
testPath: string;
}
function create(createOptions: Record<string, any>): Jasmine;
function _interface(jasmine: Jasmine, env: any): {
describe(description: string, specDefinitions: SpecDefinitionsFn): any;
it(): any;
beforeEach(): any;
afterEach(): any;
beforeAll(): any;
afterAll(): any;
spyOn(obj: Record<string, any>, methodName: string, accessType?: string): Spy;
fail(): void;
pending(): void;
}Enhanced async/await and Promise support for test functions and lifecycle hooks, with generator function support.
function jasmineAsyncInstall(
globalConfig: Config.GlobalConfig,
global: Global.Global,
): void;Setup functions that integrate Jest-specific features like snapshots, expect matchers, and global utilities.
function setupJestGlobals(options: SetupOptions): Promise<SnapshotState>;
interface SetupOptions {
config: Config.ProjectConfig;
globalConfig: Config.GlobalConfig;
localRequire: (moduleName: string) => Plugin;
testPath: string;
}
function installEach(environment: JestEnvironment): void;interface SpecDefinitionsFn {
(): void;
}
interface AssertionErrorWithStack extends AssertionError {
stack: string;
}
interface RunDetails {
totalSpecsDefined?: number;
failedExpectations?: SuiteResult['failedExpectations'];
}
interface Spy extends Record<string, any> {
(this: Record<string, unknown>, ...args: Array<any>): unknown;
and: SpyStrategy;
calls: CallTracker;
restoreObjectToOriginalState?: () => void;
}
interface JasmineMatchersObject {
[id: string]: JasmineMatcher;
}
interface JasmineMatcher {
(matchersUtil: unknown, context: unknown): JasmineMatcher;
compare(...args: Array<unknown>): unknown;
negativeCompare(...args: Array<unknown>): unknown;
}