squally-reporter 0.2.0 → 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 CHANGED
@@ -6,6 +6,7 @@ interface SquallyReporterOptions {
6
6
  export default class SquallyReporter implements Reporter {
7
7
  private apiUrl;
8
8
  private apiKey;
9
+ private enabled;
9
10
  private startedAt;
10
11
  private results;
11
12
  constructor(options?: SquallyReporterOptions);
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
- throw new Error("[squally-reporter] Missing config: set SQUALLY_API_URL and " +
170
- "SQUALLY_API_KEY as env vars, or pass apiUrl/apiKey in playwright.config.ts");
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,15 @@ class SquallyReporter {
189
206
  });
190
207
  }
191
208
  async onEnd(result) {
209
+ if (!this.enabled)
210
+ return;
211
+ // A run with 0 test results is meaningless for Squally's flakiness
212
+ // calculation and would just be dashboard clutter - regardless of why
213
+ // there were none (npx playwright test --list, an empty testDir, a
214
+ // --grep filter that matched nothing). Bail out before building/
215
+ // sending anything.
216
+ if (this.results.length === 0)
217
+ return;
192
218
  const resolvedRevision = resolveTestedRevision();
193
219
  const payload = {
194
220
  branch: detectBranch(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squally-reporter",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Playwright reporter that sends test results to your Squally dashboard.",
5
5
  "author": "Squally <squally.dev@gmail.com>",
6
6
  "keywords": [