squally-reporter 0.2.1 → 0.2.2
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/dist/index.d.ts +1 -0
- package/dist/index.js +21 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -161,21 +161,38 @@ function formatConsoleOutput(result) {
|
|
|
161
161
|
}
|
|
162
162
|
class SquallyReporter {
|
|
163
163
|
constructor(options = {}) {
|
|
164
|
+
this.apiUrl = "";
|
|
165
|
+
this.apiKey = "";
|
|
166
|
+
// Missing/invalid config must never take down the caller's whole test
|
|
167
|
+
// suite over just a reporting integration - see the constructor below.
|
|
168
|
+
// Every onXxx hook checks this first and no-ops if it's false.
|
|
169
|
+
this.enabled = false;
|
|
164
170
|
this.startedAt = new Date();
|
|
165
171
|
this.results = [];
|
|
166
172
|
const apiUrl = options.apiUrl ?? process.env.SQUALLY_API_URL;
|
|
167
173
|
const apiKey = options.apiKey ?? process.env.SQUALLY_API_KEY;
|
|
168
174
|
if (!apiUrl || !apiKey) {
|
|
169
|
-
|
|
170
|
-
|
|
175
|
+
// Deliberately NOT thrown - a missing/wrong Squally API key must
|
|
176
|
+
// only disable reporting to Squally, not fail the caller's entire
|
|
177
|
+
// CI pipeline before a single test has even run. Warn loudly
|
|
178
|
+
// instead and continue as a no-op reporter.
|
|
179
|
+
console.warn("[squally-reporter] no API key configured, skipping report - set " +
|
|
180
|
+
"SQUALLY_API_URL/SQUALLY_API_KEY as env vars, or pass apiUrl/apiKey " +
|
|
181
|
+
"in playwright.config.ts");
|
|
182
|
+
return;
|
|
171
183
|
}
|
|
172
184
|
this.apiUrl = apiUrl.replace(/\/$/, ""); // strip trailing slash if present
|
|
173
185
|
this.apiKey = apiKey;
|
|
186
|
+
this.enabled = true;
|
|
174
187
|
}
|
|
175
188
|
onBegin(_config, _suite) {
|
|
189
|
+
if (!this.enabled)
|
|
190
|
+
return;
|
|
176
191
|
this.startedAt = new Date();
|
|
177
192
|
}
|
|
178
193
|
onTestEnd(test, result) {
|
|
194
|
+
if (!this.enabled)
|
|
195
|
+
return;
|
|
179
196
|
const error = result.errors[0];
|
|
180
197
|
this.results.push({
|
|
181
198
|
testName: test.titlePath().slice(1).join(" > "),
|
|
@@ -189,6 +206,8 @@ class SquallyReporter {
|
|
|
189
206
|
});
|
|
190
207
|
}
|
|
191
208
|
async onEnd(result) {
|
|
209
|
+
if (!this.enabled)
|
|
210
|
+
return;
|
|
192
211
|
// A run with 0 test results is meaningless for Squally's flakiness
|
|
193
212
|
// calculation and would just be dashboard clutter - regardless of why
|
|
194
213
|
// there were none (npx playwright test --list, an empty testDir, a
|