@axe-core/watcher 0.0.0 → 0.0.1-next.03d73676

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.
@@ -0,0 +1,9 @@
1
+ declare abstract class Controller {
2
+ protected abstract executeScript(fn: string | (() => Promise<void>)): Promise<void>;
3
+ start(): Promise<void>;
4
+ stop(): Promise<void>;
5
+ analyze(): Promise<void>;
6
+ /** Flush all axe-core results by sending them to the server. */
7
+ flush(): Promise<void>;
8
+ }
9
+ export default Controller;
@@ -0,0 +1,137 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var fs_1 = __importDefault(require("fs"));
43
+ var util_1 = require("./util");
44
+ var updateAutoAnalyze = function (val) {
45
+ var fileContents = fs_1.default.readFileSync(util_1.PATH_TO_EXTENSION_VARIABLES, 'utf-8');
46
+ var jsonValue = JSON.parse(fileContents);
47
+ jsonValue.auto_analyze = val;
48
+ fs_1.default.writeFileSync(util_1.PATH_TO_EXTENSION_VARIABLES, JSON.stringify(jsonValue));
49
+ };
50
+ var Controller = /** @class */ (function () {
51
+ function Controller() {
52
+ }
53
+ Controller.prototype.start = function () {
54
+ return __awaiter(this, void 0, void 0, function () {
55
+ return __generator(this, function (_a) {
56
+ switch (_a.label) {
57
+ case 0:
58
+ updateAutoAnalyze(true);
59
+ return [4 /*yield*/, this.executeScript(function () {
60
+ var event = new CustomEvent('axe:start-auto-mode');
61
+ window.dispatchEvent(event);
62
+ return Promise.resolve();
63
+ })];
64
+ case 1:
65
+ _a.sent();
66
+ return [2 /*return*/];
67
+ }
68
+ });
69
+ });
70
+ };
71
+ Controller.prototype.stop = function () {
72
+ return __awaiter(this, void 0, void 0, function () {
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0:
76
+ updateAutoAnalyze(false);
77
+ return [4 /*yield*/, this.executeScript(function () {
78
+ var event = new CustomEvent('axe:stop-auto-mode');
79
+ window.dispatchEvent(event);
80
+ return Promise.resolve();
81
+ })];
82
+ case 1:
83
+ _a.sent();
84
+ return [2 /*return*/];
85
+ }
86
+ });
87
+ });
88
+ };
89
+ Controller.prototype.analyze = function () {
90
+ return __awaiter(this, void 0, void 0, function () {
91
+ return __generator(this, function (_a) {
92
+ switch (_a.label) {
93
+ case 0: return [4 /*yield*/, this.executeScript(function () {
94
+ return new Promise(function (resolve) {
95
+ var event = new CustomEvent('axe:manual-mode-analyze');
96
+ var fn = function () {
97
+ window.removeEventListener('axe:manual-mode-analyze-done', fn);
98
+ resolve();
99
+ };
100
+ window.addEventListener('axe:manual-mode-analyze-done', fn);
101
+ window.dispatchEvent(event);
102
+ });
103
+ })];
104
+ case 1:
105
+ _a.sent();
106
+ return [2 /*return*/];
107
+ }
108
+ });
109
+ });
110
+ };
111
+ /** Flush all axe-core results by sending them to the server. */
112
+ Controller.prototype.flush = function () {
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ return __generator(this, function (_a) {
115
+ switch (_a.label) {
116
+ case 0: return [4 /*yield*/, this.executeScript(function () {
117
+ return new Promise(function (resolve) {
118
+ var fn = function () {
119
+ window.removeEventListener('axe:flush-end', fn);
120
+ resolve();
121
+ };
122
+ window.addEventListener('axe:flush-end', fn);
123
+ var event = new CustomEvent('axe:flush-start');
124
+ window.dispatchEvent(event);
125
+ });
126
+ })];
127
+ case 1:
128
+ _a.sent();
129
+ return [2 /*return*/];
130
+ }
131
+ });
132
+ });
133
+ };
134
+ return Controller;
135
+ }());
136
+ exports.default = Controller;
137
+ //# sourceMappingURL=Controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Controller.js","sourceRoot":"","sources":["../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G,IAAI,WAAW,CAAC,yBAAyB,CAAC,CAAA;gCACxD,IAAM,EAAE,GAAG;oCACT,MAAM,CAAC,mBAAmB,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAA;oCAC9D,OAAO,EAAE,CAAA;gCACX,CAAC,CAAA;gCACD,MAAM,CAAC,gBAAgB,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAA;gCAC3D,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;4BAC7B,CAAC,CAAC,CAAA;wBACJ,CAAC,CAAC,EAAA;;wBAVF,SAUE,CAAA;;;;;KACH;IAED,gEAAgE;IACnD,0BAAK,GAAlB;;;;4BACE,qBAAM,IAAI,CAAC,aAAa,CAAC;4BACvB,OAAO,IAAI,OAAO,CAAC,UAAA,OAAO;gCACxB,IAAM,EAAE,GAAG;oCACT,MAAM,CAAC,mBAAmB,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;oCAC/C,OAAO,EAAE,CAAA;gCACX,CAAC,CAAA;gCACD,MAAM,CAAC,gBAAgB,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;gCAC5C,IAAM,KAAK,GAAG,IAAI,WAAW,CAAC,iBAAiB,CAAC,CAAA;gCAChD,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;4BAC7B,CAAC,CAAC,CAAA;wBACJ,CAAC,CAAC,EAAA;;wBAVF,SAUE,CAAA;;;;;KACH;IACH,iBAAC;AAAD,CAAC,AAnDD,IAmDC;AAED,kBAAe,UAAU,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type Cypress from 'cypress';
2
+ import { Configuration } from './util';
3
+ /**
4
+ * Create a Cypress config that uses the axe Watcher extension.
5
+ *
6
+ * @param config Cypress config to extend
7
+ */
8
+ export declare const cypressConfig: (config: Cypress.ConfigOptions & Configuration) => Cypress.ConfigOptions;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.cypressConfig = void 0;
26
+ var util_1 = require("./util");
27
+ /**
28
+ * Create a Cypress config that uses the axe Watcher extension.
29
+ *
30
+ * @param config Cypress config to extend
31
+ */
32
+ var cypressConfig = function (config) {
33
+ var axe = config.axe, userConfig = __rest(config, ["axe"]);
34
+ (0, util_1.writeVariables)(axe);
35
+ (0, util_1.writeManifest)({
36
+ all_frames: true,
37
+ exclude_globs: [
38
+ // Top-level Cypress page.
39
+ '*/__/#/specs/runner?file=*',
40
+ // Cypress-specific iframes.
41
+ '*/__cypress/iframes/*'
42
+ ]
43
+ });
44
+ return __assign(__assign({}, userConfig), { e2e: __assign(__assign({}, userConfig.e2e), { setupNodeEvents: function (on) {
45
+ on('before:browser:launch', function (browser, launchOptions) {
46
+ var _a;
47
+ // We only support Chrome.
48
+ if (browser.name === 'chrome') {
49
+ if (browser.isHeadless) {
50
+ throw new util_1.HeadlessNotSupportedError();
51
+ }
52
+ // Load the extension.
53
+ (_a = launchOptions.args).push.apply(_a, util_1.extensionArgs);
54
+ }
55
+ return launchOptions;
56
+ });
57
+ } }) });
58
+ };
59
+ exports.cypressConfig = cypressConfig;
60
+ //# sourceMappingURL=cypress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cypress.js","sourceRoot":"","sources":["../src/cypress.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,+BAMe;AAEf;;;;GAIG;AAEI,IAAM,aAAa,GAAG,UAC3B,MAA6C;IAErC,IAAA,GAAG,GAAoB,MAAM,IAA1B,EAAK,UAAU,UAAK,MAAM,EAA/B,OAAsB,CAAF,CAAW;IAErC,IAAA,qBAAc,EAAC,GAAG,CAAC,CAAA;IACnB,IAAA,oBAAa,EAAC;QACZ,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE;YACb,0BAA0B;YAC1B,4BAA4B;YAC5B,4BAA4B;YAC5B,uBAAuB;SACxB;KACF,CAAC,CAAA;IAEF,6BACK,UAAU,KACb,GAAG,wBACE,UAAU,CAAC,GAAG,KACjB,eAAe,YAAC,EAAE;gBAChB,EAAE,CAAC,uBAAuB,EAAE,UAAC,OAAO,EAAE,aAAa;;oBACjD,0BAA0B;oBAC1B,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;wBAC7B,IAAI,OAAO,CAAC,UAAU,EAAE;4BACtB,MAAM,IAAI,gCAAyB,EAAE,CAAA;yBACtC;wBAED,sBAAsB;wBACtB,CAAA,KAAA,aAAa,CAAC,IAAI,CAAA,CAAC,IAAI,WAAI,oBAAa,EAAC;qBAC1C;oBAED,OAAO,aAAa,CAAA;gBACtB,CAAC,CAAC,CAAA;YACJ,CAAC,OAEJ;AACH,CAAC,CAAA;AArCY,QAAA,aAAa,iBAqCzB"}
@@ -0,0 +1,15 @@
1
+ export {};
2
+ declare global {
3
+ namespace Cypress {
4
+ interface Chainable {
5
+ /** Flush the axe-core result queue by sending results to the server. */
6
+ axeFlush(): Chainable<void>;
7
+ /** Perform a manual axe-core analysis. */
8
+ axeAnalyze(): Chainable<void>;
9
+ /** Start automatic analysis mode. */
10
+ axeStart(): Chainable<void>;
11
+ /** Stop automatic analysis mode. */
12
+ axeStop(): Chainable<void>;
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ Cypress.Commands.add('axeFlush', function () {
4
+ cy.window().then(function (win) {
5
+ return new Promise(function (resolve) {
6
+ var fn = function () {
7
+ win.removeEventListener('axe:flush-end', fn);
8
+ resolve();
9
+ };
10
+ win.addEventListener('axe:flush-end', fn);
11
+ var event = new CustomEvent('axe:flush-start');
12
+ win.dispatchEvent(event);
13
+ });
14
+ });
15
+ });
16
+ Cypress.Commands.add('axeAnalyze', function () {
17
+ cy.window().then(function (win) {
18
+ return new Promise(function (resolve) {
19
+ var event = new CustomEvent('axe:manual-mode-analyze');
20
+ var fn = function () {
21
+ win.removeEventListener('axe:manual-mode-analyze-done', fn);
22
+ resolve();
23
+ };
24
+ win.addEventListener('axe:manual-mode-analyze-done', fn);
25
+ win.dispatchEvent(event);
26
+ });
27
+ });
28
+ });
29
+ Cypress.Commands.add('axeStart', function () {
30
+ cy.window().then(function (win) {
31
+ var event = new CustomEvent('axe:start-auto-mode');
32
+ win.dispatchEvent(event);
33
+ return Promise.resolve();
34
+ });
35
+ });
36
+ Cypress.Commands.add('axeStop', function () {
37
+ cy.window().then(function (win) {
38
+ var event = new CustomEvent('axe:stop-auto-mode');
39
+ win.dispatchEvent(event);
40
+ return Promise.resolve();
41
+ });
42
+ });
43
+ //# sourceMappingURL=cypressCommands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cypressCommands.js","sourceRoot":"","sources":["../src/cypressCommands.ts"],"names":[],"mappings":";;AAmBA,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE;IAC/B,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,UAAA,GAAG;QAClB,OAAO,IAAI,OAAO,CAAO,UAAA,OAAO;YAC9B,IAAM,EAAE,GAAG;gBACT,GAAG,CAAC,mBAAmB,CAAC,eAAe,EAAE,EAAE,CAA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AM,EAAE,CAAC,IAAI,CAAC,UAAA,GAAG;QAClB,IAAM,KAAK,GAAG,IAAI,WAAW,CAAC,oBAAoB,CAAC,CAAA;QACnD,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QACxB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
package/dist/git.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ /** Check if the given `dir` is contained by a Git repository. */
2
+ export declare const isRepository: (dir?: string) => boolean;
3
+ /** Get the current branch name. */
4
+ export declare const getBranchName: (dir?: string) => string | null;
5
+ /** Get the default branch name. */
6
+ export declare const getDefaultBranchName: (dir?: string) => string | null;
7
+ /** Get the repository's remote URL. */
8
+ export declare const getRemoteURL: (dir?: string) => string | null;
9
+ interface CommitInfo {
10
+ message: string;
11
+ hash: string;
12
+ author: string;
13
+ email: string;
14
+ }
15
+ /** Get info on the most recent commit. */
16
+ export declare const getCommitInfo: (dir?: string) => CommitInfo | null;
17
+ /** Check if the repository contains unstaged changes. */
18
+ export declare const isDirty: (dir?: string) => boolean;
19
+ export {};
package/dist/git.js ADDED
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDirty = exports.getCommitInfo = exports.getRemoteURL = exports.getDefaultBranchName = exports.getBranchName = exports.isRepository = void 0;
4
+ var child_process_1 = require("child_process");
5
+ /** Check if the given `dir` is contained by a Git repository. */
6
+ var isRepository = function (dir) {
7
+ if (dir === void 0) { dir = process.cwd(); }
8
+ try {
9
+ (0, child_process_1.execSync)('git rev-parse --is-inside-work-tree', {
10
+ cwd: dir,
11
+ // Prevent printing "fatal: not a git repository".
12
+ stdio: 'ignore'
13
+ });
14
+ return true;
15
+ }
16
+ catch (_a) {
17
+ return false;
18
+ }
19
+ };
20
+ exports.isRepository = isRepository;
21
+ /** Get the current branch name. */
22
+ var getBranchName = function (dir) {
23
+ if (dir === void 0) { dir = process.cwd(); }
24
+ try {
25
+ return (0, child_process_1.execSync)('git rev-parse --abbrev-ref HEAD', {
26
+ cwd: dir,
27
+ // Ignore stderr to prevent printing "fatal: not a git repository" in tests.
28
+ stdio: ['ignore', 'pipe', 'ignore']
29
+ })
30
+ .toString()
31
+ .trim();
32
+ }
33
+ catch (_a) {
34
+ return null;
35
+ }
36
+ };
37
+ exports.getBranchName = getBranchName;
38
+ /** Get the default branch name. */
39
+ var getDefaultBranchName = function (dir) {
40
+ if (dir === void 0) { dir = process.cwd(); }
41
+ try {
42
+ return (0, child_process_1.execSync)('git symbolic-ref --short refs/remotes/origin/HEAD', {
43
+ cwd: dir,
44
+ stdio: ['ignore', 'pipe', 'ignore']
45
+ })
46
+ .toString()
47
+ .trim()
48
+ .replace('origin/', '');
49
+ }
50
+ catch (_a) {
51
+ return null;
52
+ }
53
+ };
54
+ exports.getDefaultBranchName = getDefaultBranchName;
55
+ /** Get the repository's remote URL. */
56
+ var getRemoteURL = function (dir) {
57
+ if (dir === void 0) { dir = process.cwd(); }
58
+ try {
59
+ return (0, child_process_1.execSync)('git config --get remote.origin.url', {
60
+ cwd: dir,
61
+ stdio: ['ignore', 'pipe', 'ignore']
62
+ })
63
+ .toString()
64
+ .trim();
65
+ }
66
+ catch (_a) {
67
+ return null;
68
+ }
69
+ };
70
+ exports.getRemoteURL = getRemoteURL;
71
+ /** Get info on the most recent commit. */
72
+ var getCommitInfo = function (dir) {
73
+ if (dir === void 0) { dir = process.cwd(); }
74
+ try {
75
+ // %s=subject (message), %H=hash, %an=author name, %ae=author email, %n=newline
76
+ // See https://git-scm.com/docs/git-show#_pretty_formats
77
+ var stdout = (0, child_process_1.execSync)('git show --no-patch --format="%s%n%H%n%an%n%ae"', {
78
+ cwd: dir,
79
+ stdio: ['ignore', 'pipe', 'ignore']
80
+ });
81
+ var _a = stdout.toString().trim().split('\n'), message = _a[0], hash = _a[1], author = _a[2], email = _a[3];
82
+ return { message: message, hash: hash, author: author, email: email };
83
+ }
84
+ catch (_b) {
85
+ return null;
86
+ }
87
+ };
88
+ exports.getCommitInfo = getCommitInfo;
89
+ /** Check if the repository contains unstaged changes. */
90
+ var isDirty = function (dir) {
91
+ if (dir === void 0) { dir = process.cwd(); }
92
+ try {
93
+ var stdout = (0, child_process_1.execSync)('git status --short', {
94
+ cwd: dir,
95
+ stdio: ['ignore', 'pipe', 'ignore']
96
+ });
97
+ return stdout.length > 0;
98
+ }
99
+ catch (_a) {
100
+ return false;
101
+ }
102
+ };
103
+ exports.isDirty = isDirty;
104
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AAExC,iEAAiE;AAC1D,IAAM,YAAY,GAAG,UAAC,GAAmB;IAAnB,oBAAA,EAAA,MAAM,OAAO,CAAC,GAAG,EAAE;IAC9C,IAAI;QACF,IAAA,wBAAQ,EAAC,qCAAqC,EAAE;YAC9C,GAAG,EAAE,GAAG;YACR,kDAAkD;YAClD,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;KACZ;IAAC,WAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC,CAAA;AAXY,QAAA,YAAY,gBAWxB;AAED,mCAAmC;AAC5B,IAAM,aAAa,GAAG,UAAC,GAAmB;IAAnB,oBAAA,EAAA,MAAM,OAAO,CAAC,GAAG,EAAE;IAC/C,IAAI;QACF,OAAO,IAAA,wBAAQ,EAAC,iCAAiC,EAAE;YACjD,GAAG,EAAE,GAAG;YACR,4EAA4E;YAC5E,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACpC,CAAC;aACC,QAAQ,EAAE;aACV,IAAI,EAAE,CAAA;KACV;IAAC,WAAM;QACN,OAAO,IAAI,CAAA;KACZ;AACH,CAAC,CAAA;AAZY,QAAA,aAAa,iBAYzB;AAED,mCAAmC;AA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I,QAAA,EAAE,MAAM,QAAA,EAAE,KAAK,QAAwC,CAAA;QAC3E,OAAO,EAAE,OAAO,SAAA,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,KAAK,OAAA,EAAE,CAAA;KACxC;IAAC,WAAM;QACN,OAAO,IAAI,CAAA;KACZ;AACH,CAAC,CAAA;AAbY,QAAA,aAAa,iBAazB;AAED,yDAAyD;AAClD,IAAM,OAAO,GAAG,UAAC,GAAmB;IAAnB,oBAAA,EAAA,MAAM,OAAO,CAAC,GAAG,EAAE;IACzC,IAAI;QACF,IAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,oBAAoB,EAAE;YAC5C,GAAG,EAAE,GAAG;YACR,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACpC,CAAC,CAAA;QACF,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;KACzB;IAAC,WAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC,CAAA;AAVY,QAAA,OAAO,WAUnB"}
@@ -0,0 +1,6 @@
1
+ /*! Copyright Deque 2021-2022 All Rights Reserved */
2
+ export { puppeteerConfig, PuppeteerController } from './puppeteer';
3
+ export { wdioConfig, wdioTestRunner, WdioController } from './wdio';
4
+ export { webdriverConfig, WebdriverController } from './webdriver';
5
+ export { playwrightConfig, PlaywrightController } from './playwright';
6
+ export { cypressConfig } from './cypress';
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*! Copyright Deque 2021-2022 All Rights Reserved */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.cypressConfig = exports.PlaywrightController = exports.playwrightConfig = exports.WebdriverController = exports.webdriverConfig = exports.WdioController = exports.wdioTestRunner = exports.wdioConfig = exports.PuppeteerController = exports.puppeteerConfig = void 0;
5
+ var puppeteer_1 = require("./puppeteer");
6
+ Object.defineProperty(exports, "puppeteerConfig", { enumerable: true, get: function () { return puppeteer_1.puppeteerConfig; } });
7
+ Object.defineProperty(exports, "PuppeteerController", { enumerable: true, get: function () { return puppeteer_1.PuppeteerController; } });
8
+ var wdio_1 = require("./wdio");
9
+ Object.defineProperty(exports, "wdioConfig", { enumerable: true, get: function () { return wdio_1.wdioConfig; } });
10
+ Object.defineProperty(exports, "wdioTestRunner", { enumerable: true, get: function () { return wdio_1.wdioTestRunner; } });
11
+ Object.defineProperty(exports, "WdioController", { enumerable: true, get: function () { return wdio_1.WdioController; } });
12
+ var webdriver_1 = require("./webdriver");
13
+ Object.defineProperty(exports, "webdriverConfig", { enumerable: true, get: function () { return webdriver_1.webdriverConfig; } });
14
+ Object.defineProperty(exports, "WebdriverController", { enumerable: true, get: function () { return webdriver_1.WebdriverController; } });
15
+ var playwright_1 = require("./playwright");
16
+ Object.defineProperty(exports, "playwrightConfig", { enumerable: true, get: function () { return playwright_1.playwrightConfig; } });
17
+ Object.defineProperty(exports, "PlaywrightController", { enumerable: true, get: function () { return playwright_1.PlaywrightController; } });
18
+ var cypress_1 = require("./cypress");
19
+ Object.defineProperty(exports, "cypressConfig", { enumerable: true, get: function () { return cypress_1.cypressConfig; } });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAEpD,yCAAkE;AAAzD,4GAAA,eAAe,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAC7C,+BAAmE;AAA1D,kGAAA,UAAU,OAAA;AAAE,sGAAA,cAAc,OAAA;AAAE,sGAAA,cAAc,OAAA;AACnD,yCAAkE;AAAzD,4GAAA,eAAe,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAC7C,2CAAqE;AAA5D,8GAAA,gBAAgB,OAAA;AAAE,kHAAA,oBAAoB,OAAA;AAC/C,qCAAyC;AAAhC,wGAAA,aAAa,OAAA"}
@@ -0,0 +1,14 @@
1
+ import type { LaunchOptions, Page } from 'playwright';
2
+ import { Configuration } from './util';
3
+ import Controller from './Controller';
4
+ /**
5
+ * Creates a Playwright config that uses axe extension
6
+ *
7
+ * @param opts Playwright config to extend
8
+ */
9
+ export declare function playwrightConfig(opts: Configuration & LaunchOptions): LaunchOptions;
10
+ export declare class PlaywrightController extends Controller {
11
+ private driver;
12
+ constructor(driver: Page);
13
+ protected executeScript(fn: string | (() => Promise<void>)): Promise<void>;
14
+ }
@@ -0,0 +1,120 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
65
+ var t = {};
66
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
67
+ t[p] = s[p];
68
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
69
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
70
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
71
+ t[p[i]] = s[p[i]];
72
+ }
73
+ return t;
74
+ };
75
+ var __importDefault = (this && this.__importDefault) || function (mod) {
76
+ return (mod && mod.__esModule) ? mod : { "default": mod };
77
+ };
78
+ Object.defineProperty(exports, "__esModule", { value: true });
79
+ exports.PlaywrightController = exports.playwrightConfig = void 0;
80
+ var util_1 = require("./util");
81
+ var Controller_1 = __importDefault(require("./Controller"));
82
+ /**
83
+ * Creates a Playwright config that uses axe extension
84
+ *
85
+ * @param opts Playwright config to extend
86
+ */
87
+ function playwrightConfig(opts) {
88
+ var axe = opts.axe, config = __rest(opts, ["axe"]);
89
+ var _a = config.args, args = _a === void 0 ? [] : _a;
90
+ (0, util_1.writeVariables)(axe);
91
+ if (config.headless) {
92
+ throw new util_1.HeadlessNotSupportedError();
93
+ }
94
+ args = args.concat(util_1.extensionArgs);
95
+ return __assign(__assign({}, config), { headless: false, args: args });
96
+ }
97
+ exports.playwrightConfig = playwrightConfig;
98
+ var PlaywrightController = /** @class */ (function (_super) {
99
+ __extends(PlaywrightController, _super);
100
+ function PlaywrightController(driver) {
101
+ var _this = _super.call(this) || this;
102
+ _this.driver = driver;
103
+ return _this;
104
+ }
105
+ PlaywrightController.prototype.executeScript = function (fn) {
106
+ return __awaiter(this, void 0, void 0, function () {
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0: return [4 /*yield*/, this.driver.evaluate(fn)];
110
+ case 1:
111
+ _a.sent();
112
+ return [2 /*return*/];
113
+ }
114
+ });
115
+ });
116
+ };
117
+ return PlaywrightController;
118
+ }(Controller_1.default));
119
+ exports.PlaywrightController = PlaywrightController;
120
+ //# sourceMappingURL=playwright.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.js","sourceRoot":"","sources":["../src/playwright.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+BAKe;AACf,4DAAqC;AAErC;;;;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;;;;4BAElC,qBAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAA;;wBAA9B,SAA8B,CAAA;;;;;KAC/B;IACH,2BAAC;AAAD,CAAC,AAbD,CAA0C,oBAAU,GAanD;AAbY,oDAAoB"}
@@ -0,0 +1,16 @@
1
+ import type { LaunchOptions, BrowserLaunchArgumentOptions, BrowserConnectOptions, Page } from 'puppeteer';
2
+ import { Configuration } from './util';
3
+ import Controller from './Controller';
4
+ declare type Options = LaunchOptions & BrowserLaunchArgumentOptions & BrowserConnectOptions;
5
+ /**
6
+ * Creates a Puppeteer config that uses axe extension.
7
+ *
8
+ * @param opts Config to extend
9
+ */
10
+ export declare function puppeteerConfig(opts: Configuration & Options): Options;
11
+ export declare class PuppeteerController extends Controller {
12
+ private driver;
13
+ constructor(driver: Page);
14
+ protected executeScript(fn: string | (() => Promise<void>)): Promise<void>;
15
+ }
16
+ export {};