cypress-voice-plugin 1.0.4 → 2.0.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/README.md +16 -20
- package/cypress/e2e/combinedResultTime.cy.js +3 -3
- package/cypress/e2e/failedVoiceResult.cy.js +2 -2
- package/cypress/e2e/passedVoiceResult.cy.js +2 -2
- package/cypress/e2e/retriedVoiceResult.cy.js +3 -3
- package/cypress/e2e/testResultsOnly.cy.js +2 -2
- package/cypress/e2e/voiceTime.cy.js +2 -2
- package/index.js +15 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -39,16 +39,16 @@ import "cypress-voice-plugin";
|
|
|
39
39
|
|
|
40
40
|
## 🦺 Setup
|
|
41
41
|
|
|
42
|
-
Within `cypress open`, the voice plugin is enabled via a [Cypress
|
|
42
|
+
Within `cypress open`, beginning in plugin version `2.0.0`, the voice plugin is enabled via a [Cypress expose variable](https://docs.cypress.io/api/cypress-api/expose).
|
|
43
43
|
|
|
44
44
|
> [!NOTE]
|
|
45
45
|
> You can only enable a single value for `voiceResultType` at a time. `voiceResultType` and/or `voiceTime` can be enabled together or independently.
|
|
46
46
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
| `voiceResultType`
|
|
50
|
-
| `voiceResultType`
|
|
51
|
-
| `voiceTime`
|
|
47
|
+
| Expose variable | Value | Can this variable alone enable plugin? | Purpose | Sample Spoken Result |
|
|
48
|
+
| ----------------- | ------------ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
49
|
+
| `voiceResultType` | `"simple"` | ✅ Yes | High-level result of entire spec file run. | "Spec passed." |
|
|
50
|
+
| `voiceResultType` | `"detailed"` | ✅ Yes | In addition to what is provided by `"simple"`, the counts of tests passed, passed with retries, failed and skipped. | "Spec failed: 1 test passed, 2 tests failed, 1 test skipped." |
|
|
51
|
+
| `voiceTime` | `true` | ✅ Yes | The time of entire spec file run. | "Total time: 34 seconds" |
|
|
52
52
|
|
|
53
53
|
## 🏃♀️ Voice adjustments
|
|
54
54
|
|
|
@@ -64,42 +64,38 @@ As the plugin does not set a language itself, [`speechSynthesis` is able to dete
|
|
|
64
64
|
|
|
65
65
|
> If unset, the app's (i.e. the <html> lang value) lang will be used, or the user-agent default if that is unset too.
|
|
66
66
|
|
|
67
|
-
## 📕 Example
|
|
67
|
+
## 📕 Example Expose Variable Setups
|
|
68
68
|
|
|
69
|
-
The following options are suggestions of how to set the
|
|
69
|
+
The following options are suggestions of how to set the expose variable(s). A more comprehensive [guide on environment variable setting](https://docs.cypress.io/api/cypress-api/expose#Examples) can be found within official Cypress documentation.
|
|
70
70
|
|
|
71
|
-
### Setup using
|
|
71
|
+
### Setup using configuration file
|
|
72
72
|
|
|
73
|
-
Add environment variable(s) to
|
|
73
|
+
Add environment variable(s) to your Cypress configuration file.
|
|
74
74
|
|
|
75
75
|
Example:
|
|
76
76
|
|
|
77
77
|
```js
|
|
78
|
-
{
|
|
78
|
+
expose: {
|
|
79
79
|
"voiceTime": true,
|
|
80
80
|
"voiceResultType": "detailed",
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
### Setup using `--expose`
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
### Setup using `--env`
|
|
89
|
-
|
|
90
|
-
Alternatively, append the environment variable to the end of your `cypress open` cli command:
|
|
86
|
+
Alternatively, append the expose variable to the end of your `cypress open` cli command:
|
|
91
87
|
|
|
92
88
|
```shell
|
|
93
|
-
npx cypress open --
|
|
89
|
+
npx cypress open --expose voiceResultType=simple
|
|
94
90
|
```
|
|
95
91
|
|
|
96
92
|
Or, combine multiple variables in one command to hear both result and total run time:
|
|
97
93
|
|
|
98
94
|
```shell
|
|
99
|
-
npx cypress open --
|
|
95
|
+
npx cypress open --expose voiceResultType=detailed,voiceTime=true
|
|
100
96
|
```
|
|
101
97
|
|
|
102
|
-
From official Cypress docs, more information on the [`--
|
|
98
|
+
From official Cypress docs, more information on the [`--expose` method](https://docs.cypress.io/api/cypress-api/expose#CLI-Flags).
|
|
103
99
|
|
|
104
100
|
## TODO
|
|
105
101
|
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
describe("Voice result and time", () => {
|
|
5
5
|
it(
|
|
6
6
|
"Announces short passing test with result and time",
|
|
7
|
-
{
|
|
7
|
+
{ expose: { voiceResultType: "detailed", voiceTime: true } },
|
|
8
8
|
() => {
|
|
9
9
|
const synth = window.speechSynthesis;
|
|
10
10
|
synth.speak = (event) => {
|
|
11
11
|
const text = event.text;
|
|
12
12
|
expect(text).to.eq(
|
|
13
|
-
"Spec passed: 1 test passed. Total time: Less than 1 second."
|
|
13
|
+
"Spec passed: 1 test passed. Total time: Less than 1 second.",
|
|
14
14
|
);
|
|
15
15
|
};
|
|
16
|
-
}
|
|
16
|
+
},
|
|
17
17
|
);
|
|
18
18
|
});
|
|
@@ -5,7 +5,7 @@ describe("Failing voice", () => {
|
|
|
5
5
|
it(
|
|
6
6
|
"Announces failed test without time",
|
|
7
7
|
{
|
|
8
|
-
|
|
8
|
+
expose: {
|
|
9
9
|
voiceResultType: "simple",
|
|
10
10
|
},
|
|
11
11
|
},
|
|
@@ -25,6 +25,6 @@ describe("Failing voice", () => {
|
|
|
25
25
|
|
|
26
26
|
expect(char).to.eq("Spec failed.");
|
|
27
27
|
};
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
29
|
);
|
|
30
30
|
});
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
describe("Passing voice", () => {
|
|
5
5
|
it(
|
|
6
6
|
"Announces passed test",
|
|
7
|
-
{
|
|
7
|
+
{ expose: { voiceResultType: "simple", voiceTime: false } },
|
|
8
8
|
() => {
|
|
9
9
|
const synth = window.speechSynthesis;
|
|
10
10
|
synth.speak = (event) => {
|
|
@@ -12,6 +12,6 @@ describe("Passing voice", () => {
|
|
|
12
12
|
|
|
13
13
|
expect(char).to.eq("Spec passed.");
|
|
14
14
|
};
|
|
15
|
-
}
|
|
15
|
+
},
|
|
16
16
|
);
|
|
17
17
|
});
|
|
@@ -6,7 +6,7 @@ describe("Voice on retries", () => {
|
|
|
6
6
|
"Announces short retried test",
|
|
7
7
|
{
|
|
8
8
|
retries: 1,
|
|
9
|
-
|
|
9
|
+
expose: { voiceResultType: "detailed", voiceTime: false },
|
|
10
10
|
},
|
|
11
11
|
() => {
|
|
12
12
|
// this test will fail on first try, but pass on second
|
|
@@ -18,10 +18,10 @@ describe("Voice on retries", () => {
|
|
|
18
18
|
synth.speak = (event) => {
|
|
19
19
|
const text = event.text;
|
|
20
20
|
expect(text).to.eq(
|
|
21
|
-
"Spec passed with retries: 1 test passed with retries."
|
|
21
|
+
"Spec passed with retries: 1 test passed with retries.",
|
|
22
22
|
);
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
26
|
);
|
|
27
27
|
});
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
describe("Test results only", () => {
|
|
5
5
|
it(
|
|
6
6
|
"Announces short passing test with only test results",
|
|
7
|
-
{
|
|
7
|
+
{ expose: { voiceResultType: "detailed", voiceTime: false } },
|
|
8
8
|
() => {
|
|
9
9
|
const synth = window.speechSynthesis;
|
|
10
10
|
synth.speak = (event) => {
|
|
11
11
|
const text = event.text;
|
|
12
12
|
expect(text).to.eq("Spec passed: 1 test passed.");
|
|
13
13
|
};
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
);
|
|
16
16
|
});
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
describe("Voice time", () => {
|
|
5
5
|
it(
|
|
6
6
|
"Announces short passing test with only time",
|
|
7
|
-
{
|
|
7
|
+
{ expose: { voiceTime: true, voiceResultType: false } },
|
|
8
8
|
() => {
|
|
9
9
|
const synth = window.speechSynthesis;
|
|
10
10
|
synth.speak = (event) => {
|
|
11
11
|
const text = event.text;
|
|
12
12
|
expect(text).to.eq("Total time: Less than 1 second.");
|
|
13
13
|
};
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
);
|
|
16
16
|
});
|
package/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import { addStyles } from "./addStyles";
|
|
|
2
2
|
|
|
3
3
|
// Voice plugin to announce spec result when Cypress runner UI is open (cypress open)
|
|
4
4
|
if (
|
|
5
|
-
(Cypress.
|
|
6
|
-
Cypress.
|
|
7
|
-
Cypress.
|
|
5
|
+
(Cypress.expose("voiceResultType") === "simple" ||
|
|
6
|
+
Cypress.expose("voiceResultType") === "detailed" ||
|
|
7
|
+
Cypress.expose("voiceTime")) &&
|
|
8
8
|
Cypress.config("isInteractive")
|
|
9
9
|
) {
|
|
10
10
|
// Cancel any ongoing spoken results when a new spec is selected mid-speech
|
|
@@ -199,10 +199,10 @@ if (
|
|
|
199
199
|
|
|
200
200
|
if (currentTestIsLast) {
|
|
201
201
|
waitForElement(".restart", () => {
|
|
202
|
-
// Announce spec run result and/or total time based on provided
|
|
202
|
+
// Announce spec run result and/or total time based on provided Cypress.expose() variable(s)
|
|
203
203
|
if (
|
|
204
|
-
Cypress.
|
|
205
|
-
!Cypress.
|
|
204
|
+
Cypress.expose("voiceResultType") === "simple" &&
|
|
205
|
+
!Cypress.expose("voiceTime")
|
|
206
206
|
) {
|
|
207
207
|
const message = new SpeechSynthesisUtterance(
|
|
208
208
|
`Spec ${
|
|
@@ -214,9 +214,9 @@ if (
|
|
|
214
214
|
message.volume = volume.value;
|
|
215
215
|
speechSynthesis.speak(message);
|
|
216
216
|
} else if (
|
|
217
|
-
Cypress.
|
|
218
|
-
!(Cypress.
|
|
219
|
-
!(Cypress.
|
|
217
|
+
Cypress.expose("voiceTime") &&
|
|
218
|
+
!(Cypress.expose("voiceResultType") === "simple") &&
|
|
219
|
+
!(Cypress.expose("voiceResultType") === "detailed")
|
|
220
220
|
) {
|
|
221
221
|
const message = new SpeechSynthesisUtterance(
|
|
222
222
|
"Total time: " + specTime(),
|
|
@@ -226,8 +226,8 @@ if (
|
|
|
226
226
|
message.volume = volume.value;
|
|
227
227
|
speechSynthesis.speak(message);
|
|
228
228
|
} else if (
|
|
229
|
-
Cypress.
|
|
230
|
-
!Cypress.
|
|
229
|
+
Cypress.expose("voiceResultType") === "detailed" &&
|
|
230
|
+
!Cypress.expose("voiceTime")
|
|
231
231
|
) {
|
|
232
232
|
const message = new SpeechSynthesisUtterance(
|
|
233
233
|
`Spec ${
|
|
@@ -243,8 +243,8 @@ if (
|
|
|
243
243
|
message.volume = volume.value;
|
|
244
244
|
speechSynthesis.speak(message);
|
|
245
245
|
} else if (
|
|
246
|
-
Cypress.
|
|
247
|
-
Cypress.
|
|
246
|
+
Cypress.expose("voiceResultType") === "simple" &&
|
|
247
|
+
Cypress.expose("voiceTime")
|
|
248
248
|
) {
|
|
249
249
|
const message = new SpeechSynthesisUtterance(
|
|
250
250
|
`Spec ${
|
|
@@ -260,8 +260,8 @@ if (
|
|
|
260
260
|
message.volume = volume.value;
|
|
261
261
|
speechSynthesis.speak(message);
|
|
262
262
|
} else if (
|
|
263
|
-
Cypress.
|
|
264
|
-
Cypress.
|
|
263
|
+
Cypress.expose("voiceResultType") === "detailed" &&
|
|
264
|
+
Cypress.expose("voiceTime")
|
|
265
265
|
) {
|
|
266
266
|
const message = new SpeechSynthesisUtterance(
|
|
267
267
|
`Spec ${
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cypress-voice-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Voice plugin for the Cypress Test Runner",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"voice"
|
|
14
14
|
],
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"cypress": "^15.
|
|
16
|
+
"cypress": "^15.10.0"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"registry": "https://registry.npmjs.org/"
|