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