@axe-core/watcher 0.0.0 → 0.0.1-next.581e3953

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/wdio.js ADDED
@@ -0,0 +1,136 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
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
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ exports.WdioManualController = exports.wdioTestRunner = exports.wdioConfig = void 0;
66
+ var util_1 = require("./util");
67
+ /**
68
+ * Creates a WebDriverIO config that uses axe extension
69
+ *
70
+ * @param arg Config to extend
71
+ */
72
+ function wdioConfig(arg) {
73
+ var _a, _b, _c;
74
+ (0, util_1.writeVariables)(arg.axe);
75
+ // Disable eslint. Wdio doesn't export this property even though they support it.
76
+ /* eslint-disable @typescript-eslint/no-explicit-any */
77
+ var chromeOpts = ((_b = (_a = arg.options) === null || _a === void 0 ? void 0 : _a.capabilities) === null || _b === void 0 ? void 0 : _b['goog:chromeOptions']) || {};
78
+ var args = chromeOpts.args || [];
79
+ if (args.includes('--headless')) {
80
+ throw new Error('Cannot use extension while headless.');
81
+ }
82
+ return __assign(__assign({}, arg.options), { capabilities: __assign(__assign({}, (_c = arg.options) === null || _c === void 0 ? void 0 : _c.capabilities), { browserName: 'chrome', 'goog:chromeOptions': {
83
+ args: util_1.extensionArgs.concat(args)
84
+ } }) });
85
+ }
86
+ exports.wdioConfig = wdioConfig;
87
+ // Configuration.axe is not a namespace, therefore have to use ['axe'] instead of .axe
88
+ function wdioTestRunner(axe, config) {
89
+ (0, util_1.writeVariables)(axe);
90
+ var capabilities = config.capabilities || [
91
+ {
92
+ 'goog:chromeOptions': {
93
+ args: []
94
+ }
95
+ }
96
+ ];
97
+ // has to be any because type is not exported
98
+ var firstCapability = capabilities[0];
99
+ firstCapability['goog:chromeOptions'] =
100
+ firstCapability['goog:chromeOptions'] || {};
101
+ var chromeOpts = firstCapability['goog:chromeOptions'];
102
+ chromeOpts.args = chromeOpts.args || [];
103
+ var args = chromeOpts.args;
104
+ if (args.includes('--headless')) {
105
+ throw new Error('Cannot use extension while headless.');
106
+ }
107
+ chromeOpts.args = util_1.extensionArgs.concat(args);
108
+ return __assign(__assign({}, config), { capabilities: capabilities });
109
+ }
110
+ exports.wdioTestRunner = wdioTestRunner;
111
+ var WdioManualController = /** @class */ (function (_super) {
112
+ __extends(WdioManualController, _super);
113
+ function WdioManualController(driver) {
114
+ var _this = _super.call(this) || this;
115
+ _this.driver = driver;
116
+ return _this;
117
+ }
118
+ WdioManualController.prototype.executeScript = function (fn) {
119
+ return __awaiter(this, void 0, void 0, function () {
120
+ var script;
121
+ return __generator(this, function (_a) {
122
+ switch (_a.label) {
123
+ case 0:
124
+ script = "\n const callback = arguments[arguments.length - 1];\n Promise.resolve()\n .then(".concat(fn, ")\n .then(callback);\n ");
125
+ return [4 /*yield*/, this.driver.executeAsyncScript(script, [])];
126
+ case 1:
127
+ _a.sent();
128
+ return [2 /*return*/];
129
+ }
130
+ });
131
+ });
132
+ };
133
+ return WdioManualController;
134
+ }(util_1.ManualController));
135
+ exports.WdioManualController = WdioManualController;
136
+ //# sourceMappingURL=wdio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wdio.js","sourceRoot":"","sources":["../src/wdio.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAKe;AAWf;;;;GAIG;AAEH,SAAgB,UAAU,CAAC,GAAY;;IACrC,IAAA,qBAAc,EAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAEvB,iFAAiF;IACjF,uDAAuD;IACvD,IAAM,UAAU,GACd,CAAA,MAAC,MAAA,GAAG,CAAC,OAAO,0CAAE,YAAoB,0CAAG,oBAAoB,CAAC,KAAI,EAAE,CAAA;IAClE,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,IAAI,EAAE,CAAA;IAElC,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;KACxD;IAED,6BACK,GAAG,CAAC,OAAO,KACd,YAAY,wBACP,MAAA,GAAG,CAAC,OAAO,0CAAE,YAAY,KAC5B,WAAW,EAAE,QAAQ,EACrB,oBAAoB,EAAE;gBACpB,IAAI,EAAE,oBAAa,CAAC,MAAM,CAAC,IAAI,CAAC;aACjC,OAEJ;AACH,CAAC;AAvBD,gCAuBC;AAED,sFAAsF;AACtF,SAAgB,cAAc,CAC5B,GAAyB,EACzB,MAA0B;IAE1B,IAAA,qBAAc,EAAC,GAAG,CAAC,CAAA;IACnB,IAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI;QAC1C;YACE,oBAAoB,EAAE;gBACpB,IAAI,EAAE,EAAE;aACT;SACF;KACF,CAAA;IACD,6CAA6C;IAC7C,IAAM,eAAe,GAAI,YAAoB,CAAC,CAAC,CAAC,CAAA;IAChD,eAAe,CAAC,oBAAoB,CAAC;QACnC,eAAe,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAA;IAC7C,IAAM,UAAU,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAA;IACxD,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,IAAI,EAAE,CAAA;IACvC,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;IAE5B,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;KACxD;IAED,UAAU,CAAC,IAAI,GAAG,oBAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAE5C,6BACK,MAAM,KACT,YAAY,cAAA,IACb;AACH,CAAC;AA9BD,wCA8BC;AAED;IAA0C,wCAAgB;IAGxD,8BAAY,MAAe;QAA3B,YACE,iBAAO,SAER;QADC,KAAI,CAAC,MAAM,GAAG,MAAM,CAAA;;IACtB,CAAC;IAEe,4CAAa,GAA7B,UACE,EAAkC;;;;;;wBAE5B,MAAM,GAAG,4GAGH,EAAE,sCAEb,CAAA;wBACD,qBAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC,EAAA;;wBAAhD,SAAgD,CAAA;;;;;KACjD;IACH,2BAAC;AAAD,CAAC,AAnBD,CAA0C,uBAAgB,GAmBzD;AAnBY,oDAAoB"}
@@ -0,0 +1,18 @@
1
+ import { Configuration, ManualController } from './util';
2
+ import type { WebDriver } from 'selenium-webdriver';
3
+ import type { Options } from 'selenium-webdriver/chrome';
4
+ interface WebDriverArgs extends Configuration {
5
+ options?: Options;
6
+ }
7
+ /**
8
+ * Creates a Selenium config that uses axe extension
9
+ *
10
+ * @param arg Config to extend
11
+ */
12
+ export declare function webdriverConfig(arg: WebDriverArgs): Options;
13
+ export declare class WebdriverManualController extends ManualController {
14
+ private driver;
15
+ constructor(driver: WebDriver);
16
+ protected executeScript(fn: string | (() => Promise<void>)): Promise<void>;
17
+ }
18
+ export {};
@@ -0,0 +1,103 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.WebdriverManualController = exports.webdriverConfig = void 0;
55
+ var util_1 = require("./util");
56
+ /**
57
+ * Creates a Selenium config that uses axe extension
58
+ *
59
+ * @param arg Config to extend
60
+ */
61
+ function webdriverConfig(arg) {
62
+ var _a, _b;
63
+ // Lazily require `chrome` to avoid Puppeteer/Playwright/WDIO users from needing `selenium-webdriver` installed.
64
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
65
+ var chrome = require('selenium-webdriver/chrome');
66
+ var axe = arg.axe, options = arg.options;
67
+ (0, util_1.writeVariables)(axe);
68
+ var opts = options ? options : new chrome.Options();
69
+ opts.addArguments.apply(opts, util_1.extensionArgs);
70
+ // Note: fragile, but selenium does not give us a real way to check this
71
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
+ if ((_b = (_a = opts === null || opts === void 0 ? void 0 : opts.options_) === null || _a === void 0 ? void 0 : _a.args) === null || _b === void 0 ? void 0 : _b.includes('headless')) {
73
+ throw new Error('Cannot use extension while headless.');
74
+ }
75
+ return opts;
76
+ }
77
+ exports.webdriverConfig = webdriverConfig;
78
+ var WebdriverManualController = /** @class */ (function (_super) {
79
+ __extends(WebdriverManualController, _super);
80
+ function WebdriverManualController(driver) {
81
+ var _this = _super.call(this) || this;
82
+ _this.driver = driver;
83
+ return _this;
84
+ }
85
+ WebdriverManualController.prototype.executeScript = function (fn) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ var script;
88
+ return __generator(this, function (_a) {
89
+ switch (_a.label) {
90
+ case 0:
91
+ script = "\n const callback = arguments[arguments.length - 1];\n Promise.resolve()\n .then(".concat(fn, ")\n .then(callback);\n ");
92
+ return [4 /*yield*/, this.driver.executeAsyncScript(script)];
93
+ case 1:
94
+ _a.sent();
95
+ return [2 /*return*/];
96
+ }
97
+ });
98
+ });
99
+ };
100
+ return WebdriverManualController;
101
+ }(util_1.ManualController));
102
+ exports.WebdriverManualController = WebdriverManualController;
103
+ //# sourceMappingURL=webdriver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webdriver.js","sourceRoot":"","sources":["../src/webdriver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAKe;AAQf;;;;GAIG;AAEH,SAAgB,eAAe,CAAC,GAAkB;;IAChD,gHAAgH;IAChH,8DAA8D;IAC9D,IAAM,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAA;IAE3C,IAAA,GAAG,GAAc,GAAG,IAAjB,EAAE,OAAO,GAAK,GAAG,QAAR,CAAQ;IAC5B,IAAA,qBAAc,EAAC,GAAG,CAAC,CAAA;IAEnB,IAAM,IAAI,GAAY,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAA;IAC9D,IAAI,CAAC,YAAY,OAAjB,IAAI,EAAiB,oBAAa,EAAC;IAEnC,wEAAwE;IACxE,8DAA8D;IAC9D,IAAI,MAAA,MAAC,IAAY,aAAZ,IAAI,uBAAJ,IAAI,CAAU,QAAQ,0CAAE,IAAI,0CAAE,QAAQ,CAAC,UAAU,CAAC,EAAE;QACvD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;KACxD;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAlBD,0CAkBC;AAED;IAA+C,6CAAgB;IAG7D,mCAAY,MAAiB;QAA7B,YACE,iBAAO,SAER;QADC,KAAI,CAAC,MAAM,GAAG,MAAM,CAAA;;IACtB,CAAC;IAEe,iDAAa,GAA7B,UACE,EAAkC;;;;;;wBAE5B,MAAM,GAAG,4GAGH,EAAE,sCAEb,CAAA;wBACD,qBAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAA;;wBAA5C,SAA4C,CAAA;;;;;KAC7C;IACH,gCAAC;AAAD,CAAC,AAnBD,CAA+C,uBAAgB,GAmB9D;AAnBY,8DAAyB"}