@applitools/eyes-cypress 3.23.7 → 3.24.0-beta.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +2188 -2175
  2. package/LICENSE +25 -25
  3. package/README.md +778 -769
  4. package/commands.js +2 -2
  5. package/dist/browser/spec-driver.js +104 -0
  6. package/dist/plugin/handler.js +55 -0
  7. package/eyes-index.d.ts +34 -34
  8. package/index.js +2 -2
  9. package/package.json +97 -81
  10. package/src/browser/commands.js +167 -147
  11. package/src/browser/eyesCheckMapping.js +71 -0
  12. package/src/browser/eyesOpenMapping.js +34 -0
  13. package/src/browser/makeSend.js +18 -22
  14. package/src/browser/refer.js +57 -0
  15. package/src/browser/sendRequest.js +16 -16
  16. package/src/browser/socket.js +143 -0
  17. package/src/browser/socketCommands.js +81 -0
  18. package/src/browser/spec-driver.ts +109 -0
  19. package/src/pem/server.cert +22 -22
  20. package/src/pem/server.key +27 -27
  21. package/src/plugin/concurrencyMsg.js +8 -8
  22. package/src/plugin/config.js +54 -52
  23. package/src/plugin/defaultPort.js +1 -1
  24. package/src/plugin/errorDigest.js +96 -96
  25. package/src/plugin/getErrorsAndDiffs.js +34 -34
  26. package/src/plugin/handleTestResults.js +39 -0
  27. package/src/plugin/handler.ts +58 -0
  28. package/src/plugin/hooks.js +49 -42
  29. package/src/plugin/isGlobalHooksSupported.js +13 -13
  30. package/src/plugin/pluginExport.js +60 -57
  31. package/src/plugin/server.js +98 -46
  32. package/src/plugin/startPlugin.js +13 -34
  33. package/src/plugin/webSocket.js +130 -0
  34. package/src/setup/addEyesCommands.js +24 -24
  35. package/src/setup/addEyesCypressPlugin.js +15 -15
  36. package/src/setup/getCypressConfig.js +16 -16
  37. package/src/setup/getFilePath.js +22 -22
  38. package/src/setup/handleCommands.js +23 -23
  39. package/src/setup/handlePlugin.js +23 -23
  40. package/src/setup/handleTypeScript.js +21 -21
  41. package/src/setup/isCommandsDefined.js +7 -7
  42. package/src/setup/isPluginDefined.js +7 -7
  43. package/test/fixtures/testAppCopies/.gitignore +1 -1
  44. package/bin/eyes-setup.js +0 -21
  45. package/src/browser/eyesCheckWindow.js +0 -132
  46. package/src/browser/getAllBlobs.js +0 -14
  47. package/src/browser/getBrowserInfo.js +0 -39
  48. package/src/browser/makeHandleCypressViewport.js +0 -22
  49. package/src/browser/poll.js +0 -25
  50. package/src/plugin/app.js +0 -42
  51. package/src/plugin/handlers.js +0 -205
  52. package/src/plugin/makeHandleBatchResultsFile.js +0 -17
  53. package/src/plugin/pollingHandler.js +0 -46
  54. package/src/plugin/processCloseAndAbort.js +0 -33
  55. package/src/plugin/runningTests.js +0 -27
  56. package/src/plugin/waitForBatch.js +0 -33
