@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.
Files changed (3) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +97 -84
  3. 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
- [![Follow Serenity/JS on LinkedIn](https://img.shields.io/badge/Follow-Serenity%2FJS%20-0077B5?logo=linkedin)](https://www.linkedin.com/company/serenity-js)
4
- [![Watch Serenity/JS on YouTube](https://img.shields.io/badge/Watch-@serenity--js-E62117?logo=youtube)](https://www.youtube.com/@serenity-js)
5
- [![Join Serenity/JS Community Chat](https://img.shields.io/badge/Chat-Serenity%2FJS%20Community-FBD30B?logo=matrix)](https://matrix.to/#/#serenity-js:gitter.im)
6
- [![Support Serenity/JS on GitHub](https://img.shields.io/badge/Support-@serenity--js-703EC8?logo=github)](https://github.com/sponsors/serenity-js)
3
+ [![NPM Version](https://badge.fury.io/js/%40serenity-js%2Fmocha.svg)](https://badge.fury.io/js/%40serenity-js%2Fmocha)
4
+ [![Build Status](https://github.com/serenity-js/serenity-js/actions/workflows/main.yaml/badge.svg?branch=main)](https://github.com/serenity-js/serenity-js/actions)
5
+ [![Maintainability](https://qlty.sh/gh/serenity-js/projects/serenity-js/maintainability.svg)](https://qlty.sh/gh/serenity-js/projects/serenity-js)
6
+ [![Code Coverage](https://qlty.sh/gh/serenity-js/projects/serenity-js/coverage.svg)](https://qlty.sh/gh/serenity-js/projects/serenity-js)
7
+ [![Contributors](https://img.shields.io/github/contributors/serenity-js/serenity-js.svg)](https://github.com/serenity-js/serenity-js/graphs/contributors)
8
+ [![Known Vulnerabilities](https://snyk.io/test/npm/@serenity-js/mocha/badge.svg)](https://snyk.io/test/npm/@serenity-js/mocha)
9
+ [![GitHub stars](https://img.shields.io/github/stars/serenity-js/serenity-js?style=flat)](https://github.com/serenity-js/serenity-js)
7
10
 
8
- [Serenity/JS](https://serenity-js.org) is an innovative open-source framework designed to make acceptance and regression testing
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
- ⭐️ Get started with Serenity/JS!
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
- [`@serenity-js/mocha`](https://serenity-js.org/api/mocha/) contains an adapter you register with [Mocha test runner](https://mochajs.org/) to enable integration between Mocha and Serenity/JS.
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
- ### Installation
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@8.x
22
+ npm install --save-dev @serenity-js/core @serenity-js/console-reporter @serenity-js/mocha
33
23
  ```
34
24
 
35
- Install the `@serenity-js/mocha` adapter, as well as `@serenity-js/core` and any [Serenity/JS reporting modules](https://serenity-js.org/api/console-reporter/) you'd like to use, for example [`@serenity-js/console-reporter`](https://serenity-js.org/api/console-reporter/):
25
+ See the [Serenity/JS Installation Guide](https://serenity-js.org/handbook/installation/).
36
26
 
37
- ```sh
38
- npm install --save-dev @serenity-js/core @serenity-js/console-reporter @serenity-js/mocha
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 `setup.js` file (for example under `spec/support/setup.js`, but you can use any location you like):
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/setup.js
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
- ConsoleReporter.forDarkTerminals(),
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/setup.js \
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
- "target": "es2018",
87
- "lib": ["es2018"],
88
- "module": "commonjs"
87
+ "lib": ["ES2023"],
88
+ "module": "nodenext",
89
+ "target": "ES2023"
89
90
  }
90
91
  }
91
92
  ```
92
93
 
93
- Create a `setup.ts` file (for example under `spec/support/setup.ts`, but you can use any location you like):
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
- crew: [
103
- ConsoleReporter.forDarkTerminals(),
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
- Please note that you can use `.mocharc.yml` [configuration file](https://mochajs.org/#configuring-mocha-nodejs)
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/setup.ts
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 Protractor
142
+ ### Using Serenity/JS Mocha with WebdriverIO
144
143
 
145
- Configure your Protractor installation as per instructions in [`@serenity-js/protractor`](https://serenity-js.org/api/protractor/) module.
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 `protractor.conf.js` file to [configure Mocha](https://serenity-js.org/api/mocha-adapter/interface/MochaConfig/) if needed:
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="protractor.conf.js"
150
- // protractor.conf.js
148
+ ```typescript title="wdio.conf.ts"
149
+ // wdio.conf.ts
151
150
 
152
- exports.config = {
153
- // Tell Protractor to use the Serenity/JS framework adapter
154
- framework: 'custom',
155
- frameworkPath: require.resolve('@serenity-js/protractor/adapter'),
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 WebdriverIO
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
- 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:
179
+ Configure your Protractor installation as per instructions in [`@serenity-js/protractor`](https://serenity-js.org/api/protractor/) module.
182
180
 
183
- ```typescript title="wdio.conf.ts"
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
- export const config = {
187
- // Tell WebdriverIO to use the Serenity/JS framework adapter
188
- framework: '@serenity-js/webdriverio',
183
+ ```typescript title="protractor.conf.js"
184
+ // protractor.conf.js
189
185
 
190
- // Serenity/JS configuration
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
- ### Example projects
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
- Study [Serenity/JS example projects](https://github.com/serenity-js/serenity-js/tree/main/examples) to learn more.
232
+ ## License
216
233
 
217
- ## 📣 Stay up to date
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
- New features, tutorials, and demos are coming soon!
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
- [![Follow Serenity/JS on LinkedIn](https://img.shields.io/badge/Follow-Serenity%2FJS%20-0077B5?logo=linkedin)](https://www.linkedin.com/company/serenity-js)
225
- [![Watch Serenity/JS on YouTube](https://img.shields.io/badge/Watch-@serenity--js-E62117?logo=youtube)](https://www.youtube.com/@serenity-js)
226
- [![Join Serenity/JS Community Chat](https://img.shields.io/badge/Chat-Serenity%2FJS%20Community-FBD30B?logo=matrix)](https://matrix.to/#/#serenity-js:gitter.im)
227
- [![GitHub stars](https://img.shields.io/github/stars/serenity-js/serenity-js?label=Serenity%2FJS&logo=github&style=badge)](https://github.com/serenity-js/serenity-js)
239
+ ## Support
228
240
 
229
- ## 💛 Support Serenity/JS
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
- If you appreciate all the effort that goes into making sophisticated tools easy to work with, please support our work and become a Serenity/JS GitHub Sponsor today!
244
+ For corporate sponsorship or commercial support, please contact [Jan Molak](https://www.linkedin.com/in/janmolak/).
232
245
 
233
- [![GitHub Sponsors](https://img.shields.io/badge/Support%20@serenity%2FJS-703EC8?style=for-the-badge&logo=github&logoColor=white)](https://github.com/sponsors/serenity-js)
246
+ [![GitHub Sponsors](https://img.shields.io/badge/Support%20@serenity%2FJS-703EC8?style=for-the-badge&logo=github&logoColor=white)](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.36.1",
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.36.1"
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": "d13abbfcd6255c6f9466394d4efa1e808907a71f"
68
+ "gitHead": "dae146cd99a04f09b5926fb9d3205af562fa2927"
69
69
  }