cypress-voice-plugin 1.0.4 → 2.1.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 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 environment variable](https://docs.cypress.io/guides/guides/environment-variables).
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
- | Environment 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" |
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 Environment Variable Setups
67
+ ## 📕 Example Expose Variable Setups
68
68
 
69
- The following options are suggestions of how to set the environment variable(s). A more comprehensive [guide on environment variable setting](https://docs.cypress.io/guides/guides/environment-variables#Setting) can be found within official Cypress documentation.
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 `cypress.env.json`
71
+ ### Setup using configuration file
72
72
 
73
- Add environment variable(s) to a created `cypress.env.json` file.
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
- This is a useful method for handling local use of this plugin, particularly if you add `cypress.env.json` to your `.gitignore` file. This way, enabling the plugin functionality via environment variable can be different for each developer machine rather than committed to the remote repository.
84
+ ### Setup using `--expose`
85
85
 
86
- From official Cypress docs, more information on the [`cypress.env.json` method](https://docs.cypress.io/guides/guides/environment-variables#Option-2-cypressenvjson).
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 --env voiceResultType=simple
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 --env voiceResultType=detailed,voiceTime=true
95
+ npx cypress open --expose voiceResultType=detailed,voiceTime=true
100
96
  ```
101
97
 
102
- From official Cypress docs, more information on the [`--env` method](https://docs.cypress.io/guides/guides/environment-variables#Option-4---env).
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
- { env: { voiceResultType: "detailed", voiceTime: true } },
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
- env: {
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
- { env: { voiceResultType: "simple", voiceTime: false } },
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
- env: { voiceResultType: "detailed", voiceTime: false },
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
- { env: { voiceResultType: "detailed", voiceTime: false } },
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
- { env: { voiceTime: true, voiceResultType: false } },
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.env("voiceResultType") === "simple" ||
6
- Cypress.env("voiceResultType") === "detailed" ||
7
- Cypress.env("voiceTime")) &&
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 environment variable(s)
202
+ // Announce spec run result and/or total time based on provided Cypress.expose() variable(s)
203
203
  if (
204
- Cypress.env("voiceResultType") === "simple" &&
205
- !Cypress.env("voiceTime")
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.env("voiceTime") &&
218
- !(Cypress.env("voiceResultType") === "simple") &&
219
- !(Cypress.env("voiceResultType") === "detailed")
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.env("voiceResultType") === "detailed" &&
230
- !Cypress.env("voiceTime")
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.env("voiceResultType") === "simple" &&
247
- Cypress.env("voiceTime")
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.env("voiceResultType") === "detailed" &&
264
- Cypress.env("voiceTime")
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": "1.0.4",
3
+ "version": "2.1.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.8.2"
16
+ "cypress": "^15.11.0"
17
17
  },
18
18
  "publishConfig": {
19
19
  "registry": "https://registry.npmjs.org/"