@lvce-editor/test-with-playwright-worker 12.0.0 → 12.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.
Files changed (2) hide show
  1. package/dist/workerMain.js +67 -69
  2. package/package.json +1 -1
@@ -245,8 +245,8 @@ const getModuleNotFoundError = stderr => {
245
245
  const messageIndex = lines.findIndex(isModuleNotFoundMessage);
246
246
  const message = lines[messageIndex];
247
247
  return {
248
- message,
249
- code: ERR_MODULE_NOT_FOUND
248
+ code: ERR_MODULE_NOT_FOUND,
249
+ message
250
250
  };
251
251
  };
252
252
  const isModuleNotFoundError = stderr => {
@@ -269,14 +269,14 @@ const isUnhelpfulNativeModuleError = stderr => {
269
269
  const getNativeModuleErrorMessage = stderr => {
270
270
  const message = getMessageCodeBlock(stderr);
271
271
  return {
272
- message: `Incompatible native node module: ${message}`,
273
- code: E_INCOMPATIBLE_NATIVE_MODULE
272
+ code: E_INCOMPATIBLE_NATIVE_MODULE,
273
+ message: `Incompatible native node module: ${message}`
274
274
  };
275
275
  };
276
276
  const getModuleSyntaxError = () => {
277
277
  return {
278
- message: `ES Modules are not supported in electron`,
279
- code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
278
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
279
+ message: `ES Modules are not supported in electron`
280
280
  };
281
281
  };
282
282
  const getHelpfulChildProcessError = (stdout, stderr) => {
@@ -295,8 +295,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
295
295
  rest
296
296
  } = getDetails(lines);
297
297
  return {
298
- message: actualMessage,
299
298
  code: '',
299
+ message: actualMessage,
300
300
  stack: rest
301
301
  };
302
302
  };
@@ -306,8 +306,8 @@ class IpcError extends VError {
306
306
  if (stdout || stderr) {
307
307
  // @ts-ignore
308
308
  const {
309
- message,
310
309
  code,
310
+ message,
311
311
  stack
312
312
  } = getHelpfulChildProcessError(stdout, stderr);
313
313
  const cause = new Error(message);
@@ -918,23 +918,23 @@ const Fail = 3;
918
918
 
919
919
  const getTestState = (testOverlayState, text) => {
920
920
  switch (testOverlayState) {
921
- case Pass$1:
921
+ case Fail$1:
922
922
  // @ts-ignore
923
923
  return {
924
- status: Pass,
925
- error: ''
924
+ error: `${text}`,
925
+ status: Fail
926
926
  };
927
- case Skip$1:
927
+ case Pass$1:
928
928
  // @ts-ignore
929
929
  return {
930
- status: Skip,
931
- error: ''
930
+ error: '',
931
+ status: Pass
932
932
  };
933
- case Fail$1:
933
+ case Skip$1:
934
934
  // @ts-ignore
935
935
  return {
936
- status: Fail,
937
- error: `${text}`
936
+ error: '',
937
+ status: Skip
938
938
  };
939
939
  default:
940
940
  throw new Error(`unexpected test state: ${testOverlayState}`);
@@ -951,10 +951,10 @@ const getUrlFromTestFile = (absolutePath, port) => {
951
951
  return `http://localhost:${port}/tests/${htmlFileName}`;
952
952
  };
953
953
  const runTest = async ({
954
- test,
955
954
  page,
956
- testSrc,
957
955
  port,
956
+ test,
957
+ testSrc,
958
958
  timeout
959
959
  }) => {
960
960
  const start = performance.now();
@@ -974,10 +974,10 @@ const runTest = async ({
974
974
  return {
975
975
  // @ts-ignore
976
976
  ...testState,
977
- name: test,
978
- start,
979
977
  end,
980
- error: text
978
+ error: text,
979
+ name: test,
980
+ start
981
981
  };
982
982
  };
983
983
 
@@ -986,14 +986,14 @@ const runTest = async ({
986
986
  * @param {{testSrc:string, tests:string[], headless:boolean, page: import('@playwright/test').Page, port:number, timeout:number, onResult:any, onFinalResult:any}} param0
987
987
  */
988
988
  const runTests = async ({
989
- testSrc,
990
- tests,
991
989
  headless,
990
+ onFinalResult,
991
+ onResult,
992
992
  page,
993
993
  port,
994
- timeout,
995
- onResult,
996
- onFinalResult
994
+ tests,
995
+ testSrc,
996
+ timeout
997
997
  }) => {
998
998
  let failed = 0;
999
999
  let skipped = 0;
@@ -1001,10 +1001,10 @@ const runTests = async ({
1001
1001
  const start = performance.now();
1002
1002
  for (const test of tests) {
1003
1003
  const result = await runTest({
1004
- test,
1005
1004
  page,
1006
- testSrc,
1007
1005
  port,
1006
+ test,
1007
+ testSrc,
1008
1008
  timeout
1009
1009
  });
1010
1010
  await onResult(result);
@@ -1013,21 +1013,21 @@ const runTests = async ({
1013
1013
  case Fail:
1014
1014
  failed++;
1015
1015
  break;
1016
- case Skip:
1017
- skipped++;
1018
- break;
1019
1016
  case Pass:
1020
1017
  passed++;
1021
1018
  break;
1019
+ case Skip:
1020
+ skipped++;
1021
+ break;
1022
1022
  }
1023
1023
  }
1024
1024
  const end = performance.now();
1025
1025
  await onFinalResult({
1026
- passed,
1026
+ end,
1027
1027
  failed,
1028
+ passed,
1028
1029
  skipped,
1029
- start,
1030
- end
1030
+ start
1031
1031
  });
1032
1032
  };
1033
1033
 
@@ -1175,8 +1175,8 @@ const getServerPath = async serverPath => {
1175
1175
  * @returns
1176
1176
  */
1177
1177
  const startBrowser = async ({
1178
- signal,
1179
- headless
1178
+ headless,
1179
+ signal
1180
1180
  }) => {
1181
1181
  const browser = await chromium.launch({
1182
1182
  headless
@@ -1194,29 +1194,27 @@ const startBrowser = async ({
1194
1194
  };
1195
1195
  };
1196
1196
 
1197
- /* eslint-disable n/no-unsupported-features/es-syntax */
1198
-
1199
1197
  /**
1200
1198
  *
1201
1199
  * @param {{signal:AbortSignal, port:number, serverPath:string, onlyExtension:string, testPath:string}} param0
1202
1200
  * @returns
1203
1201
  */
1204
1202
  const startServer = async ({
1205
- signal,
1203
+ onlyExtension,
1206
1204
  port,
1207
1205
  serverPath,
1208
- onlyExtension,
1206
+ signal,
1209
1207
  testPath
1210
1208
  }) => {
1211
1209
  const child = fork(serverPath, {
1212
- stdio: 'inherit',
1213
1210
  // signal,
1214
1211
  env: {
1215
1212
  ...process.env,
1216
- PORT: String(port),
1217
1213
  ONLY_EXTENSION: onlyExtension,
1214
+ PORT: String(port),
1218
1215
  TEST_PATH: testPath
1219
- }
1216
+ },
1217
+ stdio: 'inherit'
1220
1218
  });
1221
1219
  child.on('error', x => {
1222
1220
  if (x.name === 'AbortError') {
@@ -1225,8 +1223,8 @@ const startServer = async ({
1225
1223
  console.log('child error', x);
1226
1224
  });
1227
1225
  const {
1228
- resolve,
1229
- promise
1226
+ promise,
1227
+ resolve
1230
1228
  } = Promise.withResolvers();
1231
1229
  child.on('message', resolve);
1232
1230
  await promise;
@@ -1239,41 +1237,41 @@ const startServer = async ({
1239
1237
  * @returns
1240
1238
  */
1241
1239
  const setupTests = async ({
1242
- signal,
1243
1240
  headless,
1244
1241
  onlyExtension,
1245
- testPath,
1246
- serverPath
1242
+ serverPath,
1243
+ signal,
1244
+ testPath
1247
1245
  }) => {
1248
1246
  const port = await getPort();
1249
1247
  const {
1250
1248
  browser,
1251
1249
  page
1252
1250
  } = await startBrowser({
1253
- signal,
1254
- headless
1251
+ headless,
1252
+ signal
1255
1253
  });
1256
1254
  const resolvedServerPath = await getServerPath(serverPath);
1257
1255
  const child = await startServer({
1258
- signal,
1256
+ onlyExtension,
1259
1257
  port,
1260
1258
  serverPath: resolvedServerPath,
1261
- onlyExtension,
1259
+ signal,
1262
1260
  testPath
1263
1261
  });
1264
1262
  return {
1265
- port,
1266
1263
  browser,
1264
+ child,
1267
1265
  page,
1268
- child
1266
+ port
1269
1267
  };
1270
1268
  };
1271
1269
 
1272
1270
  const SIGINT = 'SIGINT';
1273
1271
 
1274
1272
  const tearDownTests = async ({
1275
- controller,
1276
- child
1273
+ child,
1274
+ controller
1277
1275
  }) => {
1278
1276
  controller.abort();
1279
1277
  child.kill(SIGINT);
@@ -1299,15 +1297,15 @@ const runAllTests = async (extensionPath, testPath, cwd, headless, timeout, serv
1299
1297
  } = controller;
1300
1298
  // @ts-ignore
1301
1299
  const {
1302
- page,
1303
1300
  child,
1301
+ page,
1304
1302
  port
1305
1303
  } = await setupTests({
1306
- signal,
1307
1304
  headless,
1308
1305
  onlyExtension: extensionPath,
1309
- testPath,
1310
- serverPath
1306
+ serverPath,
1307
+ signal,
1308
+ testPath
1311
1309
  });
1312
1310
  const testSrc = join(testPath, 'src');
1313
1311
  const tests = await getTests(testSrc);
@@ -1318,18 +1316,18 @@ const runAllTests = async (extensionPath, testPath, cwd, headless, timeout, serv
1318
1316
  await rpc.invoke(HandleFinalResult, finalResult);
1319
1317
  };
1320
1318
  await runTests({
1321
- testSrc,
1322
- tests,
1323
1319
  headless,
1324
- port,
1325
- page,
1326
- timeout,
1320
+ onFinalResult,
1327
1321
  onResult,
1328
- onFinalResult
1322
+ page,
1323
+ port,
1324
+ tests,
1325
+ testSrc,
1326
+ timeout
1329
1327
  });
1330
1328
  await tearDownTests({
1331
- controller,
1332
- child
1329
+ child,
1330
+ controller
1333
1331
  });
1334
1332
  };
1335
1333
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-with-playwright-worker",
3
- "version": "12.0.0",
3
+ "version": "12.1.0",
4
4
  "description": "Worker package for test-with-playwright",
5
5
  "repository": {
6
6
  "type": "git",