@telefonica/acceptance-testing 3.0.0 → 4.1.0
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 +49 -9
- package/dist/acceptance-testing.cjs.development.js +350 -198
- package/dist/acceptance-testing.cjs.development.js.map +1 -1
- package/dist/acceptance-testing.cjs.production.min.js +1 -1
- package/dist/acceptance-testing.cjs.production.min.js.map +1 -1
- package/dist/acceptance-testing.esm.js +350 -198
- package/dist/acceptance-testing.esm.js.map +1 -1
- package/dist/coverage.d.ts +9 -2
- package/dist/index.d.ts +2 -2
- package/dist/utils.d.ts +4 -0
- package/package.json +3 -2
|
@@ -5,6 +5,7 @@ import { queries, getDocument } from 'pptr-testing-library';
|
|
|
5
5
|
import { configureToMatchImageSnapshot } from 'jest-image-snapshot';
|
|
6
6
|
import globToRegExp from 'glob-to-regexp';
|
|
7
7
|
import { execSync } from 'child_process';
|
|
8
|
+
import istanbul from 'istanbul-lib-coverage';
|
|
8
9
|
|
|
9
10
|
function _regeneratorRuntime() {
|
|
10
11
|
_regeneratorRuntime = function () {
|
|
@@ -364,6 +365,27 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
364
365
|
return target;
|
|
365
366
|
}
|
|
366
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Debug function that logs to the console if the DEBUG_ACCEPTANCE_TESTING environment variable is set
|
|
370
|
+
*/
|
|
371
|
+
var debug = function debug() {
|
|
372
|
+
if (process.env.DEBUG_ACCEPTANCE_TESTING) {
|
|
373
|
+
var _console;
|
|
374
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
375
|
+
args[_key] = arguments[_key];
|
|
376
|
+
}
|
|
377
|
+
(_console = console).debug.apply(_console, ['[acceptance-testing]'].concat(args));
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* Returns true if the current path matches the spied path, including parameters
|
|
382
|
+
*/
|
|
383
|
+
var matchPath = function matchPath(spiedPath, currentPath) {
|
|
384
|
+
var normalizedCurrentPath = path.normalize(currentPath);
|
|
385
|
+
var pattern = globToRegExp(spiedPath);
|
|
386
|
+
return pattern.test(normalizedCurrentPath);
|
|
387
|
+
};
|
|
388
|
+
|
|
367
389
|
var getGlobalPage = function getGlobalPage() {
|
|
368
390
|
return global.page;
|
|
369
391
|
};
|
|
@@ -385,80 +407,148 @@ var getRootPath = function getRootPath() {
|
|
|
385
407
|
var prepareCoverageReportPath = function prepareCoverageReportPath(_ref) {
|
|
386
408
|
var coveragePath = _ref.coveragePath;
|
|
387
409
|
var ppidFile = path.join(coveragePath, '.ppid');
|
|
410
|
+
var nycOutputPath = path.join(coveragePath, '.nyc_output');
|
|
388
411
|
var ppid = process.ppid.toString();
|
|
389
412
|
if (!fs.existsSync(ppidFile) || fs.readFileSync(ppidFile, 'utf-8') !== ppid) {
|
|
390
413
|
// the condition is just to make sure we don't remove files outside the repo
|
|
391
414
|
if (getRootPath() === process.cwd() && path.normalize(coveragePath).startsWith(process.cwd())) {
|
|
392
|
-
fs.rmSync(
|
|
415
|
+
fs.rmSync(nycOutputPath, {
|
|
393
416
|
recursive: true,
|
|
394
417
|
force: true
|
|
395
418
|
});
|
|
396
419
|
}
|
|
397
|
-
fs.mkdirSync(
|
|
420
|
+
fs.mkdirSync(nycOutputPath, {
|
|
398
421
|
recursive: true
|
|
399
422
|
});
|
|
400
423
|
fs.writeFileSync(ppidFile, ppid);
|
|
401
424
|
}
|
|
402
425
|
};
|
|
426
|
+
var workerId = process.env.JEST_WORKER_ID || '0';
|
|
403
427
|
/**
|
|
404
|
-
*
|
|
428
|
+
* Writes the coverage reports into single files, one per each coverage object (path). This makes it easier to merge them.
|
|
429
|
+
* The `workerId` from jest is used to avoid race conditions when multiple workers are running in parallel.
|
|
430
|
+
*/
|
|
431
|
+
var writeCombinedCoverage = function writeCombinedCoverage(nycOutputPath, coverage) {
|
|
432
|
+
Object.values(coverage).forEach(function (value) {
|
|
433
|
+
if (value && value.path && value.hash) {
|
|
434
|
+
var _currentCoverage;
|
|
435
|
+
var filename = path.join(nycOutputPath, value.hash + "-" + workerId + ".json");
|
|
436
|
+
var currentCoverage = (_currentCoverage = {}, _currentCoverage[value.path] = value, _currentCoverage);
|
|
437
|
+
var previousCoverage = fs.existsSync(filename) ? JSON.parse(fs.readFileSync(filename, 'utf8')) : {};
|
|
438
|
+
var mergedCoverage = istanbul.createCoverageMap(previousCoverage);
|
|
439
|
+
mergedCoverage.merge(currentCoverage);
|
|
440
|
+
debug('Writing merged coverage:', value.path, value.hash);
|
|
441
|
+
fs.writeFileSync(filename, JSON.stringify(mergedCoverage.toJSON(), null, 2));
|
|
442
|
+
} else {
|
|
443
|
+
debug('Skip write coverage. Missing path or hash:', value);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* Assumes the code was instrumented with istanbul/nyc and the coverage report stored in `window.__coverage__`.
|
|
405
449
|
* If not, this function does nothing.
|
|
406
450
|
*/
|
|
407
|
-
var
|
|
451
|
+
var collectFrontendCoverage = /*#__PURE__*/function () {
|
|
408
452
|
var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
|
|
409
|
-
var coveragePath,
|
|
453
|
+
var coveragePath, nycOutputPath, coverage;
|
|
410
454
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
411
455
|
while (1) switch (_context.prev = _context.next) {
|
|
412
456
|
case 0:
|
|
413
457
|
coveragePath = _ref2.coveragePath;
|
|
414
|
-
|
|
458
|
+
nycOutputPath = path.join(coveragePath, '.nyc_output');
|
|
459
|
+
_context.next = 4;
|
|
415
460
|
return getGlobalPage().evaluate(function () {
|
|
416
461
|
return window.__coverage__;
|
|
417
462
|
});
|
|
418
|
-
case
|
|
463
|
+
case 4:
|
|
419
464
|
coverage = _context.sent;
|
|
420
465
|
if (coverage) {
|
|
421
|
-
_context.next =
|
|
466
|
+
_context.next = 8;
|
|
422
467
|
break;
|
|
423
468
|
}
|
|
469
|
+
debug('Skipping coverage collection. No coverage found.');
|
|
424
470
|
return _context.abrupt("return");
|
|
425
|
-
case
|
|
471
|
+
case 8:
|
|
472
|
+
debug('Frontend coverage found');
|
|
426
473
|
prepareCoverageReportPath({
|
|
427
474
|
coveragePath: coveragePath
|
|
428
475
|
});
|
|
429
|
-
nycOutputPath = path.join(coveragePath, '.nyc_output');
|
|
430
476
|
fs.mkdirSync(nycOutputPath, {
|
|
431
477
|
recursive: true
|
|
432
478
|
});
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
var _JSON$stringify;
|
|
436
|
-
fs.writeFileSync(path.join(nycOutputPath, cov.hash + '.json'), JSON.stringify((_JSON$stringify = {}, _JSON$stringify[cov.path] = cov, _JSON$stringify)));
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
case 10:
|
|
479
|
+
writeCombinedCoverage(nycOutputPath, coverage);
|
|
480
|
+
case 12:
|
|
440
481
|
case "end":
|
|
441
482
|
return _context.stop();
|
|
442
483
|
}
|
|
443
484
|
}, _callee);
|
|
444
485
|
}));
|
|
445
|
-
return function
|
|
486
|
+
return function collectFrontendCoverage(_x) {
|
|
446
487
|
return _ref3.apply(this, arguments);
|
|
447
488
|
};
|
|
448
489
|
}();
|
|
449
|
-
|
|
490
|
+
var writeCoverage = function writeCoverage(nycOutputPath, nameSuffix, coverage) {
|
|
491
|
+
Object.values(coverage).forEach(function (value) {
|
|
492
|
+
if (value && value.path && value.hash) {
|
|
493
|
+
var _JSON$stringify;
|
|
494
|
+
var filename = path.join(nycOutputPath, "" + value.hash + nameSuffix + ".json");
|
|
495
|
+
debug('Writing coverage:', value.path, value.hash);
|
|
496
|
+
fs.writeFileSync(filename, JSON.stringify((_JSON$stringify = {}, _JSON$stringify[value.path] = value, _JSON$stringify), null, 2));
|
|
497
|
+
} else {
|
|
498
|
+
debug('Skip write coverage. Missing path or hash:', value);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
};
|
|
450
502
|
/**
|
|
451
|
-
*
|
|
503
|
+
* Collects backend coverage reports from the provided URLs and stores them in the coverage folder
|
|
452
504
|
*/
|
|
453
|
-
var
|
|
454
|
-
var
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
505
|
+
var collectBackendCoverage = /*#__PURE__*/function () {
|
|
506
|
+
var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref4) {
|
|
507
|
+
var coveragePath, coverageUrls, nycOutputPath, serverReports;
|
|
508
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
509
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
510
|
+
case 0:
|
|
511
|
+
coveragePath = _ref4.coveragePath, coverageUrls = _ref4.coverageUrls;
|
|
512
|
+
nycOutputPath = path.join(coveragePath, '.nyc_output');
|
|
513
|
+
debug('Collecting backend coverage reports', coverageUrls);
|
|
514
|
+
_context2.next = 5;
|
|
515
|
+
return Promise.all(coverageUrls.map(function (url) {
|
|
516
|
+
return fetch(url).then(function (res) {
|
|
517
|
+
var _res$headers$get;
|
|
518
|
+
if (res.ok && res.status === 200 && (_res$headers$get = res.headers.get('content-type')) != null && _res$headers$get.includes('application/json')) {
|
|
519
|
+
return res.json();
|
|
520
|
+
}
|
|
521
|
+
debug('Error fetching coverage report:', {
|
|
522
|
+
url: url,
|
|
523
|
+
status: res.status
|
|
524
|
+
});
|
|
525
|
+
return null;
|
|
526
|
+
})["catch"](function () {
|
|
527
|
+
debug('Error fetching coverage report:', {
|
|
528
|
+
url: url
|
|
529
|
+
});
|
|
530
|
+
return null;
|
|
531
|
+
});
|
|
532
|
+
}));
|
|
533
|
+
case 5:
|
|
534
|
+
serverReports = _context2.sent;
|
|
535
|
+
serverReports.forEach(function (report, index) {
|
|
536
|
+
writeCoverage(nycOutputPath, "-backend" + index, report.coverage);
|
|
537
|
+
});
|
|
538
|
+
case 7:
|
|
539
|
+
case "end":
|
|
540
|
+
return _context2.stop();
|
|
541
|
+
}
|
|
542
|
+
}, _callee2);
|
|
543
|
+
}));
|
|
544
|
+
return function collectBackendCoverage(_x2) {
|
|
545
|
+
return _ref5.apply(this, arguments);
|
|
546
|
+
};
|
|
547
|
+
}();
|
|
458
548
|
|
|
459
549
|
var _excluded = ["captureBeyondViewport"],
|
|
460
550
|
_excluded2 = ["userAgent", "isDarkMode", "viewport", "cookies"];
|
|
461
|
-
var _pkg$acceptanceTests, _ref, _projectConfig$covera;
|
|
551
|
+
var _pkg$acceptanceTests, _ref, _projectConfig$covera, _projectConfig$covera2;
|
|
462
552
|
var LINUX_DOCKER_HOST_IP = '172.17.0.1';
|
|
463
553
|
var getGlobalBrowser = function getGlobalBrowser() {
|
|
464
554
|
return global.browser;
|
|
@@ -530,8 +620,10 @@ var serverHostName = /*#__PURE__*/function () {
|
|
|
530
620
|
var rootDir = /*#__PURE__*/findRoot( /*#__PURE__*/process.cwd());
|
|
531
621
|
var pkg = /*#__PURE__*/JSON.parse( /*#__PURE__*/fs.readFileSync( /*#__PURE__*/path.join(rootDir, 'package.json'), 'utf-8'));
|
|
532
622
|
var projectConfig = (_pkg$acceptanceTests = pkg.acceptanceTests) != null ? _pkg$acceptanceTests : {};
|
|
623
|
+
debug('Project config:', projectConfig);
|
|
533
624
|
var server = (_ref = isCi ? projectConfig.ciServer : projectConfig.devServer) != null ? _ref : projectConfig.server;
|
|
534
625
|
var coveragePath = /*#__PURE__*/path.join(rootDir, (_projectConfig$covera = projectConfig.coveragePath) != null ? _projectConfig$covera : 'reports/coverage-acceptance');
|
|
626
|
+
var coverageUrls = (_projectConfig$covera2 = projectConfig.coverageUrls) != null ? _projectConfig$covera2 : [];
|
|
535
627
|
var serverPort = server == null ? void 0 : server.port;
|
|
536
628
|
var toMatchImageSnapshot = /*#__PURE__*/configureToMatchImageSnapshot({
|
|
537
629
|
failureThreshold: 0,
|
|
@@ -781,22 +873,41 @@ var getPageApi = function getPageApi(page) {
|
|
|
781
873
|
};
|
|
782
874
|
var needsRequestInterception = false;
|
|
783
875
|
var requestHandlers = [];
|
|
784
|
-
var requestInterceptor = function
|
|
785
|
-
var
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
876
|
+
var requestInterceptor = /*#__PURE__*/function () {
|
|
877
|
+
var _ref11 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(req) {
|
|
878
|
+
var _requestHandlers$find;
|
|
879
|
+
var _ref12, handler, response;
|
|
880
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
881
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
882
|
+
case 0:
|
|
883
|
+
_ref12 = (_requestHandlers$find = requestHandlers.find(function (_ref13) {
|
|
884
|
+
var matcher = _ref13.matcher;
|
|
885
|
+
return matcher(req);
|
|
886
|
+
})) != null ? _requestHandlers$find : {
|
|
887
|
+
handler: null
|
|
888
|
+
}, handler = _ref12.handler;
|
|
889
|
+
if (handler) {
|
|
890
|
+
_context7.next = 4;
|
|
891
|
+
break;
|
|
892
|
+
}
|
|
893
|
+
req["continue"]();
|
|
894
|
+
return _context7.abrupt("return");
|
|
895
|
+
case 4:
|
|
896
|
+
_context7.next = 6;
|
|
897
|
+
return handler(req);
|
|
898
|
+
case 6:
|
|
899
|
+
response = _context7.sent;
|
|
900
|
+
req.respond(response);
|
|
901
|
+
case 8:
|
|
902
|
+
case "end":
|
|
903
|
+
return _context7.stop();
|
|
904
|
+
}
|
|
905
|
+
}, _callee7);
|
|
906
|
+
}));
|
|
907
|
+
return function requestInterceptor(_x11) {
|
|
908
|
+
return _ref11.apply(this, arguments);
|
|
909
|
+
};
|
|
910
|
+
}();
|
|
800
911
|
var interceptRequest = function interceptRequest(matcher) {
|
|
801
912
|
needsRequestInterception = true;
|
|
802
913
|
var spy = jest.fn();
|
|
@@ -807,11 +918,11 @@ var interceptRequest = function interceptRequest(matcher) {
|
|
|
807
918
|
return spy;
|
|
808
919
|
};
|
|
809
920
|
var createApiEndpointMock = function createApiEndpointMock(_temp3) {
|
|
810
|
-
var
|
|
811
|
-
var
|
|
812
|
-
origin =
|
|
813
|
-
baseUrl =
|
|
814
|
-
var originRegExp = globToRegExp((
|
|
921
|
+
var _ref15;
|
|
922
|
+
var _ref14 = _temp3 === void 0 ? {} : _temp3,
|
|
923
|
+
origin = _ref14.origin,
|
|
924
|
+
baseUrl = _ref14.baseUrl;
|
|
925
|
+
var originRegExp = globToRegExp((_ref15 = origin != null ? origin : baseUrl) != null ? _ref15 : '*');
|
|
815
926
|
interceptRequest(function (req) {
|
|
816
927
|
var _URL = new URL(req.url()),
|
|
817
928
|
origin = _URL.origin;
|
|
@@ -840,31 +951,48 @@ var createApiEndpointMock = function createApiEndpointMock(_temp3) {
|
|
|
840
951
|
return req.method() === method && !!origin.match(originRegExp) && matchPath(spiedPath, pathWithParams);
|
|
841
952
|
};
|
|
842
953
|
var spy = jest.fn();
|
|
843
|
-
interceptRequest(matcher).mockImplementation(function (
|
|
844
|
-
var
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
954
|
+
interceptRequest(matcher).mockImplementation( /*#__PURE__*/function () {
|
|
955
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(req) {
|
|
956
|
+
var _spyResult$status;
|
|
957
|
+
var spyResult, status, resBody;
|
|
958
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
959
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
960
|
+
case 0:
|
|
961
|
+
_context8.next = 2;
|
|
962
|
+
return spy(req);
|
|
963
|
+
case 2:
|
|
964
|
+
spyResult = _context8.sent;
|
|
965
|
+
status = (_spyResult$status = spyResult.status) != null ? _spyResult$status : 200;
|
|
966
|
+
resBody = spyResult.body || spyResult;
|
|
967
|
+
return _context8.abrupt("return", {
|
|
968
|
+
status: status,
|
|
969
|
+
headers: {
|
|
970
|
+
'Access-Control-Allow-Origin': '*'
|
|
971
|
+
},
|
|
972
|
+
contentType: 'application/json',
|
|
973
|
+
body: JSON.stringify(resBody)
|
|
974
|
+
});
|
|
975
|
+
case 6:
|
|
976
|
+
case "end":
|
|
977
|
+
return _context8.stop();
|
|
978
|
+
}
|
|
979
|
+
}, _callee8);
|
|
980
|
+
}));
|
|
981
|
+
return function (_x12) {
|
|
982
|
+
return _ref16.apply(this, arguments);
|
|
855
983
|
};
|
|
856
|
-
});
|
|
984
|
+
}());
|
|
857
985
|
return spy;
|
|
858
986
|
}
|
|
859
987
|
};
|
|
860
988
|
};
|
|
861
989
|
var openPage = /*#__PURE__*/function () {
|
|
862
|
-
var
|
|
990
|
+
var _ref18 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref17) {
|
|
863
991
|
var userAgent, isDarkMode, viewport, cookies, urlConfig, url, currentUserAgent, page, connectionError;
|
|
864
|
-
return _regeneratorRuntime().wrap(function
|
|
865
|
-
while (1) switch (
|
|
992
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
993
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
866
994
|
case 0:
|
|
867
|
-
userAgent =
|
|
995
|
+
userAgent = _ref17.userAgent, isDarkMode = _ref17.isDarkMode, viewport = _ref17.viewport, cookies = _ref17.cookies, urlConfig = /*#__PURE__*/_objectWithoutPropertiesLoose(_ref17, _excluded2);
|
|
868
996
|
url = function () {
|
|
869
997
|
if (urlConfig.url !== undefined) {
|
|
870
998
|
return urlConfig.url;
|
|
@@ -883,45 +1011,46 @@ var openPage = /*#__PURE__*/function () {
|
|
|
883
1011
|
}
|
|
884
1012
|
return protocol + "://" + hostname + ":" + port + path;
|
|
885
1013
|
}();
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
1014
|
+
debug('Opening page:', url);
|
|
1015
|
+
_context9.t0 = userAgent;
|
|
1016
|
+
if (_context9.t0) {
|
|
1017
|
+
_context9.next = 8;
|
|
889
1018
|
break;
|
|
890
1019
|
}
|
|
891
|
-
|
|
1020
|
+
_context9.next = 7;
|
|
892
1021
|
return getGlobalBrowser().userAgent();
|
|
893
|
-
case 6:
|
|
894
|
-
_context7.t0 = _context7.sent;
|
|
895
1022
|
case 7:
|
|
896
|
-
|
|
1023
|
+
_context9.t0 = _context9.sent;
|
|
1024
|
+
case 8:
|
|
1025
|
+
currentUserAgent = _context9.t0;
|
|
897
1026
|
page = getGlobalPage$1();
|
|
898
|
-
|
|
1027
|
+
_context9.next = 12;
|
|
899
1028
|
return page.bringToFront();
|
|
900
|
-
case
|
|
1029
|
+
case 12:
|
|
901
1030
|
if (!viewport) {
|
|
902
|
-
|
|
1031
|
+
_context9.next = 15;
|
|
903
1032
|
break;
|
|
904
1033
|
}
|
|
905
|
-
|
|
1034
|
+
_context9.next = 15;
|
|
906
1035
|
return page.setViewport(viewport);
|
|
907
|
-
case
|
|
1036
|
+
case 15:
|
|
908
1037
|
if (!cookies) {
|
|
909
|
-
|
|
1038
|
+
_context9.next = 18;
|
|
910
1039
|
break;
|
|
911
1040
|
}
|
|
912
|
-
|
|
1041
|
+
_context9.next = 18;
|
|
913
1042
|
return page.setCookie.apply(page, cookies);
|
|
914
|
-
case
|
|
915
|
-
|
|
1043
|
+
case 18:
|
|
1044
|
+
_context9.next = 20;
|
|
916
1045
|
return page.setUserAgent(currentUserAgent + " acceptance-test");
|
|
917
|
-
case
|
|
918
|
-
|
|
1046
|
+
case 20:
|
|
1047
|
+
_context9.next = 22;
|
|
919
1048
|
return page.emulateMediaFeatures([{
|
|
920
1049
|
name: 'prefers-color-scheme',
|
|
921
1050
|
value: isDarkMode ? 'dark' : 'light'
|
|
922
1051
|
}]);
|
|
923
|
-
case
|
|
924
|
-
|
|
1052
|
+
case 22:
|
|
1053
|
+
_context9.next = 24;
|
|
925
1054
|
return page.evaluateOnNewDocument(function (viewport) {
|
|
926
1055
|
var _viewport$safeAreaIns;
|
|
927
1056
|
var overriddenSafeAreaInsets = !viewport ? [] : Object.keys((_viewport$safeAreaIns = viewport == null ? void 0 : viewport.safeAreaInset) != null ? _viewport$safeAreaIns : {}).map(function (key) {
|
|
@@ -935,59 +1064,59 @@ var openPage = /*#__PURE__*/function () {
|
|
|
935
1064
|
document.head.appendChild(style);
|
|
936
1065
|
});
|
|
937
1066
|
}, viewport);
|
|
938
|
-
case
|
|
1067
|
+
case 24:
|
|
939
1068
|
if (!needsRequestInterception) {
|
|
940
|
-
|
|
1069
|
+
_context9.next = 28;
|
|
941
1070
|
break;
|
|
942
1071
|
}
|
|
943
|
-
|
|
1072
|
+
_context9.next = 27;
|
|
944
1073
|
return page.setRequestInterception(true);
|
|
945
|
-
case 26:
|
|
946
|
-
page.on('request', requestInterceptor);
|
|
947
1074
|
case 27:
|
|
948
|
-
|
|
949
|
-
|
|
1075
|
+
page.on('request', requestInterceptor);
|
|
1076
|
+
case 28:
|
|
1077
|
+
_context9.prev = 28;
|
|
1078
|
+
_context9.next = 31;
|
|
950
1079
|
return page["goto"](url);
|
|
951
|
-
case
|
|
952
|
-
|
|
1080
|
+
case 31:
|
|
1081
|
+
_context9.next = 42;
|
|
953
1082
|
break;
|
|
954
|
-
case
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
if (!
|
|
958
|
-
|
|
1083
|
+
case 33:
|
|
1084
|
+
_context9.prev = 33;
|
|
1085
|
+
_context9.t1 = _context9["catch"](28);
|
|
1086
|
+
if (!_context9.t1.message.includes('net::ERR_CONNECTION_REFUSED')) {
|
|
1087
|
+
_context9.next = 41;
|
|
959
1088
|
break;
|
|
960
1089
|
}
|
|
961
1090
|
connectionError = new Error("Could not connect to " + url + ". Is the server running?");
|
|
962
1091
|
Error.captureStackTrace(connectionError, openPage);
|
|
963
1092
|
throw connectionError;
|
|
964
|
-
case 40:
|
|
965
|
-
throw _context7.t1;
|
|
966
1093
|
case 41:
|
|
967
|
-
|
|
1094
|
+
throw _context9.t1;
|
|
1095
|
+
case 42:
|
|
1096
|
+
_context9.next = 44;
|
|
968
1097
|
return page.waitForFunction('document.fonts.status === "loaded"');
|
|
969
|
-
case 43:
|
|
970
|
-
return _context7.abrupt("return", getPageApi(page));
|
|
971
1098
|
case 44:
|
|
1099
|
+
return _context9.abrupt("return", getPageApi(page));
|
|
1100
|
+
case 45:
|
|
972
1101
|
case "end":
|
|
973
|
-
return
|
|
1102
|
+
return _context9.stop();
|
|
974
1103
|
}
|
|
975
|
-
},
|
|
1104
|
+
}, _callee9, null, [[28, 33]]);
|
|
976
1105
|
}));
|
|
977
|
-
return function openPage(
|
|
978
|
-
return
|
|
1106
|
+
return function openPage(_x13) {
|
|
1107
|
+
return _ref18.apply(this, arguments);
|
|
979
1108
|
};
|
|
980
1109
|
}();
|
|
981
1110
|
var buildQueryMethods = function buildQueryMethods(_temp4) {
|
|
982
|
-
var
|
|
983
|
-
page =
|
|
984
|
-
element =
|
|
1111
|
+
var _ref19 = _temp4 === void 0 ? {} : _temp4,
|
|
1112
|
+
page = _ref19.page,
|
|
1113
|
+
element = _ref19.element;
|
|
985
1114
|
var boundQueries = {};
|
|
986
1115
|
var _loop = function _loop() {
|
|
987
1116
|
var _Object$entries$_i = _Object$entries[_i],
|
|
988
1117
|
queryName = _Object$entries$_i[0],
|
|
989
1118
|
queryFn = _Object$entries$_i[1];
|
|
990
|
-
boundQueries[queryName] = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1119
|
+
boundQueries[queryName] = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
991
1120
|
var doc,
|
|
992
1121
|
body,
|
|
993
1122
|
_len2,
|
|
@@ -996,20 +1125,20 @@ var buildQueryMethods = function buildQueryMethods(_temp4) {
|
|
|
996
1125
|
queryArgs,
|
|
997
1126
|
elementHandle,
|
|
998
1127
|
newElementHandle,
|
|
999
|
-
|
|
1000
|
-
return _regeneratorRuntime().wrap(function
|
|
1001
|
-
while (1) switch (
|
|
1128
|
+
_args14 = arguments;
|
|
1129
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1130
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1002
1131
|
case 0:
|
|
1003
|
-
|
|
1132
|
+
_context14.next = 2;
|
|
1004
1133
|
return getDocument(page != null ? page : getGlobalPage$1());
|
|
1005
1134
|
case 2:
|
|
1006
|
-
doc =
|
|
1007
|
-
|
|
1135
|
+
doc = _context14.sent;
|
|
1136
|
+
_context14.next = 5;
|
|
1008
1137
|
return doc.$('body');
|
|
1009
1138
|
case 5:
|
|
1010
|
-
body =
|
|
1011
|
-
for (_len2 =
|
|
1012
|
-
args[_key2] =
|
|
1139
|
+
body = _context14.sent;
|
|
1140
|
+
for (_len2 = _args14.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1141
|
+
args[_key2] = _args14[_key2];
|
|
1013
1142
|
}
|
|
1014
1143
|
queryArgs = [].concat(args);
|
|
1015
1144
|
if (queryName.startsWith('findBy')) {
|
|
@@ -1020,98 +1149,98 @@ var buildQueryMethods = function buildQueryMethods(_temp4) {
|
|
|
1020
1149
|
timeout: 10000
|
|
1021
1150
|
});
|
|
1022
1151
|
}
|
|
1023
|
-
|
|
1152
|
+
_context14.next = 11;
|
|
1024
1153
|
return queryFn.apply(void 0, [element != null ? element : body].concat(queryArgs));
|
|
1025
1154
|
case 11:
|
|
1026
|
-
elementHandle =
|
|
1155
|
+
elementHandle = _context14.sent;
|
|
1027
1156
|
newElementHandle = Object.create(elementHandle);
|
|
1028
1157
|
newElementHandle.screenshot = /*#__PURE__*/function () {
|
|
1029
|
-
var
|
|
1030
|
-
return _regeneratorRuntime().wrap(function
|
|
1031
|
-
while (1) switch (
|
|
1158
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(options) {
|
|
1159
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1160
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1032
1161
|
case 0:
|
|
1033
1162
|
if (options != null && options.skipNetworkWait) {
|
|
1034
|
-
|
|
1163
|
+
_context10.next = 3;
|
|
1035
1164
|
break;
|
|
1036
1165
|
}
|
|
1037
|
-
|
|
1166
|
+
_context10.next = 3;
|
|
1038
1167
|
return (page != null ? page : getGlobalPage$1()).waitForNetworkIdle();
|
|
1039
1168
|
case 3:
|
|
1040
|
-
|
|
1169
|
+
_context10.next = 5;
|
|
1041
1170
|
return waitForPaintEnd(elementHandle, _extends({}, options, {
|
|
1042
1171
|
fullPage: false
|
|
1043
1172
|
}));
|
|
1044
1173
|
case 5:
|
|
1045
|
-
return
|
|
1174
|
+
return _context10.abrupt("return", elementHandle.screenshot(normalizeSreenshotOptions(options)));
|
|
1046
1175
|
case 6:
|
|
1047
1176
|
case "end":
|
|
1048
|
-
return
|
|
1177
|
+
return _context10.stop();
|
|
1049
1178
|
}
|
|
1050
|
-
},
|
|
1179
|
+
}, _callee10);
|
|
1051
1180
|
}));
|
|
1052
|
-
return function (
|
|
1053
|
-
return
|
|
1181
|
+
return function (_x14) {
|
|
1182
|
+
return _ref21.apply(this, arguments);
|
|
1054
1183
|
};
|
|
1055
1184
|
}();
|
|
1056
1185
|
newElementHandle.click = /*#__PURE__*/function () {
|
|
1057
|
-
var
|
|
1058
|
-
return _regeneratorRuntime().wrap(function
|
|
1059
|
-
while (1) switch (
|
|
1186
|
+
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
|
|
1187
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1188
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1060
1189
|
case 0:
|
|
1061
|
-
|
|
1190
|
+
_context11.next = 2;
|
|
1062
1191
|
return scrollIntoView(elementHandle);
|
|
1063
1192
|
case 2:
|
|
1064
|
-
return
|
|
1193
|
+
return _context11.abrupt("return", elementHandle.click(options));
|
|
1065
1194
|
case 3:
|
|
1066
1195
|
case "end":
|
|
1067
|
-
return
|
|
1196
|
+
return _context11.stop();
|
|
1068
1197
|
}
|
|
1069
|
-
},
|
|
1198
|
+
}, _callee11);
|
|
1070
1199
|
}));
|
|
1071
|
-
return function (
|
|
1072
|
-
return
|
|
1200
|
+
return function (_x15) {
|
|
1201
|
+
return _ref22.apply(this, arguments);
|
|
1073
1202
|
};
|
|
1074
1203
|
}();
|
|
1075
1204
|
newElementHandle.type = /*#__PURE__*/function () {
|
|
1076
|
-
var
|
|
1077
|
-
return _regeneratorRuntime().wrap(function
|
|
1078
|
-
while (1) switch (
|
|
1205
|
+
var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(text, options) {
|
|
1206
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1207
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1079
1208
|
case 0:
|
|
1080
|
-
|
|
1209
|
+
_context12.next = 2;
|
|
1081
1210
|
return scrollIntoView(elementHandle);
|
|
1082
1211
|
case 2:
|
|
1083
|
-
return
|
|
1212
|
+
return _context12.abrupt("return", elementHandle.type(text, options));
|
|
1084
1213
|
case 3:
|
|
1085
1214
|
case "end":
|
|
1086
|
-
return
|
|
1215
|
+
return _context12.stop();
|
|
1087
1216
|
}
|
|
1088
|
-
},
|
|
1217
|
+
}, _callee12);
|
|
1089
1218
|
}));
|
|
1090
|
-
return function (
|
|
1091
|
-
return
|
|
1219
|
+
return function (_x16, _x17) {
|
|
1220
|
+
return _ref23.apply(this, arguments);
|
|
1092
1221
|
};
|
|
1093
1222
|
}();
|
|
1094
|
-
newElementHandle.select = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1095
|
-
var
|
|
1096
|
-
return _regeneratorRuntime().wrap(function
|
|
1097
|
-
while (1) switch (
|
|
1223
|
+
newElementHandle.select = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
1224
|
+
var _args13 = arguments;
|
|
1225
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1226
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1098
1227
|
case 0:
|
|
1099
|
-
|
|
1228
|
+
_context13.next = 2;
|
|
1100
1229
|
return scrollIntoView(elementHandle);
|
|
1101
1230
|
case 2:
|
|
1102
|
-
return
|
|
1231
|
+
return _context13.abrupt("return", elementHandle.select.apply(elementHandle, _args13));
|
|
1103
1232
|
case 3:
|
|
1104
1233
|
case "end":
|
|
1105
|
-
return
|
|
1234
|
+
return _context13.stop();
|
|
1106
1235
|
}
|
|
1107
|
-
},
|
|
1236
|
+
}, _callee13);
|
|
1108
1237
|
}));
|
|
1109
|
-
return
|
|
1238
|
+
return _context14.abrupt("return", newElementHandle);
|
|
1110
1239
|
case 18:
|
|
1111
1240
|
case "end":
|
|
1112
|
-
return
|
|
1241
|
+
return _context14.stop();
|
|
1113
1242
|
}
|
|
1114
|
-
},
|
|
1243
|
+
}, _callee14);
|
|
1115
1244
|
}));
|
|
1116
1245
|
};
|
|
1117
1246
|
for (var _i = 0, _Object$entries = Object.entries(queries); _i < _Object$entries.length; _i++) {
|
|
@@ -1130,50 +1259,73 @@ var within = function within(element) {
|
|
|
1130
1259
|
element: element
|
|
1131
1260
|
});
|
|
1132
1261
|
};
|
|
1133
|
-
beforeEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1134
|
-
return _regeneratorRuntime().wrap(function
|
|
1135
|
-
while (1) switch (
|
|
1262
|
+
beforeEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
1263
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1264
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1136
1265
|
case 0:
|
|
1137
|
-
|
|
1266
|
+
_context15.next = 2;
|
|
1138
1267
|
return getGlobalPage$1().setRequestInterception(false);
|
|
1139
1268
|
case 2:
|
|
1140
|
-
|
|
1269
|
+
_context15.next = 4;
|
|
1141
1270
|
return global.jestPuppeteer.resetPage();
|
|
1142
1271
|
case 4:
|
|
1143
1272
|
case "end":
|
|
1144
|
-
return
|
|
1273
|
+
return _context15.stop();
|
|
1145
1274
|
}
|
|
1146
|
-
},
|
|
1275
|
+
}, _callee15);
|
|
1147
1276
|
})));
|
|
1148
|
-
afterEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1277
|
+
afterEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1149
1278
|
var page;
|
|
1150
|
-
return _regeneratorRuntime().wrap(function
|
|
1151
|
-
while (1) switch (
|
|
1279
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1280
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1152
1281
|
case 0:
|
|
1153
|
-
|
|
1154
|
-
|
|
1282
|
+
if (!process.env.COLLECT_ACCEPTANCE_COVERAGE) {
|
|
1283
|
+
_context16.next = 3;
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
_context16.next = 3;
|
|
1287
|
+
return collectFrontendCoverage({
|
|
1155
1288
|
coveragePath: coveragePath
|
|
1156
1289
|
});
|
|
1157
|
-
case
|
|
1158
|
-
|
|
1290
|
+
case 3:
|
|
1291
|
+
_context16.prev = 3;
|
|
1159
1292
|
page = getGlobalPage$1();
|
|
1160
1293
|
requestHandlers = [];
|
|
1161
1294
|
needsRequestInterception = false;
|
|
1162
1295
|
page.off('request', requestInterceptor);
|
|
1163
1296
|
// clear tab, this way we clear the DOM and stop js execution or pending requests
|
|
1164
|
-
|
|
1297
|
+
_context16.next = 10;
|
|
1165
1298
|
return page["goto"]('about:blank');
|
|
1166
|
-
case
|
|
1167
|
-
|
|
1299
|
+
case 10:
|
|
1300
|
+
_context16.next = 14;
|
|
1168
1301
|
break;
|
|
1169
|
-
case
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
case
|
|
1302
|
+
case 12:
|
|
1303
|
+
_context16.prev = 12;
|
|
1304
|
+
_context16.t0 = _context16["catch"](3);
|
|
1305
|
+
case 14:
|
|
1306
|
+
case "end":
|
|
1307
|
+
return _context16.stop();
|
|
1308
|
+
}
|
|
1309
|
+
}, _callee16, null, [[3, 12]]);
|
|
1310
|
+
})));
|
|
1311
|
+
afterAll( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1312
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1313
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1314
|
+
case 0:
|
|
1315
|
+
if (!process.env.COLLECT_ACCEPTANCE_COVERAGE) {
|
|
1316
|
+
_context17.next = 3;
|
|
1317
|
+
break;
|
|
1318
|
+
}
|
|
1319
|
+
_context17.next = 3;
|
|
1320
|
+
return collectBackendCoverage({
|
|
1321
|
+
coveragePath: coveragePath,
|
|
1322
|
+
coverageUrls: coverageUrls
|
|
1323
|
+
});
|
|
1324
|
+
case 3:
|
|
1173
1325
|
case "end":
|
|
1174
|
-
return
|
|
1326
|
+
return _context17.stop();
|
|
1175
1327
|
}
|
|
1176
|
-
},
|
|
1328
|
+
}, _callee17);
|
|
1177
1329
|
})));
|
|
1178
1330
|
/**
|
|
1179
1331
|
* Returns a new path to the file that can be used by chromium in acceptance tests
|
|
@@ -1249,44 +1401,44 @@ var waitForElementToBeRemoved = function waitForElementToBeRemoved(element, time
|
|
|
1249
1401
|
}
|
|
1250
1402
|
var startStack = new Error().stack;
|
|
1251
1403
|
var wait = /*#__PURE__*/function () {
|
|
1252
|
-
var
|
|
1404
|
+
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1253
1405
|
var t0, box;
|
|
1254
|
-
return _regeneratorRuntime().wrap(function
|
|
1255
|
-
while (1) switch (
|
|
1406
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1407
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1256
1408
|
case 0:
|
|
1257
1409
|
t0 = Date.now();
|
|
1258
1410
|
case 1:
|
|
1259
1411
|
if (!(Date.now() - t0 < timeout)) {
|
|
1260
|
-
|
|
1412
|
+
_context18.next = 11;
|
|
1261
1413
|
break;
|
|
1262
1414
|
}
|
|
1263
|
-
|
|
1415
|
+
_context18.next = 4;
|
|
1264
1416
|
return element.boundingBox();
|
|
1265
1417
|
case 4:
|
|
1266
|
-
box =
|
|
1418
|
+
box = _context18.sent;
|
|
1267
1419
|
if (box) {
|
|
1268
|
-
|
|
1420
|
+
_context18.next = 7;
|
|
1269
1421
|
break;
|
|
1270
1422
|
}
|
|
1271
|
-
return
|
|
1423
|
+
return _context18.abrupt("return");
|
|
1272
1424
|
case 7:
|
|
1273
|
-
|
|
1425
|
+
_context18.next = 9;
|
|
1274
1426
|
return new Promise(function (resolve) {
|
|
1275
1427
|
return setTimeout(resolve, interval);
|
|
1276
1428
|
});
|
|
1277
1429
|
case 9:
|
|
1278
|
-
|
|
1430
|
+
_context18.next = 1;
|
|
1279
1431
|
break;
|
|
1280
1432
|
case 11:
|
|
1281
1433
|
throw new Error('Element not removed');
|
|
1282
1434
|
case 12:
|
|
1283
1435
|
case "end":
|
|
1284
|
-
return
|
|
1436
|
+
return _context18.stop();
|
|
1285
1437
|
}
|
|
1286
|
-
},
|
|
1438
|
+
}, _callee18);
|
|
1287
1439
|
}));
|
|
1288
1440
|
return function wait() {
|
|
1289
|
-
return
|
|
1441
|
+
return _ref28.apply(this, arguments);
|
|
1290
1442
|
};
|
|
1291
1443
|
}();
|
|
1292
1444
|
return wait()["catch"](function (error) {
|