@serenity-js/mocha 3.36.1 → 3.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +97 -84
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.37.0](https://github.com/serenity-js/serenity-js/compare/v3.36.2...v3.37.0) (2025-12-02)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @serenity-js/mocha
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.36.2](https://github.com/serenity-js/serenity-js/compare/v3.36.1...v3.36.2) (2025-11-26)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @serenity-js/mocha
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [3.36.1](https://github.com/serenity-js/serenity-js/compare/v3.36.0...v3.36.1) (2025-11-16)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @serenity-js/mocha
|
package/README.md
CHANGED
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
# Serenity/JS
|
|
1
|
+
# Serenity/JS Mocha
|
|
2
2
|
|
|
3
|
-
[](https://badge.fury.io/js/%40serenity-js%2Fmocha)
|
|
4
|
+
[](https://github.com/serenity-js/serenity-js/actions)
|
|
5
|
+
[](https://qlty.sh/gh/serenity-js/projects/serenity-js)
|
|
6
|
+
[](https://qlty.sh/gh/serenity-js/projects/serenity-js)
|
|
7
|
+
[](https://github.com/serenity-js/serenity-js/graphs/contributors)
|
|
8
|
+
[](https://snyk.io/test/npm/@serenity-js/mocha)
|
|
9
|
+
[](https://github.com/serenity-js/serenity-js)
|
|
7
10
|
|
|
8
|
-
[
|
|
9
|
-
of complex software systems faster, more collaborative and easier to scale.
|
|
11
|
+
[`@serenity-js/mocha`](https://serenity-js.org/api/mocha/) brings full [Serenity reporting](https://serenity-js.org/handbook/reporting/) capabilities to [Mocha](https://serenity-js.org/handbook/test-runners/mocha/) and enables writing tests using the [Screenplay Pattern](https://serenity-js.org/handbook/design/screenplay-pattern/).
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
- [Serenity/JS web testing tutorial](https://serenity-js.org/handbook/web-testing/your-first-web-scenario)
|
|
13
|
-
- [Serenity/JS Handbook](https://serenity-js.org/handbook)
|
|
14
|
-
- [API documentation](https://serenity-js.org/api/)
|
|
15
|
-
- [Serenity/JS Project Templates](https://serenity-js.org/handbook/project-templates/)
|
|
16
|
-
|
|
17
|
-
👋 Join the Serenity/JS Community!
|
|
18
|
-
- Meet other Serenity/JS developers and maintainers on the [Serenity/JS Community chat channel](https://matrix.to/#/#serenity-js:gitter.im),
|
|
19
|
-
- Find answers to your Serenity/JS questions on the [Serenity/JS Forum](https://github.com/orgs/serenity-js/discussions/categories/how-do-i),
|
|
20
|
-
- Learn how to [contribute to Serenity/JS](https://serenity-js.org/community/contributing/),
|
|
21
|
-
- Support the project and gain access to [Serenity/JS Playbooks](https://github.com/serenity-js/playbooks) by becoming a [Serenity/JS GitHub Sponsor](https://github.com/sponsors/serenity-js)!
|
|
22
|
-
|
|
23
|
-
## Serenity/JS Mocha
|
|
13
|
+
## Features
|
|
24
14
|
|
|
25
|
-
[
|
|
15
|
+
- Enables [Screenplay Pattern](https://serenity-js.org/handbook/design/screenplay-pattern/) APIs in Mocha tests
|
|
16
|
+
- Supports all [Serenity/JS reporting features](https://serenity-js.org/handbook/reporting/)
|
|
17
|
+
- TypeScript-first design with strong typing for safer and more predictable test code.
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Install [Mocha](https://mochajs.org/) version 8.x or newer:
|
|
19
|
+
## Installation
|
|
30
20
|
|
|
31
21
|
```sh
|
|
32
|
-
npm install --save-dev mocha
|
|
22
|
+
npm install --save-dev @serenity-js/core @serenity-js/console-reporter @serenity-js/mocha
|
|
33
23
|
```
|
|
34
24
|
|
|
35
|
-
|
|
25
|
+
See the [Serenity/JS Installation Guide](https://serenity-js.org/handbook/installation/).
|
|
36
26
|
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { actorCalled } from '@serenity-js/core';
|
|
31
|
+
import { describe, it } from 'mocha';
|
|
32
|
+
|
|
33
|
+
describe('Example Test', () => {
|
|
34
|
+
it('supports actors', async () => {
|
|
35
|
+
await actorCalled('Alice').attemptsTo(
|
|
36
|
+
// Add tasks and interactions here
|
|
37
|
+
)
|
|
38
|
+
})
|
|
39
|
+
})
|
|
39
40
|
```
|
|
40
41
|
|
|
42
|
+
Explore practical examples and in-depth explanations in the [Serenity/JS Handbook](https://serenity-js.org/handbook/).
|
|
43
|
+
|
|
44
|
+
## Reporting
|
|
41
45
|
|
|
42
46
|
### Usage with standalone Mocha
|
|
43
47
|
|
|
@@ -46,18 +50,15 @@ you'll need a setup file that configures Serenity/JS reporting services.
|
|
|
46
50
|
|
|
47
51
|
#### JavaScript
|
|
48
52
|
|
|
49
|
-
If you're writing your tests in JavaScript, create a `
|
|
53
|
+
If you're writing your tests in JavaScript, create a `serenity.config.js` file (for example under `spec/support/serenity.config.js`, but you can use any location you like):
|
|
50
54
|
|
|
51
55
|
```javascript
|
|
52
|
-
// spec/support/
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
{ ConsoleReporter } = require('@serenity-js/console-reporter'),
|
|
56
|
-
{ configure } = require('@serenity-js/core');
|
|
56
|
+
// spec/support/serenity.config.js
|
|
57
|
+
const { configure } = require('@serenity-js/core')
|
|
57
58
|
|
|
58
59
|
configure({
|
|
59
60
|
crew: [
|
|
60
|
-
|
|
61
|
+
'@serenity-js/console-reporter',
|
|
61
62
|
],
|
|
62
63
|
})
|
|
63
64
|
```
|
|
@@ -66,7 +67,7 @@ Next, run Mocha as follows:
|
|
|
66
67
|
|
|
67
68
|
```console
|
|
68
69
|
mocha --reporter=@serenity-js/mocha \
|
|
69
|
-
--require=spec/support/
|
|
70
|
+
--require=spec/support/serenity.config.js \
|
|
70
71
|
'spec/**/*.spec.js'
|
|
71
72
|
```
|
|
72
73
|
|
|
@@ -83,25 +84,23 @@ If you haven't done so already, configure your TypeScript transpiler via [`tscon
|
|
|
83
84
|
```json
|
|
84
85
|
{
|
|
85
86
|
"compilerOptions": {
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
87
|
+
"lib": ["ES2023"],
|
|
88
|
+
"module": "nodenext",
|
|
89
|
+
"target": "ES2023"
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
```
|
|
92
93
|
|
|
93
|
-
Create a `
|
|
94
|
+
Create a `serenity.config.ts` file (for example under `spec/support/serenity.config.ts`, but you can use any location you like):
|
|
94
95
|
|
|
95
96
|
```typescript
|
|
96
97
|
// spec/support/setup.ts
|
|
97
|
-
|
|
98
|
-
import { ConsoleReporter } from '@serenity-js/console-reporter'
|
|
99
98
|
import { configure } from '@serenity-js/core'
|
|
100
99
|
|
|
101
100
|
configure({
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
crew: [
|
|
102
|
+
'@serenity-js/console-reporter',
|
|
103
|
+
],
|
|
105
104
|
})
|
|
106
105
|
```
|
|
107
106
|
|
|
@@ -116,7 +115,7 @@ mocha --reporter=@serenity-js/mocha \
|
|
|
116
115
|
|
|
117
116
|
#### Using Mocha configuration file
|
|
118
117
|
|
|
119
|
-
|
|
118
|
+
You can use `.mocharc.yml` [configuration file](https://mochajs.org/#configuring-mocha-nodejs)
|
|
120
119
|
to simplify your command line execution.
|
|
121
120
|
|
|
122
121
|
For example:
|
|
@@ -125,7 +124,7 @@ For example:
|
|
|
125
124
|
reporter: '@serenity-js/mocha'
|
|
126
125
|
require:
|
|
127
126
|
- ts-node/register
|
|
128
|
-
- spec/support/
|
|
127
|
+
- spec/support/serenity.config.ts
|
|
129
128
|
check-leaks: false
|
|
130
129
|
timeout: 5000
|
|
131
130
|
v8-stack-trace-limit: 100
|
|
@@ -140,21 +139,22 @@ reporter-options: # Note: array, not an object
|
|
|
140
139
|
- 'specDirectory=e2e' # Configure custom requirements hierarchy root, such as "e2e"
|
|
141
140
|
```
|
|
142
141
|
|
|
143
|
-
### Using Serenity/JS Mocha with
|
|
142
|
+
### Using Serenity/JS Mocha with WebdriverIO
|
|
144
143
|
|
|
145
|
-
Configure your
|
|
144
|
+
Configure your WebdriverIO installation as per instructions in [`@serenity-js/webdriverio`](https://serenity-js.org/api/webdriverio/) module.
|
|
146
145
|
|
|
147
|
-
Next, instruct Serenity/JS to run your tests using Mocha. You can also use your `
|
|
146
|
+
Next, instruct Serenity/JS to run your tests using Mocha. You can also use your `wdio.conf.ts` file to [configure Mocha](https://serenity-js.org/api/mocha-adapter/interface/MochaConfig/) if needed:
|
|
148
147
|
|
|
149
|
-
```typescript title="
|
|
150
|
-
//
|
|
148
|
+
```typescript title="wdio.conf.ts"
|
|
149
|
+
// wdio.conf.ts
|
|
151
150
|
|
|
152
|
-
|
|
153
|
-
// Tell
|
|
154
|
-
framework:
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
export const config = {
|
|
152
|
+
// Tell WebdriverIO to use the Serenity/JS framework adapter
|
|
153
|
+
framework: '@serenity-js/webdriverio',
|
|
154
|
+
|
|
155
|
+
// Serenity/JS configuration
|
|
157
156
|
serenity: {
|
|
157
|
+
// Configure Serenity/JS to use an appropriate test runner adapter
|
|
158
158
|
runner: 'mocha', // Use Mocha
|
|
159
159
|
// ... other Serenity/JS-specific configuration
|
|
160
160
|
},
|
|
@@ -164,7 +164,7 @@ exports.config = {
|
|
|
164
164
|
reporterOptions: [
|
|
165
165
|
'specDirectory=e2e'
|
|
166
166
|
],
|
|
167
|
-
|
|
167
|
+
|
|
168
168
|
// ... other Mocha-specific configuration
|
|
169
169
|
},
|
|
170
170
|
|
|
@@ -174,22 +174,21 @@ exports.config = {
|
|
|
174
174
|
|
|
175
175
|
Learn more about supported [Mocha configuration options](https://serenity-js.org/api/mocha-adapter/interface/MochaConfig/).
|
|
176
176
|
|
|
177
|
-
### Using Serenity/JS Mocha with
|
|
178
|
-
|
|
179
|
-
Configure your WebdriverIO installation as per instructions in [`@serenity-js/webdriverio`](https://serenity-js.org/api/webdriverio/) module.
|
|
177
|
+
### Using Serenity/JS Mocha with Protractor
|
|
180
178
|
|
|
181
|
-
|
|
179
|
+
Configure your Protractor installation as per instructions in [`@serenity-js/protractor`](https://serenity-js.org/api/protractor/) module.
|
|
182
180
|
|
|
183
|
-
|
|
184
|
-
// wdio.conf.ts
|
|
181
|
+
Next, instruct Serenity/JS to run your tests using Mocha. You can also use your `protractor.conf.js` file to [configure Mocha](https://serenity-js.org/api/mocha-adapter/interface/MochaConfig/) if needed:
|
|
185
182
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
framework: '@serenity-js/webdriverio',
|
|
183
|
+
```typescript title="protractor.conf.js"
|
|
184
|
+
// protractor.conf.js
|
|
189
185
|
|
|
190
|
-
|
|
186
|
+
exports.config = {
|
|
187
|
+
// Tell Protractor to use the Serenity/JS framework adapter
|
|
188
|
+
framework: 'custom',
|
|
189
|
+
frameworkPath: require.resolve('@serenity-js/protractor/adapter'),
|
|
190
|
+
|
|
191
191
|
serenity: {
|
|
192
|
-
// Configure Serenity/JS to use an appropriate test runner adapter
|
|
193
192
|
runner: 'mocha', // Use Mocha
|
|
194
193
|
// ... other Serenity/JS-specific configuration
|
|
195
194
|
},
|
|
@@ -199,7 +198,7 @@ export const config = {
|
|
|
199
198
|
reporterOptions: [
|
|
200
199
|
'specDirectory=e2e'
|
|
201
200
|
],
|
|
202
|
-
|
|
201
|
+
|
|
203
202
|
// ... other Mocha-specific configuration
|
|
204
203
|
},
|
|
205
204
|
|
|
@@ -209,25 +208,39 @@ export const config = {
|
|
|
209
208
|
|
|
210
209
|
Learn more about supported [Mocha configuration options](https://serenity-js.org/api/mocha-adapter/interface/MochaConfig/).
|
|
211
210
|
|
|
211
|
+
## Documentation
|
|
212
|
+
|
|
213
|
+
- [API Reference](https://serenity-js.org/api/)
|
|
214
|
+
- [Screenplay Pattern Guide](https://serenity-js.org/handbook/design/screenplay-pattern/)
|
|
215
|
+
- [Serenity/JS Project Templates](https://serenity-js.org/handbook/project-templates/)
|
|
216
|
+
- [More examples and reference implementations](https://github.com/serenity-js/serenity-js/tree/main/examples)
|
|
217
|
+
- [Tutorial: First Web Scenario](https://serenity-js.org/handbook/tutorials/your-first-web-scenario/)
|
|
218
|
+
- [Tutorial: First API Scenario](https://serenity-js.org/handbook/tutorials/your-first-api-scenario/)
|
|
219
|
+
|
|
220
|
+
## Contributing
|
|
221
|
+
|
|
222
|
+
Contributions of all kinds are welcome! Get started with the [Contributing Guide](https://serenity-js.org/community/contributing/).
|
|
223
|
+
|
|
224
|
+
## Community
|
|
225
|
+
|
|
226
|
+
- [Community Chat](https://matrix.to/#/#serenity-js:gitter.im)
|
|
227
|
+
- [Discussions Forum](https://github.com/orgs/serenity-js/discussions)
|
|
228
|
+
- Visit the [💡How to... ?](https://github.com/orgs/serenity-js/discussions/categories/how-to) section for answers to common questions
|
|
212
229
|
|
|
213
|
-
|
|
230
|
+
If you enjoy using Serenity/JS, make sure to star ⭐️ [Serenity/JS on GitHub](https://github.com/serenity-js/serenity-js) to help others discover the framework!
|
|
214
231
|
|
|
215
|
-
|
|
232
|
+
## License
|
|
216
233
|
|
|
217
|
-
|
|
234
|
+
The Serenity/JS code base is licensed under the [Apache-2.0](https://opensource.org/license/apache-2-0) license,
|
|
235
|
+
while its documentation and the [Serenity/JS Handbook](https://serenity-js.org/handbook/) are licensed under the [Creative Commons BY-NC-SA 4.0 International](https://creativecommons.org/licenses/by-nc-sa/4.0/).
|
|
218
236
|
|
|
219
|
-
|
|
220
|
-
Follow [Serenity/JS on LinkedIn](https://www.linkedin.com/company/serenity-js),
|
|
221
|
-
subscribe to [Serenity/JS channel on YouTube](https://www.youtube.com/@serenity-js) and join the [Serenity/JS Community Chat](https://matrix.to/#/#serenity-js:gitter.im) to stay up to date!
|
|
222
|
-
Please also make sure to star ⭐️ [Serenity/JS on GitHub](https://github.com/serenity-js/serenity-js) to help others discover the framework!
|
|
237
|
+
See the [Serenity/JS License](https://serenity-js.org/legal/license/).
|
|
223
238
|
|
|
224
|
-
|
|
225
|
-
[](https://www.youtube.com/@serenity-js)
|
|
226
|
-
[](https://matrix.to/#/#serenity-js:gitter.im)
|
|
227
|
-
[](https://github.com/serenity-js/serenity-js)
|
|
239
|
+
## Support
|
|
228
240
|
|
|
229
|
-
|
|
241
|
+
Support ongoing development through [GitHub Sponsors](https://github.com/sponsors/serenity-js). Sponsors gain access to [Serenity/JS Playbooks](https://github.com/serenity-js/playbooks)
|
|
242
|
+
and priority help in the [Discussions Forum](https://github.com/orgs/serenity-js/discussions).
|
|
230
243
|
|
|
231
|
-
|
|
244
|
+
For corporate sponsorship or commercial support, please contact [Jan Molak](https://www.linkedin.com/in/janmolak/).
|
|
232
245
|
|
|
233
|
-
[](https://github.com/sponsors/serenity-js)
|
|
246
|
+
[](https://github.com/sponsors/serenity-js).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/mocha",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.37.0",
|
|
4
4
|
"description": "Serenity/JS test runner adapter for Mocha, enabling the use of the Screenplay Pattern in Mocha-based test suites and leveraging Serenity/JS reporting capabilities",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"node": "^20 || ^22 || ^24"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@serenity-js/core": "3.
|
|
53
|
+
"@serenity-js/core": "3.37.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"mocha": "^10.8.2 || ^11.0.1"
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"ts-node": "10.9.2",
|
|
66
66
|
"typescript": "5.9.3"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "dae146cd99a04f09b5926fb9d3205af562fa2927"
|
|
69
69
|
}
|