@honeybadger-io/js 6.4.3 → 6.5.1

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
@@ -25,10 +25,32 @@ However, since the package is isomorphic, TypeScript users will likely be writin
25
25
 
26
26
  ### Tests
27
27
  1. To run unit tests for both browser and server builds: `npm test`. Or separately: `npm run test:browser`, `npm run test:server`.
28
- 2. To run integration tests across all supported platforms, set up a [BrowserStack](https://www.browserstack.com/)
29
- account and use `BROWSERSTACK_USERNAME=your_username BROWSERSTACK_ACCESS_KEY=your-access-key npm run test:integration`.
28
+ 2. To run integration tests across all supported platforms, see [End-to-end tests with Playwright and Browserstack](#end-to-end-tests-with-playwright-and-browserstack-optional).
30
29
  3. To test the TypeScript type definitions: `npm run tsd`.
31
30
 
31
+ #### End-to-end tests with Playwright and Browserstack (optional)
32
+ We use [Playwright](https://playwright.dev) to run integration tests in a real browser.
33
+ The config file is at `test/e2e/playwright.config.ts`.
34
+ To run these tests locally, you'll need to install the browsers you want to test with.
35
+ Open `test/e2e/browsers.ts` and enable the browsers you want to test with.
36
+ Then, run `npx playwright install --with-deps` to install the browsers.
37
+ Lastly, run `npm run test:integration`.
38
+ Additionally, if you want to run the tests on Browserstack:
39
+ - enable Browserstack browsers in `browsers.ts`,
40
+ - set up a [BrowserStack](https://www.browserstack.com/) account and
41
+ - use `BROWSERSTACK_USERNAME=your_username BROWSERSTACK_ACCESS_KEY=your-access-key npm run test:integration`.
42
+
43
+ ##### Architecture
44
+ Inside `./test/e2e`, you will find a `server.js` file that runs a simple nodejs http server.
45
+ This server is used to serve the test page, along with other static assets and to receive the error reports from the browser.
46
+ The server is automatically started and stopped by Playwright, as you can see at the bottom of the `./test/e2e/playwright.config.ts` file.
47
+ The test page is found in `./test/e2e/sandbox.html`.
48
+ All tests are found in `./test/e2e/integration.spec.ts`.
49
+ Two more configuration files, `./test/e2e/global-setup.ts` and `./test/e2e/global-teardown.ts` are used to start and stop
50
+ a local browserstack executable, needed to run the tests on Browserstack. This executable will only be executed if you are testing on Browserstack.
51
+ Finally, the `./test/e2e/browserstack.config.ts` file contains the configuration and helper functions to run the tests on Browserstack.
52
+
53
+
32
54
  ## Releasing
33
55
 
34
56
  This package comes with a `postpublish` script (`scripts/release-cdn.sh`)
@@ -9,6 +9,7 @@ declare class Honeybadger extends Client {
9
9
  factory(opts?: Partial<Types.BrowserConfig>): this;
10
10
  checkIn(_id: string): Promise<void>;
11
11
  showUserFeedbackForm(options?: Types.UserFeedbackFormOptions): Promise<void>;
12
+ private appendUserFeedbackScriptTag;
12
13
  private isUserFeedbackScriptUrlAlreadyVisible;
13
14
  private getUserFeedbackSubmitUrl;
14
15
  }
@@ -857,7 +857,7 @@
857
857
  this.__notifier = {
858
858
  name: '@honeybadger-io/core',
859
859
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
860
- version: '6.4.3'
860
+ version: '6.5.1'
861
861
  };
862
862
  this.config = __assign({ apiKey: null, endpoint: 'https://api.honeybadger.io', environment: null, hostname: null, projectRoot: null, component: null, action: null, revision: null, reportData: null, breadcrumbsEnabled: true, maxBreadcrumbs: 40, maxObjectDepth: 8, logger: console, developmentEnvironments: ['dev', 'development', 'test'], debug: false, tags: null, enableUncaught: true, enableUnhandledRejection: true, afterUncaught: function () { return true; }, filters: ['creditcard', 'password'], __plugins: [] }, opts);
863
863
  this.__initStore();
@@ -2175,7 +2175,7 @@
2175
2175
  Honeybadger.prototype.showUserFeedbackForm = function (options) {
2176
2176
  if (options === void 0) { options = {}; }
2177
2177
  return __awaiter(this, void 0, void 0, function () {
2178
- var global, script;
2178
+ var global;
2179
2179
  return __generator(this, function (_a) {
2180
2180
  if (!this.config || !this.config.apiKey) {
2181
2181
  this.logger.debug('Client not initialized');
@@ -2195,17 +2195,21 @@
2195
2195
  return [2 /*return*/];
2196
2196
  }
2197
2197
  global['honeybadgerUserFeedbackOptions'] = __assign(__assign({}, options), { apiKey: this.config.apiKey, endpoint: this.config.userFeedbackEndpoint, noticeId: this.__lastNoticeId });
2198
- script = global.document.createElement('script');
2199
- script.setAttribute('src', this.getUserFeedbackSubmitUrl());
2200
- script.setAttribute('async', 'true');
2201
- if (options.onLoad) {
2202
- script.onload = options.onLoad;
2203
- }
2204
- (global.document.head || global.document.body).appendChild(script);
2198
+ this.appendUserFeedbackScriptTag(global, options);
2205
2199
  return [2 /*return*/];
2206
2200
  });
2207
2201
  });
2208
2202
  };
2203
+ Honeybadger.prototype.appendUserFeedbackScriptTag = function (window, options) {
2204
+ if (options === void 0) { options = {}; }
2205
+ var script = window.document.createElement('script');
2206
+ script.setAttribute('src', this.getUserFeedbackSubmitUrl());
2207
+ script.setAttribute('async', 'true');
2208
+ if (options.onLoad) {
2209
+ script.onload = options.onLoad;
2210
+ }
2211
+ (commonjsGlobal.document.head || commonjsGlobal.document.body).appendChild(script);
2212
+ };
2209
2213
  Honeybadger.prototype.isUserFeedbackScriptUrlAlreadyVisible = function () {
2210
2214
  var global = (0, util_1.globalThisOrWindow)();
2211
2215
  var feedbackScriptUrl = this.getUserFeedbackSubmitUrl();
@@ -2329,7 +2333,7 @@
2329
2333
  var NOTIFIER = {
2330
2334
  name: '@honeybadger-io/js',
2331
2335
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
2332
- version: '6.4.3'
2336
+ version: '6.5.1'
2333
2337
  };
2334
2338
  singleton.setNotifier(NOTIFIER);
2335
2339
  var core_2 = src;