@lvce-editor/test-worker 16.6.0 → 16.7.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.
@@ -5578,6 +5578,75 @@ const watchForHotReload = async (platform, href) => {
5578
5578
  await invoke('FileWatcher.watchFile', TestWorker, callbackCommand, fileUrl);
5579
5579
  };
5580
5580
 
5581
+ const toErrorMessage = error => {
5582
+ if (error instanceof Error) {
5583
+ return error.message;
5584
+ }
5585
+ return String(error);
5586
+ };
5587
+ const getSkippedResult = name => {
5588
+ const now$1 = now();
5589
+ return {
5590
+ end: now$1,
5591
+ error: '',
5592
+ name,
5593
+ start: now$1,
5594
+ status: 'skip'
5595
+ };
5596
+ };
5597
+ const getMissingTestResult = name => {
5598
+ const now$1 = now();
5599
+ return {
5600
+ end: now$1,
5601
+ error: 'test function not found',
5602
+ name,
5603
+ start: now$1,
5604
+ status: Fail
5605
+ };
5606
+ };
5607
+ const getImportErrorResult = (name, error) => {
5608
+ const now$1 = now();
5609
+ return {
5610
+ end: now$1,
5611
+ error: toErrorMessage(error),
5612
+ name,
5613
+ start: now$1,
5614
+ status: Fail
5615
+ };
5616
+ };
5617
+ const getExecutedResult = async (name, test, globals) => {
5618
+ const result = await executeTest2(name, test, globals, now);
5619
+ return {
5620
+ end: result.end,
5621
+ error: result.error ? toErrorMessage(result.error) : '',
5622
+ name,
5623
+ start: result.start,
5624
+ status: result.type
5625
+ };
5626
+ };
5627
+ const executeAllTest = async (item, globals) => {
5628
+ try {
5629
+ const module = await importTest(item.url);
5630
+ const {
5631
+ mockRpc,
5632
+ skip,
5633
+ test
5634
+ } = module;
5635
+ if (mockRpc) {
5636
+ setMockRpc(mockRpc);
5637
+ }
5638
+ if (skip) {
5639
+ return getSkippedResult(item.name);
5640
+ }
5641
+ if (!test) {
5642
+ return getMissingTestResult(item.name);
5643
+ }
5644
+ return getExecutedResult(item.name, test, globals);
5645
+ } catch (error) {
5646
+ return getImportErrorResult(item.name, error);
5647
+ }
5648
+ };
5649
+
5581
5650
  // TODO move this into three steps:
5582
5651
  // 1. import test module
5583
5652
  // 2. execute test
@@ -5638,6 +5707,27 @@ const execute = async (href, platform, assetDir) => {
5638
5707
  // ignore
5639
5708
  }
5640
5709
  };
5710
+ const executeAll = async (tests, href, platform, assetDir) => {
5711
+ push({
5712
+ assetDir,
5713
+ inProgress: true,
5714
+ platform,
5715
+ url: href
5716
+ });
5717
+ const globals = createApi(platform, assetDir);
5718
+ const results = [];
5719
+ for (const test of tests) {
5720
+ const result = await executeAllTest(test, globals);
5721
+ results.push(result);
5722
+ }
5723
+ await invoke('TestFrameWork.showTestResults', JSON.stringify(results));
5724
+ push({
5725
+ assetDir,
5726
+ inProgress: false,
5727
+ platform,
5728
+ url: href
5729
+ });
5730
+ };
5641
5731
 
5642
5732
  const doHotReload = async (url, platform, assetDir) => {
5643
5733
  // eslint-disable-next-line no-console
@@ -6044,6 +6134,7 @@ const tryAutoFix = async () => {
6044
6134
  const commandMap = {
6045
6135
  'FileWatcher.handleEvent': handleFileWatcherEvent,
6046
6136
  'Test.execute': execute,
6137
+ 'Test.executeAll': executeAll,
6047
6138
  'Test.executeMock': executeMock,
6048
6139
  'Test.tryAutoFix': tryAutoFix
6049
6140
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "16.6.0",
3
+ "version": "16.7.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",