CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-wdio--jasmine-framework

A WebdriverIO plugin adapter that integrates Jasmine testing framework with WebdriverIO test runner for end-to-end testing.

Pending
Overview
Eval results
Files

configuration.mddocs/

Configuration Options

Comprehensive configuration options for customizing Jasmine behavior within WebdriverIO environments, including timeouts, test filtering, execution control, and custom handlers.

Capabilities

JasmineOpts Interface

Main configuration interface for customizing Jasmine framework adapter behavior.

/**
 * Configuration options for Jasmine framework adapter
 */
interface JasmineOpts {
  /** Default timeout interval for Jasmine operations (default: 60000ms) */
  defaultTimeoutInterval?: number;

  /** Array of helper file paths relative to spec directory to include before specs (default: []) */
  helpers?: string[];

  /** Array of module paths to require before requiring any helper or spec files (default: []) */
  requires?: string[];

  /** Whether to randomize spec execution order (default: true) */
  random?: boolean;

  /** Seed function for randomization basis. Null causes random seed (default: undefined) */
  seed?: Function;

  /** Whether to stop execution after first spec failure (deprecated, use stopOnSpecFailure) */
  failFast?: boolean;

  /** Whether to fail specs that ran no expectations (default: false) */
  failSpecWithNoExpectations?: boolean;

  /** Whether specs should only have one expectation failure per spec (default: false) */
  oneFailurePerSpec?: boolean;

  /** Custom function to filter which specs to run */
  specFilter?: () => boolean;

  /** Pattern to selectively run specs matching string or regexp */
  grep?: string | RegExp;

  /** If true, inverts grep matches to run non-matching tests (default: false) */
  invertGrep?: boolean;

  /** Whether to clean up stack traces removing node module references (default: false) */
  cleanStack?: boolean;

  /** Whether to stop test suite execution on first spec failure (default: false) */
  stopOnSpecFailure?: boolean;

  /** Whether to stop spec execution on first expectation failure (default: false) */
  stopSpecOnExpectationFailure?: boolean;

  /** Custom handler for intercepting assertion results for logging or screenshots */
  expectationResultHandler?: (passed: boolean, data: ResultHandlerPayload) => void;
}

Usage Examples:

// Basic configuration
export const config = {
  framework: 'jasmine',
  jasmineOpts: {
    defaultTimeoutInterval: 30000,
    random: false,
    stopOnSpecFailure: true
  }
};

// Advanced configuration with custom handlers
export const config = {
  framework: 'jasmine',
  jasmineOpts: {
    defaultTimeoutInterval: 60000,
    helpers: ['./test/helpers/**/*.js'],
    requires: ['ts-node/register'],
    grep: /smoke/,
    expectationResultHandler: (passed, data) => {
      if (!passed) {
        // Take screenshot on failure
        browser.saveScreenshot(`./failures/${Date.now()}.png`);
        console.log('Assertion failed:', data.message);
      }
    },
    cleanStack: true,
    failSpecWithNoExpectations: true
  }
};

Configuration Properties

Timeout Management

/** Default timeout interval for all Jasmine operations */
defaultTimeoutInterval?: number; // Default: 60000ms

Controls the default timeout for all Jasmine specs and hooks. Individual tests can override this with their own timeout parameter.

File Loading

/** Helper files to load before spec files */
helpers?: string[];

/** Modules to require before any helper or spec files */
requires?: string[];

Helper files are loaded after requires but before spec files. Both support glob patterns for file matching.

Execution Control

/** Randomize spec execution order */
random?: boolean; // Default: true

/** Custom seed function for randomization */
seed?: Function;

/** Stop suite execution on first spec failure */
stopOnSpecFailure?: boolean; // Default: false

/** Stop spec execution on first expectation failure */
stopSpecOnExpectationFailure?: boolean; // Default: false

Test Filtering

/** Custom spec filter function */
specFilter?: () => boolean;

/** Pattern to match spec names */
grep?: string | RegExp;

/** Invert grep pattern matching */
invertGrep?: boolean; // Default: false

Filtering allows selective test execution based on patterns or custom logic. When specFilter is provided, grep and invertGrep are ignored.

Validation and Error Handling

/** Fail specs with no expectations */
failSpecWithNoExpectations?: boolean; // Default: false

/** Limit to one expectation failure per spec */
oneFailurePerSpec?: boolean; // Default: false

/** Clean up stack traces */
cleanStack?: boolean; // Default: false

/** Custom expectation result handler */
expectationResultHandler?: (passed: boolean, data: ResultHandlerPayload) => void;

Result Handler Payload

Data structure passed to custom expectation result handlers.

/**
 * Payload structure for expectation result handlers
 */
interface ResultHandlerPayload {
  /** Whether the expectation passed */
  passed: boolean;

  /** Optional message describing the expectation */
  message?: string;

  /** Error object if expectation failed */
  error?: Error;
}

Usage Example:

expectationResultHandler: (passed, data) => {
  console.log(`Expectation ${passed ? 'passed' : 'failed'}`);
  
  if (!passed) {
    console.log('Failure message:', data.message);
    
    if (data.error) {
      console.log('Error details:', data.error.stack);
    }
    
    // Custom failure handling (screenshots, logging, etc.)
    handleTestFailure(data);
  }
}

WebdriverIO Integration Types

Extended configuration interface that combines WebdriverIO config with Jasmine options.

/**
 * WebdriverIO configuration extended with Jasmine options
 */
interface WebdriverIOJasmineConfig extends Omit<WebdriverIO.Config, keyof HooksArray>, HooksArray {
  /** Jasmine-specific configuration options */
  jasmineOpts: Omit<JasmineOpts, 'cleanStack'>;
}

/**
 * Hook arrays for WebdriverIO integration
 */
type HooksArray = {
  [K in keyof Required<Services.HookFunctions>]: Required<Services.HookFunctions>[K][];
}

Deprecated Options

Legacy Properties

/** @deprecated Use stopOnSpecFailure instead */
failFast?: boolean;

Note: stopSpecOnExpectationFailure is not deprecated but works alongside oneFailurePerSpec. When either is set to true, specs will only have one expectation failure. The implementation checks both properties for backwards compatibility.

Install with Tessl CLI

npx tessl i tessl/npm-wdio--jasmine-framework

docs

adapter.md

configuration.md

index.md

tile.json