0
# WDIO Jasmine Framework
1
2
A WebdriverIO plugin that provides adapter functionality for integrating the Jasmine testing framework with WebdriverIO test runner. This adapter enables end-to-end testing using Jasmine's familiar describe/it syntax and assertion methods within WebdriverIO environments.
3
4
## Package Information
5
6
- **Package Name**: @wdio/jasmine-framework
7
- **Package Type**: npm
8
- **Language**: TypeScript
9
- **Installation**: `npm install @wdio/jasmine-framework --save-dev`
10
11
## Core Imports
12
13
```typescript
14
import JasmineAdapterFactory, { JasmineAdapter } from "@wdio/jasmine-framework";
15
```
16
17
For CommonJS:
18
19
```javascript
20
const JasmineAdapterFactory = require("@wdio/jasmine-framework").default;
21
const { JasmineAdapter } = require("@wdio/jasmine-framework");
22
```
23
24
## Basic Usage
25
26
The adapter is typically configured through WebdriverIO configuration rather than direct instantiation:
27
28
```javascript
29
// wdio.conf.js
30
export const config = {
31
framework: 'jasmine',
32
jasmineOpts: {
33
defaultTimeoutInterval: 10000,
34
expectationResultHandler: (passed, data) => {
35
// Handle assertion results
36
if (!passed) {
37
console.log('Assertion failed:', data.message);
38
}
39
}
40
}
41
};
42
```
43
44
Direct adapter usage (advanced):
45
46
```typescript
47
import JasmineAdapterFactory from "@wdio/jasmine-framework";
48
import type { EventEmitter } from "node:events";
49
50
const adapter = await JasmineAdapterFactory.init(
51
'worker-id',
52
config,
53
specFiles,
54
capabilities,
55
reporter
56
);
57
58
const exitCode = await adapter.run();
59
```
60
61
## Architecture
62
63
The WDIO Jasmine Framework is built around several key components:
64
65
- **Adapter Factory**: Entry point that creates and initializes JasmineAdapter instances
66
- **JasmineAdapter**: Core adapter class that bridges WebdriverIO with Jasmine framework
67
- **Event System**: Internal reporting bridge that translates Jasmine events to WebdriverIO reporter format
68
- **Configuration System**: Comprehensive options for customizing Jasmine behavior within WebdriverIO
69
- **Matcher Integration**: Seamless integration of WebdriverIO matchers with Jasmine expectations
70
71
## Capabilities
72
73
### Adapter Factory
74
75
Factory for creating and initializing JasmineAdapter instances. Provides the main entry point for WebdriverIO test runner integration.
76
77
```typescript { .api }
78
declare const adapterFactory: {
79
init?: (
80
cid: string,
81
config: WebdriverIOJasmineConfig,
82
specs: string[],
83
capabilities: Capabilities.ResolvedTestrunnerCapabilities,
84
reporter: EventEmitter
85
) => Promise<JasmineAdapter>;
86
};
87
88
export default adapterFactory;
89
export { JasmineAdapter, adapterFactory };
90
```
91
92
[Adapter Implementation](./adapter.md)
93
94
### Framework Configuration
95
96
Comprehensive configuration options for customizing Jasmine behavior within WebdriverIO environments, including timeouts, filtering, and custom handlers.
97
98
```typescript { .api }
99
interface JasmineOpts {
100
defaultTimeoutInterval?: number;
101
helpers?: string[];
102
requires?: string[];
103
random?: boolean;
104
seed?: Function;
105
failFast?: boolean;
106
failSpecWithNoExpectations?: boolean;
107
oneFailurePerSpec?: boolean;
108
specFilter?: () => boolean;
109
grep?: string | RegExp;
110
invertGrep?: boolean;
111
cleanStack?: boolean;
112
stopOnSpecFailure?: boolean;
113
stopSpecOnExpectationFailure?: boolean;
114
expectationResultHandler?: (passed: boolean, data: ResultHandlerPayload) => void;
115
}
116
```
117
118
[Configuration Options](./configuration.md)
119
120
## Types
121
122
```typescript { .api }
123
interface WebdriverIOJasmineConfig extends Omit<WebdriverIO.Config, keyof HooksArray>, HooksArray {
124
jasmineOpts: Omit<JasmineOpts, 'cleanStack'>;
125
}
126
127
interface ResultHandlerPayload {
128
passed: boolean;
129
message?: string;
130
error?: Error;
131
}
132
133
type HooksArray = {
134
[K in keyof Required<Services.HookFunctions>]: Required<Services.HookFunctions>[K][];
135
}
136
```