package/bin/eyes-setup.js DELETED
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const chalk = require('chalk');
5
- const handlePlugin = require('../src/setup/handlePlugin');
6
- const handleCommands = require('../src/setup/handleCommands');
7
- const handleTypeScript = require('../src/setup/handleTypeScript');
8
- const {version} = require('../package');
9
- const cwd = process.cwd();
10
-
11
- console.log(chalk.cyan('Setup eyes-cypress', version));
12
-
13
- try {
14
- handlePlugin(cwd);
15
- handleCommands(cwd);
16
- handleTypeScript(cwd);
17
- } catch (e) {
18
- console.log(chalk.red('Setup error:\n', e));
19
- }
20
-
21
- console.log(chalk.cyan('Setup done!'));
@@ -1,132 +0,0 @@
1
- /* global cy*/
2
- 'use strict';
3
-
4
- const getAllBlobs = require('./getAllBlobs');
5
- const getBrowserInfo = require('./getBrowserInfo');
6
-
7
- function makeEyesCheckWindow({sendRequest, processPage, domSnapshotOptions, cypress = cy}) {
8
- return function eyesCheckWindow(doc, args = {}) {
9
- return takeDomSnapshots(domSnapshotOptions).then(snapshot => {
10
- // console.log("%cDone taking snapshots!", "color:chartreuse");
11
- return sendRequest({
12
- command: 'checkWindow',
13
- data: {
14
- url: Array.isArray(snapshot) ? snapshot[0].url : snapshot.url,
15
- snapshot,
16
- ...args,
17
- },
18
- });
19
- });
20
-
21
- function takeDomSnapshots(options) {
22
- const browser = args.browser;
23
- const breakpoints = args.layoutBreakpoints;
24
- const waitBeforeCapture = args.waitBeforeCapture ? args.waitBeforeCapture : 100;
25
- const browsers = Array.isArray(browser) ? browser : [browser];
26
-
27
- if (!breakpoints) {
28
- //console.log('no breakpoints, taking single dom snapshot');
29
- return cypress
30
- .wrap({}, {log: false})
31
- .wait(waitBeforeCapture)
32
- .then({log: false, timeout: 900000}, () => {
33
- return takeDomSnapshot(options);
34
- });
35
- }
36
-
37
- return browsers
38
- .reduce((widths, browser, index) => {
39
- return widths.then(widthsMap => {
40
- return getBrowserInfo(browser, sendRequest).then(({name, width}) => {
41
- const requiredWidth = getBreakpointWidth(breakpoints, width);
42
- let groupedBrowsers = widthsMap[requiredWidth];
43
- if (!groupedBrowsers) {
44
- groupedBrowsers = [];
45
- widthsMap[requiredWidth] = groupedBrowsers;
46
- }
47
- groupedBrowsers.push({index, width, name});
48
- return widthsMap;
49
- });
50
- });
51
- }, cypress.wrap({}, {log: false}))
52
- .then(requiredWidths => {
53
- const {innerWidth: width, innerHeight: height} = doc.defaultView;
54
- const snapshots = Array(browsers.length);
55
- const requiredWidthsKeys = Object.keys(requiredWidths);
56
- for (const requiredWidth of requiredWidthsKeys) {
57
- const browsersInfo = requiredWidths[requiredWidth];
58
- // console.log(`taking dom snapshot for width ${requiredWidth}`);
59
- cypress
60
- .viewport(Number(requiredWidth), height, {log: false})
61
- .wait(waitBeforeCapture, {log: false})
62
- .then({log: false, timeout: 900000}, () => {
63
- return takeDomSnapshot(options).then(snapshot => {
64
- browsersInfo.forEach(({index}) => (snapshots[index] = snapshot));
65
- });
66
- });
67
- }
68
- return cypress
69
- .viewport(width, height, {log: false})
70
- .wait(0, {log: false})
71
- .then(() => snapshots);
72
- });
73
- }
74
-
75
- function takeDomSnapshot(options) {
76
- // console.log(`take dom snapshot with ${doc.defaultView.innerWidth}`);
77
- return processPage(Object.assign({doc}, options)).then(mainFrame => {
78
- const allBlobs = getAllBlobs(mainFrame)
79
- .filter(blob => !blob.errorStatusCode)
80
- .map(mapBlob);
81
- const snapshot = replaceBlobsWithBlobDataInFrame(mainFrame);
82
- return Promise.all(allBlobs.map(putResource)).then(() => snapshot);
83
-
84
- function putResource({url, value}) {
85
- return sendRequest({
86
- command: `resource/${encodeURIComponent(url)}`,
87
- data: value,
88
- method: 'PUT',
89
- headers: {'Content-Type': 'application/octet-stream'},
90
- }).catch(_e => {
91
- snapshot.blobData.splice(
92
- snapshot.blobData.findIndex(({url: blobUrl}) => blobUrl === url),
93
- 1,
94
- );
95
- snapshot.resourceUrls.push(url);
96
- });
97
- }
98
- });
99
- }
100
-
101
- function getBreakpointWidth(breakpoints, width) {
102
- if (!Array.isArray(breakpoints) || breakpoints.length === 0) return width;
103
- const sortedBreakpoints = Array.from(new Set(breakpoints)).sort((a, b) => (a < b ? 1 : -1));
104
- const breakpoint = sortedBreakpoints.find(sortedBreakpoint => width >= sortedBreakpoint);
105
- return breakpoint || sortedBreakpoints[breakpoints.length - 1] - 1;
106
- }
107
- };
108
- }
109
-
110
- function replaceBlobsWithBlobDataInFrame({url, cdt, resourceUrls, blobs, frames}) {
111
- return {
112
- url,
113
- cdt,
114
- resourceUrls,
115
- blobData: blobs.map(mapBlobData),
116
- frames: frames.map(replaceBlobsWithBlobDataInFrame),
117
- };
118
- }
119
-
120
- function mapBlobData(blob) {
121
- if (blob.errorStatusCode) {
122
- return {url: blob.url, errorStatusCode: blob.errorStatusCode};
123
- } else {
124
- return {url: blob.url, type: blob.type || 'application/x-applitools-unknown'};
125
- }
126
- }
127
-
128
- function mapBlob({url, type, value}) {
129
- return {url, type: type || 'application/x-applitools-unknown', value};
130
- }
131
-
132
- module.exports = makeEyesCheckWindow;
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- function getAllBlobs(frame) {
4
- return uniq([
5
- ...frame.blobs,
6
- ...frame.frames.reduce((acc, frame) => [...acc, ...getAllBlobs(frame)], []),
7
- ]);
8
- }
9
-
10
- function uniq(arr) {
11
- return Array.from(new Set(arr)).filter(x => !!x);
12
- }
13
-
14
- module.exports = getAllBlobs;
@@ -1,39 +0,0 @@
1
- function getBrowserInfo(browser, sendRequest) {
2
- const isMobile =
3
- browser.deviceName || browser.mobile || browser.iosDeviceInfo || browser.chromeEmulationInfo;
4
- if (isMobile) {
5
- const {deviceName, screenOrientation = 'portrait'} =
6
- browser.iosDeviceInfo || browser.chromeEmulationInfo || browser;
7
- const command = browser.iosDeviceInfo ? 'getIosDevicesSizes' : 'getEmulatedDevicesSizes';
8
- return sendRequest({command}).then(devicesSizes => {
9
- if (!devicesSizes.hasOwnProperty(deviceName)) {
10
- handleDeviceError(browser);
11
- }
12
- const size = devicesSizes[deviceName][screenOrientation];
13
- return {name: deviceName, ...size};
14
- });
15
- } else {
16
- const {name, width} = browser;
17
- return Promise.resolve({name, width});
18
- }
19
- }
20
-
21
- function handleDeviceError(browser) {
22
- const baseUrl =
23
- 'https://github.com/applitools/eyes.sdk.javascript1/blob/master/packages/eyes-sdk-core/lib/config';
24
- const deviceName = browser.deviceName;
25
- const category = browser.iosDeviceInfo
26
- ? {
27
- name: 'iOS',
28
- url: `${baseUrl}/IosDeviceName.js`,
29
- }
30
- : {
31
- name: 'emulated',
32
- url: `${baseUrl}/DeviceName.js`,
33
- };
34
- throw new Error(
35
- `'${deviceName}' does not exist in the list of ${category.name} devices.\nplease see the device list at: ${category.url}`,
36
- );
37
- }
38
-
39
- module.exports = getBrowserInfo;
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- const makeHandleCypressViewport = ({cy}) => {
4
- return browser => {
5
- let rv = cy;
6
- if (Array.isArray(browser) && browser.length === 1) {
7
- browser = browser[0];
8
- }
9
-
10
- if (
11
- typeof browser === 'object' &&
12
- browser !== null &&
13
- browser.width !== undefined &&
14
- browser.height !== undefined
15
- ) {
16
- rv = rv.viewport(browser.width, browser.height, {log: false});
17
- }
18
- return rv;
19
- };
20
- };
21
-
22
- module.exports = makeHandleCypressViewport;
@@ -1,25 +0,0 @@
1
- 'use strict';
2
- function poll(doWork) {
3
- function doPoll(args) {
4
- return doWork(args).then(result => {
5
- if (result.status === 'WIP' || result.status === 'IDLE') {
6
- return new Promise((resolve, reject) => {
7
- setTimeout(() => {
8
- doPoll(args).then(
9
- results => resolve(results),
10
- err => reject(err),
11
- );
12
- }, 1000);
13
- });
14
- } else if (result.status === 'DONE') {
15
- return result.results;
16
- } else {
17
- throw new Error(result);
18
- }
19
- });
20
- }
21
-
22
- return doPoll;
23
- }
24
-
25
- module.exports = poll;
package/src/plugin/app.js DELETED
@@ -1,42 +0,0 @@
1
- 'use strict';
2
- const express = require('express');
3
- const bodyParser = require('body-parser');
4
- const cors = require('cors');
5
-
6
- function startApp({handlers, logger = console} = {}) {
7
- const app = express();
8
- app.use(cors());
9
- app.get('/hb', (_req, res) => res.sendStatus(200));
10
- app.get('/err', (_req, res) => res.status(500).send('this is a test error'));
11
-
12
- app.put('/eyes/resource/:id', bodyParser.raw({type: '*/*', limit: '100mb'}), async (req, res) => {
13
- try {
14
- if (!req.params || !req.params.id) throw new Error('missing resource url');
15
- const id = req.params.id; // already decoded by express with decodeURIComponent
16
- if (!(req.body instanceof Buffer)) throw new Error(`could not process resource ${id}`); // body-parser returned non-buffer body: https://github.com/expressjs/body-parser/blob/bd386d3a7d540bac90bbdaff88f653414f6647fc/lib/types/raw.js#L62
17
- const buffer = req.body;
18
- logger.log('[server] PUT resource:', id, buffer.length);
19
- handlers.putResource(id, buffer);
20
- res.status(200).send({success: true});
21
- } catch (ex) {
22
- logger.log('[server] error in PUT resource', req.params.id, ex);
23
- res.status(200).send({success: false, error: ex.message});
24
- }
25
- });
26
-
27
- app.post('/eyes/:command', express.json({limit: '100mb'}), async (req, res) => {
28
- logger.log(`[server] eyes api: ${req.params.command}`, Object.keys(req.body));
29
- try {
30
- const result = await handlers[req.params.command](req.body);
31
- res.set('Content-Type', 'application/json');
32
- res.status(200).send({success: true, result});
33
- } catch (ex) {
34
- logger.log('[server] error in eyes api:', ex);
35
- res.status(200).send({success: false, error: ex.message});
36
- }
37
- });
38
-
39
- return app;
40
- }
41
-
42
- module.exports = {startApp};
@@ -1,205 +0,0 @@
1
- 'use strict';
2
- const {presult} = require('@applitools/functional-commons');
3
- const pollingHandler = require('./pollingHandler');
4
- const makeWaitForBatch = require('./waitForBatch');
5
- const makeHandleBatchResultsFile = require('./makeHandleBatchResultsFile');
6
- const {GeneralUtils} = require('@applitools/visual-grid-client');
7
- const runningTests = require('./runningTests');
8
-
9
- function makeHandlers({
10
- config = {},
11
- visualGridClient,
12
- logger = console,
13
- processCloseAndAbort,
14
- getErrorsAndDiffs,
15
- errorDigest,
16
- }) {
17
- logger.log('[handlers] creating handlers with the following config:', config);
18
- let pollBatchEnd, checkWindow, close, resources, openErr;
19
-
20
- return {
21
- open: async args => {
22
- try {
23
- logger.log(`[handlers] open: close=${typeof close}, args=`, args);
24
- args.accessibilitySettings = args.accessibilityValidation;
25
- delete args.accessibilityValidation;
26
- const eyes = await visualGridClient.openEyes(args);
27
- const runningTest = {
28
- abort: eyes.abort,
29
- closePromise: undefined,
30
- };
31
- checkWindow = eyes.checkWindow;
32
- close = makeClose(eyes.close, runningTest);
33
- resources = {};
34
- runningTests.add(runningTest);
35
- logger.log('[handlers] open finished');
36
- return eyes;
37
- } catch (err) {
38
- logger.log(`[handlers] openEyes error ${err}`);
39
- openErr = err;
40
- throw err;
41
- }
42
- },
43
- batchStart: data => {
44
- logger.log('[handlers] batchStart with data', data);
45
- // this is due to Cypress' weird behavior of firing the event that triggers batchStart twice - once in the global hook, and once in cy.visit
46
- runningTests.abortTests().catch(err => {
47
- logger.log('error when aborting tests at the beginning of batchStart', err);
48
- });
49
- const {testConcurrency} = config;
50
- const waitForBatch = makeWaitForBatch({
51
- logger: (logger.extend && logger.extend('waitForBatch')) || logger,
52
- testConcurrency,
53
- processCloseAndAbort,
54
- getErrorsAndDiffs,
55
- errorDigest,
56
- isInteractive: GeneralUtils.getPropertyByPath(data, 'isInteractive'),
57
- handleBatchResultsFile: makeHandleBatchResultsFile(config),
58
- });
59
- pollBatchEnd = pollingHandler(
60
- waitForBatch.bind(null, runningTests.tests, visualGridClient.closeBatch),
61
- );
62
- return visualGridClient;
63
- },
64
- getIosDevicesSizes: () => visualGridClient.getIosDevicesSizes(),
65
- getEmulatedDevicesSizes: () => visualGridClient.getEmulatedDevicesSizes(),
66
- batchEnd: async () => {
67
- logger.log(`[handlers] batchEnd`);
68
- return await pollBatchEnd();
69
- },
70
-
71
- putResource: (id, buffer) => {
72
- if (!resources) {
73
- throw new Error('Please call cy.eyesOpen() before calling cy.eyesCheckWindow()');
74
- }
75
- resources[id] = buffer;
76
- },
77
-
78
- checkWindow: async ({
79
- url,
80
- snapshot = {},
81
- tag,
82
- sizeMode,
83
- target,
84
- fully,
85
- selector,
86
- region,
87
- scriptHooks,
88
- ignore,
89
- floating,
90
- layout,
91
- content,
92
- strict,
93
- sendDom,
94
- useDom,
95
- enablePatterns,
96
- ignoreDisplacements,
97
- accessibility,
98
- matchLevel,
99
- visualGridOptions,
100
- variationGroupId,
101
- }) => {
102
- logger.log(`[handlers] checkWindow: checkWindow=${typeof checkWindow}`);
103
- if (!checkWindow) {
104
- throw new Error('Please call cy.eyesOpen() before calling cy.eyesCheckWindow()');
105
- }
106
-
107
- const snapshotsWithResourceContents = Array.isArray(snapshot)
108
- ? snapshot.map(getSnapshotWithResourceContents)
109
- : getSnapshotWithResourceContents(snapshot);
110
-
111
- if (sizeMode) {
112
- console.warn(
113
- 'WARNING! "sizeMode" is deprecated and will be removed in the future, please use target instead.',
114
- '\nSee: https://github.com/applitools/eyes-cypress#target for more details.',
115
- );
116
- }
117
-
118
- return await checkWindow({
119
- url,
120
- snapshot: snapshotsWithResourceContents,
121
- tag,
122
- sizeMode,
123
- target,
124
- fully,
125
- selector,
126
- region,
127
- scriptHooks,
128
- ignore,
129
- floating,
130
- layout,
131
- content,
132
- strict,
133
- sendDom,
134
- useDom,
135
- enablePatterns,
136
- ignoreDisplacements,
137
- accessibility,
138
- matchLevel,
139
- visualGridOptions,
140
- variationGroupId,
141
- });
142
- },
143
-
144
- close: async () => {
145
- logger.log(
146
- `[handlers] close: openErr=${openErr}, close=${typeof close}, checkWindow=${typeof checkWindow}, resources=${
147
- resources ? `count:${Object.keys(resources).length}` : resources
148
- }`,
149
- );
150
- if (openErr) {
151
- return;
152
- }
153
-
154
- if (!close) {
155
- throw new Error('Please call cy.eyesOpen() before calling cy.eyesClose()');
156
- }
157
-
158
- // not returning this promise because we don't to wait on it before responding to the client
159
- close();
160
-
161
- resources = null;
162
- close = null;
163
- checkWindow = null;
164
- openErr = null;
165
- },
166
- };
167
-
168
- function makeClose(doClose, runningTest) {
169
- return async function() {
170
- return (runningTest.closePromise = presult(doClose(false)));
171
- };
172
- }
173
-
174
- function getSnapshotWithResourceContents(snapshot) {
175
- const target = {};
176
- Object.assign(target, snapshot, {
177
- resourceContents: blobDataToResourceContents(snapshot.blobData),
178
- frames: createResourceContents(snapshot.frames),
179
- });
180
- delete target.blobData;
181
- return target;
182
- }
183
-
184
- function createResourceContents(frames = []) {
185
- return frames.map(frame => {
186
- return {
187
- url: frame.url,
188
- cdt: frame.cdt,
189
- resourceUrls: frame.resourceUrls,
190
- resourceContents: blobDataToResourceContents(frame.blobData),
191
- frames: frame.frames ? createResourceContents(frame.frames) : undefined,
192
- };
193
- });
194
- }
195
-
196
- function blobDataToResourceContents(blobData = []) {
197
- return blobData.reduce((acc, {url, type, errorStatusCode}) => {
198
- const data = errorStatusCode ? {url, errorStatusCode} : {url, type, value: resources[url]};
199
- acc[url] = data;
200
- return acc;
201
- }, {});
202
- }
203
- }
204
-
205
- module.exports = makeHandlers;
@@ -1,17 +0,0 @@
1
- const {TestResultsFormatter} = require('@applitools/visual-grid-client');
2
- const {resolve} = require('path');
3
- const {promisify} = require('util');
4
- const fs = require('fs');
5
- const writeFile = promisify(fs.writeFile);
6
-
7
- const makeHandleBatchResultsFile = config => {
8
- if (!config.tapDirPath) return () => {};
9
- return async function handleBatchResultsFile(results) {
10
- const formatter = new TestResultsFormatter(results);
11
- const fileName = config.tapFileName || `${new Date().toISOString()}-eyes.tap`;
12
- const tapFile = resolve(config.tapDirPath, fileName);
13
- await writeFile(tapFile, formatter.asHierarchicTAPString(false, true));
14
- };
15
- };
16
-
17
- module.exports = makeHandleBatchResultsFile;
@@ -1,46 +0,0 @@
1
- 'use strict';
2
- const PollingStatus = {
3
- IDLE: 'IDLE',
4
- WIP: 'WIP',
5
- DONE: 'DONE',
6
- ERROR: 'ERROR',
7
- };
8
-
9
- function pollingHandler(doWork) {
10
- let pollingStatus = PollingStatus.IDLE,
11
- workError,
12
- workResults;
13
-
14
- return () => {
15
- switch (pollingStatus) {
16
- case PollingStatus.IDLE:
17
- pollingStatus = PollingStatus.WIP;
18
- doWork()
19
- .then(results => {
20
- pollingStatus = PollingStatus.DONE;
21
- workResults = results;
22
- })
23
- .catch(ex => {
24
- pollingStatus = PollingStatus.ERROR;
25
- workError = ex;
26
- });
27
- return {status: PollingStatus.IDLE};
28
- case PollingStatus.WIP:
29
- return {status: PollingStatus.WIP};
30
-
31
- case PollingStatus.DONE:
32
- pollingStatus = PollingStatus.IDLE;
33
- return {status: PollingStatus.DONE, results: workResults};
34
-
35
- case PollingStatus.ERROR:
36
- pollingStatus = PollingStatus.IDLE;
37
- throw workError;
38
-
39
- default:
40
- throw new Error('Unknown error during cy.eyesClose()');
41
- }
42
- };
43
- }
44
-
45
- module.exports = pollingHandler;
46
- module.exports.PollingStatus = PollingStatus;
@@ -1,33 +0,0 @@
1
- 'use strict';
2
- const {presult} = require('@applitools/functional-commons');
3
-
4
- async function processCloseAndAbort({runningTests, closeBatch, logger}) {
5
- const closeAll = runningTests.map(async ({closePromise, abort}) => {
6
- if (closePromise) {
7
- const [closeErr, closeResult] = await closePromise;
8
- if (closeErr) {
9
- return (await abort()).map(testResult => {
10
- if (testResult) {
11
- testResult.error = closeErr;
12
- return testResult;
13
- } else {
14
- return closeErr;
15
- }
16
- });
17
- } else {
18
- return closeResult;
19
- }
20
- } else {
21
- return (await abort()).filter(x => !!x);
22
- }
23
- });
24
-
25
- const results = await Promise.all(closeAll);
26
- const [err] = await presult(closeBatch());
27
- if (err) {
28
- logger.log('failed to close batch', err);
29
- }
30
- return results;
31
- }
32
-
33
- module.exports = processCloseAndAbort;
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- const runningTests = {
4
- tests: [],
5
- add(test) {
6
- this.tests.push(test);
7
- },
8
- reset() {
9
- this.tests = [];
10
- },
11
- async abortTests() {
12
- const tests = this.tests;
13
- this.reset();
14
- return Promise.all(
15
- tests.map(async test => {
16
- if (test.closePromise) {
17
- // this condition doesn't really happen in the code, but it's here for purity. This is used in handlers' batchStart in order to cleanup the state in case a zombie open was called.
18
- await test.closePromise;
19
- } else {
20
- await test.abort();
21
- }
22
- }),
23
- );
24
- },
25
- };
26
-
27
- module.exports = runningTests;
@@ -1,33 +0,0 @@
1
- 'use strict';
2
- const {concurrencyMsg} = require('./concurrencyMsg');
3
- const flatten = require('lodash.flatten');
4
-
5
- function makeWaitForBatch({
6
- logger,
7
- testConcurrency,
8
- processCloseAndAbort,
9
- getErrorsAndDiffs,
10
- errorDigest,
11
- handleBatchResultsFile,
12
- isInteractive,
13
- }) {
14
- return async function(runningTests, closeBatch) {
15
- logger.log(`Waiting for test results of ${runningTests.length} tests.`);
16
-
17
- const testResultsArr = flatten(await processCloseAndAbort({runningTests, closeBatch, logger}));
18
- const {failed, diffs, passed} = getErrorsAndDiffs(testResultsArr);
19
- await handleBatchResultsFile(testResultsArr);
20
-
21
- if (Number(testConcurrency) === 5) {
22
- console.log(concurrencyMsg);
23
- }
24
-
25
- if (failed.length || diffs.length) {
26
- throw new Error(errorDigest({passed, failed, diffs, logger, isInteractive}));
27
- }
28
-
29
- return passed.length;
30
- };
31
- }
32
-
33
- module.exports = makeWaitForBatch;