hass-taste-test 0.0.14 → 0.0.15

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/README.md +19 -0
  2. package/lib/index.js +10 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -83,6 +83,25 @@ it('Custom Card', async () => {
83
83
 
84
84
  You may now consider customizing your Jest configuration using (`npx jest --init`), [learning more about Jest](https://jestjs.io/docs/getting-started), and browsing through the [examples](https://github.com/rianadon/hass-taste-test/tree/main/test)
85
85
 
86
+ ## Developing
87
+
88
+ If you wish to make changes to this repository, follow these instructions. Tests are run with `ts-node`, so no recompilation of typescript is necessary.
89
+
90
+ 1. Install dependencies
91
+
92
+ ```bash
93
+ npm install
94
+ npx playwright install-deps
95
+ ```
96
+
97
+ 2. Run tests
98
+
99
+ ```bash
100
+ npm run test
101
+ ```
102
+
103
+ To update snapshots, use `npx jest -u` and `npx ava -u`.
104
+
86
105
  ### But I want to write my tests in TypeScript
87
106
 
88
107
  Install [`ts-jest`](https://kulshekhar.github.io/ts-jest/docs/getting-started/installation/), `@types/jest`, and `@types/jest-image-snapshot` along with the other dependencies, then run `npx ts-jest config:init` to configure Jest for Typescript. Browse the [examples](https://github.com/rianadon/hass-taste-test/tree/main/test) for example tests; they are all written in TypeScript.
package/lib/index.js CHANGED
@@ -110,8 +110,16 @@ class HomeAssistant {
110
110
  console.error(`----\nHome Assistant is having trouble starting. This is likely due to a problem with your virtual environment; try removing the venv folder at ${this.venvDir} and re-running hass-taste-test\n---`);
111
111
  throw e;
112
112
  });
113
- while (!(await this.isUp()))
114
- await sleep();
113
+ await new Promise(async (resolve, reject) => {
114
+ // Wait for Home Assistant to start, but quit early if the process exits
115
+ this.process.on('close', (code) => {
116
+ if (code != 0)
117
+ reject(new Error(`Home assistant exited with code ${code}`));
118
+ });
119
+ while (!(await this.isUp()))
120
+ await sleep();
121
+ resolve();
122
+ });
115
123
  await this.onboard();
116
124
  }
117
125
  /** Write configuration.yaml */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hass-taste-test",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "Integration testing for Home Assistant cards",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {