@axe-core/watcher 2.0.0 → 2.1.1-next.293a245f

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 (48) hide show
  1. package/dist/Controller.d.ts +9 -6
  2. package/dist/Controller.js +102 -139
  3. package/dist/Controller.js.map +1 -1
  4. package/dist/cypress.d.ts +1 -1
  5. package/dist/cypress.js +8 -37
  6. package/dist/cypress.js.map +1 -1
  7. package/dist/cypressCommands.d.ts +8 -5
  8. package/dist/cypressCommands.js +126 -116
  9. package/dist/cypressCommands.js.map +1 -1
  10. package/dist/git.d.ts +2 -0
  11. package/dist/git.js +31 -22
  12. package/dist/git.js.map +1 -1
  13. package/dist/index.d.ts +3 -2
  14. package/dist/index.js +8 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/playwright.d.ts +6 -4
  17. package/dist/playwright.js +17 -82
  18. package/dist/playwright.js.map +1 -1
  19. package/dist/playwrightTest.d.ts +16 -0
  20. package/dist/playwrightTest.js +74 -0
  21. package/dist/playwrightTest.js.map +1 -0
  22. package/dist/playwrightWrapping.d.ts +2 -8
  23. package/dist/playwrightWrapping.js +212 -491
  24. package/dist/playwrightWrapping.js.map +1 -1
  25. package/dist/puppeteer.d.ts +3 -3
  26. package/dist/puppeteer.js +18 -92
  27. package/dist/puppeteer.js.map +1 -1
  28. package/dist/puppeteerWrapping.d.ts +14 -0
  29. package/dist/puppeteerWrapping.js +426 -0
  30. package/dist/puppeteerWrapping.js.map +1 -0
  31. package/dist/util.d.ts +12 -0
  32. package/dist/util.js +69 -45
  33. package/dist/util.js.map +1 -1
  34. package/dist/validateApiKey.js +6 -7
  35. package/dist/validateApiKey.js.map +1 -1
  36. package/dist/wdio.d.ts +5 -2
  37. package/dist/wdio.js +60 -147
  38. package/dist/wdio.js.map +1 -1
  39. package/dist/webdriver.d.ts +3 -3
  40. package/dist/webdriver.js +25 -85
  41. package/dist/webdriver.js.map +1 -1
  42. package/dist/webdriverWrapping.d.ts +7 -0
  43. package/dist/webdriverWrapping.js +131 -0
  44. package/dist/webdriverWrapping.js.map +1 -0
  45. package/extension/background.js +1 -1
  46. package/extension/content.js +1 -1
  47. package/extension/manifest.json +2 -3
  48. package/package.json +7 -7
@@ -1,30 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -34,33 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
34
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
35
9
  });
36
10
  };
37
- var __generator = (this && this.__generator) || function (thisArg, body) {
38
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
- function verb(n) { return function (v) { return step([n, v]); }; }
41
- function step(op) {
42
- if (f) throw new TypeError("Generator is already executing.");
43
- while (_) try {
44
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
- if (y = 0, t) op = [op[0] & 2, t.value];
46
- switch (op[0]) {
47
- case 0: case 1: t = op; break;
48
- case 4: _.label++; return { value: op[1], done: false };
49
- case 5: _.label++; y = op[1]; op = [0]; continue;
50
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
- default:
52
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
- if (t[2]) _.ops.pop();
57
- _.trys.pop(); continue;
58
- }
59
- op = body.call(thisArg, _);
60
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
- }
63
- };
64
11
  var __rest = (this && this.__rest) || function (s, e) {
65
12
  var t = {};
66
13
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -77,9 +24,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
77
24
  };
78
25
  Object.defineProperty(exports, "__esModule", { value: true });
79
26
  exports.wrapPlaywright = exports.PlaywrightController = exports.playwrightConfig = void 0;
80
- var util_1 = require("./util");
81
- var Controller_1 = __importDefault(require("./Controller"));
82
- var playwrightWrapping_1 = require("./playwrightWrapping");
27
+ const util_1 = require("./util");
28
+ const Controller_1 = __importDefault(require("./Controller"));
29
+ const playwrightWrapping_1 = require("./playwrightWrapping");
83
30
  Object.defineProperty(exports, "wrapPlaywright", { enumerable: true, get: function () { return playwrightWrapping_1.wrapBrowserContext; } });
84
31
  /**
85
32
  * Creates a Playwright config that uses axe extension
@@ -87,40 +34,28 @@ Object.defineProperty(exports, "wrapPlaywright", { enumerable: true, get: functi
87
34
  * @param opts Playwright config to extend
88
35
  */
89
36
  function playwrightConfig(opts) {
90
- var axe = opts.axe, config = __rest(opts, ["axe"]);
91
- var _a = config.args, args = _a === void 0 ? [] : _a;
37
+ const { axe } = opts, config = __rest(opts, ["axe"]);
38
+ let { args = [] } = config;
92
39
  (0, util_1.writeVariables)(axe);
93
40
  if (config.headless) {
94
41
  throw new util_1.HeadlessNotSupportedError();
95
42
  }
96
43
  args = args.concat(util_1.extensionArgs);
97
- return __assign(__assign({}, config), { headless: false, args: args });
44
+ return Object.assign(Object.assign({}, config), { headless: false, args });
98
45
  }
99
46
  exports.playwrightConfig = playwrightConfig;
100
- var PlaywrightController = /** @class */ (function (_super) {
101
- __extends(PlaywrightController, _super);
102
- function PlaywrightController(driver) {
103
- var _this = _super.call(this) || this;
104
- _this.driver = driver;
105
- return _this;
47
+ class PlaywrightController extends Controller_1.default {
48
+ constructor(driver) {
49
+ super();
50
+ this.driver = driver;
106
51
  }
107
- PlaywrightController.prototype.executeScript = function (fn) {
108
- var args = [];
109
- for (var _i = 1; _i < arguments.length; _i++) {
110
- args[_i - 1] = arguments[_i];
111
- }
112
- return __awaiter(this, void 0, void 0, function () {
113
- return __generator(this, function (_a) {
114
- switch (_a.label) {
115
- case 0: return [4 /*yield*/, this.driver.evaluate(fn, args)];
116
- case 1:
117
- _a.sent();
118
- return [2 /*return*/];
119
- }
120
- });
52
+ executeScript(fn, ...args) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const [arg] = args || [];
55
+ const result = yield this.driver.evaluate(fn, arg);
56
+ return result;
121
57
  });
122
- };
123
- return PlaywrightController;
124
- }(Controller_1.default));
58
+ }
59
+ }
125
60
  exports.PlaywrightController = PlaywrightController;
126
61
  //# sourceMappingURL=playwright.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"playwright.js","sourceRoot":"","sources":["../src/playwright.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+BAKe;AACf,4DAAqC;AACrC,2DAAyD;AA4C1B,+FA5CtB,uCAAkB,OA4CkB;AA1C7C;;;;GAIG;AAEH,SAAgB,gBAAgB,CAC9B,IAAmC;IAE3B,IAAA,GAAG,GAAgB,IAAI,IAApB,EAAK,MAAM,UAAK,IAAI,EAAzB,OAAkB,CAAF,CAAS;IACzB,IAAA,KAAc,MAAM,KAAX,EAAT,IAAI,mBAAG,EAAE,KAAA,CAAW;IAC1B,IAAA,qBAAc,EAAC,GAAG,CAAC,CAAA;IAEnB,IAAI,MAAM,CAAC,QAAQ,EAAE;QACnB,MAAM,IAAI,gCAAyB,EAAE,CAAA;KACtC;IAED,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAa,CAAC,CAAA;IAEjC,6BACK,MAAM,KACT,QAAQ,EAAE,KAAK,EACf,IAAI,MAAA,IACL;AACH,CAAC;AAlBD,4CAkBC;AAED;IAA0C,wCAAU;IAGlD,8BAAY,MAAY;QAAxB,YACE,iBAAO,SAER;QADC,KAAI,CAAC,MAAM,GAAG,MAAM,CAAA;;IACtB,CAAC;IAEe,4CAAa,GAA7B,UACE,EAAkC;QAClC,cAAkB;aAAlB,UAAkB,EAAlB,qBAAkB,EAAlB,IAAkB;YAAlB,6BAAkB;;;;;4BAElB,qBAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,EAAA;;wBAApC,SAAoC,CAAA;;;;;KACrC;IACH,2BAAC;AAAD,CAAC,AAdD,CAA0C,oBAAU,GAcnD;AAdY,oDAAoB"}
1
+ {"version":3,"file":"playwright.js","sourceRoot":"","sources":["../src/playwright.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iCAKe;AACf,8DAAqC;AACrC,6DAAyD;AAgD1B,+FAhDtB,uCAAkB,OAgDkB;AA3C7C;;;;GAIG;AAEH,SAAgB,gBAAgB,CAAC,IAAa;IAC5C,MAAM,EAAE,GAAG,KAAgB,IAAI,EAAf,MAAM,UAAK,IAAI,EAAzB,OAAkB,CAAO,CAAA;IAC/B,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,MAAM,CAAA;IAE1B,IAAA,qBAAc,EAAC,GAAG,CAAC,CAAA;IAEnB,IAAI,MAAM,CAAC,QAAQ,EAAE;QACnB,MAAM,IAAI,gCAAyB,EAAE,CAAA;KACtC;IAED,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAa,CAAC,CAAA;IAEjC,uCACK,MAAM,KACT,QAAQ,EAAE,KAAK,EACf,IAAI,IACL;AACH,CAAC;AAjBD,4CAiBC;AAED,MAAa,oBAAqB,SAAQ,oBAAU;IAGlD,YAAY,MAAY;QACtB,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEe,aAAa,CAC3B,EAA+B,EAC/B,GAAG,IAAe;;YAElB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,EAAE,CAAA;YACxB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAI,EAAE,EAAE,GAAG,CAAC,CAAA;YACrD,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;CACF;AAhBD,oDAgBC"}
@@ -0,0 +1,16 @@
1
+ import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, Expect } from '@playwright/test';
2
+ import { type Options } from './playwright';
3
+ declare type Test = TestType<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
4
+ interface ReturnValue {
5
+ test: Test;
6
+ expect: Expect;
7
+ }
8
+ /**
9
+ * Configure `@playwright/test` for usage with axe Watcher and return wrapped `test` and `expect` functions.
10
+ *
11
+ * @param options Options for configuring Playwright and @axe-core/watcher
12
+ * @see https://playwright.dev/docs/api/class-test#test-call
13
+ * @see https://playwright.dev/docs/api/class-test#test-expect
14
+ */
15
+ declare const playwrightTest: (options: Options) => ReturnValue;
16
+ export default playwrightTest;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ const playwright_1 = require("./playwright");
24
+ const util_1 = require("./util");
25
+ /**
26
+ * Configure `@playwright/test` for usage with axe Watcher and return wrapped `test` and `expect` functions.
27
+ *
28
+ * @param options Options for configuring Playwright and @axe-core/watcher
29
+ * @see https://playwright.dev/docs/api/class-test#test-call
30
+ * @see https://playwright.dev/docs/api/class-test#test-expect
31
+ */
32
+ const playwrightTest = (options) => {
33
+ let controller = null;
34
+ const { axe } = options, config = __rest(options
35
+ // We must lazily require the `@playwright/test` package, as
36
+ // users of other platforms won't have it installed.
37
+ , ["axe"]);
38
+ // We must lazily require the `@playwright/test` package, as
39
+ // users of other platforms won't have it installed.
40
+ let base;
41
+ let chromium;
42
+ try {
43
+ ;
44
+ ({ test: base, chromium } = require('@playwright/test'));
45
+ }
46
+ catch (error) {
47
+ throw new Error('Unable to load @playwright/test: ' + error.message);
48
+ }
49
+ (0, util_1.writeVariables)(axe);
50
+ const test = base.extend({
51
+ // Playwright requires destructing the context object. Removing it yields:
52
+ //
53
+ // Error: First argument must use the object destructuring pattern:
54
+ //
55
+ // eslint-disable-next-line no-empty-pattern
56
+ context: ({}, use) => __awaiter(void 0, void 0, void 0, function* () {
57
+ const context = yield chromium.launchPersistentContext('', Object.assign(Object.assign({}, config), { args: [...(config.args || []), ...util_1.extensionArgs] }));
58
+ yield use(context);
59
+ yield context.close();
60
+ }),
61
+ page: ({ page, context }, use) => __awaiter(void 0, void 0, void 0, function* () {
62
+ controller = new playwright_1.PlaywrightController(page);
63
+ (0, playwright_1.wrapPlaywright)(context, controller);
64
+ yield use(page);
65
+ })
66
+ });
67
+ test.afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
68
+ yield (controller === null || controller === void 0 ? void 0 : controller.flush());
69
+ }));
70
+ const expect = test.expect;
71
+ return { test, expect };
72
+ };
73
+ exports.default = playwrightTest;
74
+ //# sourceMappingURL=playwrightTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwrightTest.js","sourceRoot":"","sources":["../src/playwrightTest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAUA,6CAIqB;AACrB,iCAAsD;AAYtD;;;;;;GAMG;AAEH,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAe,EAAE;IACvD,IAAI,UAAU,GAAgC,IAAI,CAAA;IAClD,MAAM,EAAE,GAAG,KAAgB,OAAO,EAAlB,MAAM,UAAK,OAAO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,KAAK,EAAE,CAAA,CAAA;IAC3B,CAAC,CAAA,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;AACzB,CAAC,CAAA;AAED,kBAAe,cAAc,CAAA"}
@@ -1,11 +1,6 @@
1
- import type { Browser, BrowserContext, ElementHandle, Frame, FrameLocator, JSHandle, Keyboard, Locator, Mouse, Page, Touchscreen } from 'playwright';
1
+ import type { Browser, BrowserContext, ElementHandle, Frame, FrameLocator, JSHandle, Keyboard, Locator, Mouse, Page, Touchscreen } from 'playwright-core';
2
2
  import type { PlaywrightController } from './playwright';
3
- declare const kWrapped: unique symbol;
4
- declare type PossiblyWrapped<T> = T & {
5
- [kWrapped]?: boolean;
6
- };
7
- export declare const isWrapped: <T>(o: PossiblyWrapped<T>) => boolean;
8
- export declare const markAsWrapped: (o: unknown) => void;
3
+ import { type PossiblyWrapped } from './util';
9
4
  export declare const wrapBrowserContext: (browserContext: PossiblyWrapped<BrowserContext>, controller: PlaywrightController) => BrowserContext;
10
5
  export declare const wrapBrowser: (browser: PossiblyWrapped<Browser>, controller: PlaywrightController) => Browser;
11
6
  export declare const wrapPage: (page: PossiblyWrapped<Page>, controller: PlaywrightController) => Page;
@@ -17,4 +12,3 @@ export declare const wrapJSHandle: (jsHandle: PossiblyWrapped<JSHandle>, control
17
12
  export declare const wrapKeyboard: (keyboard: PossiblyWrapped<Keyboard>, controller: PlaywrightController) => Keyboard;
18
13
  export declare const wrapMouse: (mouse: PossiblyWrapped<Mouse>, controller: PlaywrightController) => Mouse;
19
14
  export declare const wrapTouchscreen: (touchscreen: PossiblyWrapped<Touchscreen>, controller: PlaywrightController) => Touchscreen;
20
- export {};