@rstest/core 0.0.10 → 0.1.1

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.
@@ -0,0 +1,47 @@
1
+ /*
2
+ * @version 1.4.0
3
+ * @date 2015-10-26
4
+ * @stability 3 - Stable
5
+ * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
6
+ * @license MIT License
7
+ */
8
+
9
+ /**
10
+ * @license React
11
+ * react-is.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */
18
+
19
+ /**
20
+ * @license React
21
+ * react-is.development.js
22
+ *
23
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
24
+ *
25
+ * This source code is licensed under the MIT license found in the
26
+ * LICENSE file in the root directory of this source tree.
27
+ */
28
+
29
+ /**
30
+ * @license React
31
+ * react-is.production.js
32
+ *
33
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
34
+ *
35
+ * This source code is licensed under the MIT license found in the
36
+ * LICENSE file in the root directory of this source tree.
37
+ */
38
+
39
+ /**
40
+ * @license React
41
+ * react-is.production.min.js
42
+ *
43
+ * Copyright (c) Facebook, Inc. and its affiliates.
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE file in the root directory of this source tree.
47
+ */
package/dist/285.js CHANGED
@@ -1,3 +1,5 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
1
3
  export const __webpack_ids__ = [
2
4
  "285"
3
5
  ];
package/dist/355.js CHANGED
@@ -1,9 +1,12 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
1
3
  export const __webpack_ids__ = [
2
4
  "355"
3
5
  ];
4
6
  export const __webpack_modules__ = {
5
7
  "./src/utils/error.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
6
8
  __webpack_require__.d(__webpack_exports__, {
9
+ parseErrorStacktrace: ()=>parseErrorStacktrace,
7
10
  printError: ()=>printError
8
11
  });
9
12
  var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs");
@@ -70,6 +73,8 @@ export const __webpack_modules__ = {
70
73
  /node_modules\/@vitest\/expect/,
71
74
  /node_modules\/@vitest\/snapshot/,
72
75
  /node:\w+/,
76
+ /webpack\/runtime/,
77
+ /webpack\\runtime/,
73
78
  '<anonymous>'
74
79
  ];
75
80
  async function parseErrorStacktrace({ stack, getSourcemap, fullStack }) {
@@ -1,5 +1,7 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
1
3
  export const __webpack_ids__ = [
2
- "353"
4
+ "359"
3
5
  ];
4
6
  export const __webpack_modules__ = {
5
7
  "../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
@@ -99,10 +101,66 @@ export const __webpack_modules__ = {
99
101
  __webpack_require__.d(__webpack_exports__, {
100
102
  createRstest: ()=>createRstest
101
103
  });
102
- var manager_ = __webpack_require__("@vitest/snapshot/manager");
104
+ var external_pathe_ = __webpack_require__("pathe");
105
+ class SnapshotManager {
106
+ summary;
107
+ extension = ".snap";
108
+ constructor(options){
109
+ this.options = options;
110
+ this.clear();
111
+ }
112
+ clear() {
113
+ this.summary = emptySummary(this.options);
114
+ }
115
+ add(result) {
116
+ addSnapshotResult(this.summary, result);
117
+ }
118
+ resolvePath(testPath, context) {
119
+ const resolver = this.options.resolveSnapshotPath || (()=>(0, external_pathe_.join)((0, external_pathe_.join)((0, external_pathe_.dirname)(testPath), "__snapshots__"), `${(0, external_pathe_.basename)(testPath)}${this.extension}`));
120
+ const path = resolver(testPath, this.extension, context);
121
+ return path;
122
+ }
123
+ resolveRawPath(testPath, rawPath) {
124
+ return (0, external_pathe_.isAbsolute)(rawPath) ? rawPath : (0, external_pathe_.resolve)((0, external_pathe_.dirname)(testPath), rawPath);
125
+ }
126
+ }
127
+ function emptySummary(options) {
128
+ const summary = {
129
+ added: 0,
130
+ failure: false,
131
+ filesAdded: 0,
132
+ filesRemoved: 0,
133
+ filesRemovedList: [],
134
+ filesUnmatched: 0,
135
+ filesUpdated: 0,
136
+ matched: 0,
137
+ total: 0,
138
+ unchecked: 0,
139
+ uncheckedKeysByFile: [],
140
+ unmatched: 0,
141
+ updated: 0,
142
+ didUpdate: "all" === options.updateSnapshot
143
+ };
144
+ return summary;
145
+ }
146
+ function addSnapshotResult(summary, result) {
147
+ if (result.added) summary.filesAdded++;
148
+ if (result.fileDeleted) summary.filesRemoved++;
149
+ if (result.unmatched) summary.filesUnmatched++;
150
+ if (result.updated) summary.filesUpdated++;
151
+ summary.added += result.added;
152
+ summary.matched += result.matched;
153
+ summary.unchecked += result.unchecked;
154
+ if (result.uncheckedKeys && result.uncheckedKeys.length > 0) summary.uncheckedKeysByFile.push({
155
+ filePath: result.filepath,
156
+ keys: result.uncheckedKeys
157
+ });
158
+ summary.unmatched += result.unmatched;
159
+ summary.updated += result.updated;
160
+ summary.total += result.added + result.matched + result.unmatched + result.updated;
161
+ }
103
162
  var external_std_env_ = __webpack_require__("std-env");
104
163
  var src_config = __webpack_require__("./src/config.ts");
105
- var external_pathe_ = __webpack_require__("pathe");
106
164
  var stack_trace_parser_esm = __webpack_require__("../../node_modules/.pnpm/stacktrace-parser@0.1.11/node_modules/stacktrace-parser/dist/stack-trace-parser.esm.js");
107
165
  var utils = __webpack_require__("./src/utils/index.ts");
108
166
  var external_node_util_ = __webpack_require__("node:util");
@@ -342,6 +400,23 @@ export const __webpack_modules__ = {
342
400
  todo: utils.$_.gray(statusStr.todo),
343
401
  skip: utils.$_.gray(statusStr.skip)
344
402
  };
403
+ const logCase = (result, slowTestThreshold)=>{
404
+ const isSlowCase = (result.duration || 0) > slowTestThreshold;
405
+ const icon = isSlowCase && 'pass' === result.status ? utils.$_.yellow(statusStr[result.status]) : statusColorfulStr[result.status];
406
+ const nameStr = (0, utils.Yz)(result);
407
+ const duration = void 0 !== result.duration ? ` (${(0, utils.AS)(result.duration)})` : '';
408
+ const retry = result.retryCount ? utils.$_.yellow(` (retry x${result.retryCount})`) : '';
409
+ utils.kg.log(` ${icon} ${nameStr}${utils.$_.gray(duration)}${retry}`);
410
+ if (result.errors) for (const error of result.errors)console.error(utils.$_.red(` ${error.message}`));
411
+ };
412
+ const logFileTitle = (test, relativePath, slowTestThreshold, alwaysShowTime = false)=>{
413
+ let title = ` ${utils.$_.bold(statusColorfulStr[test.status])} ${(0, utils.aj)(relativePath)}`;
414
+ const formatDuration = (duration)=>utils.$_[duration > slowTestThreshold ? 'yellow' : 'green'](`${(0, utils.AS)(duration)}`);
415
+ title += ` ${utils.$_.gray(`(${test.results.length})`)}`;
416
+ const isTooSlow = test.duration && test.duration > slowTestThreshold;
417
+ if (alwaysShowTime || isTooSlow) title += ` ${formatDuration(test.duration)}`;
418
+ utils.kg.log(title);
419
+ };
345
420
  class DefaultReporter {
346
421
  rootPath;
347
422
  config;
@@ -360,25 +435,15 @@ export const __webpack_modules__ = {
360
435
  this.statusRenderer?.removeRunningModule(test.testPath);
361
436
  const relativePath = (0, external_pathe_.relative)(this.rootPath, test.testPath);
362
437
  const { slowTestThreshold } = this.config;
363
- let title = ` ${utils.$_.bold(statusColorfulStr[test.status])} ${(0, utils.aj)(relativePath)}`;
364
- const formatDuration = (duration)=>utils.$_[duration > slowTestThreshold ? 'yellow' : 'green'](`${(0, utils.AS)(duration)}`);
365
- title += ` ${utils.$_.gray(`(${test.results.length})`)}`;
438
+ logFileTitle(test, relativePath, slowTestThreshold);
366
439
  const isTooSlow = test.duration && test.duration > slowTestThreshold;
367
- if (isTooSlow) title += ` ${formatDuration(test.duration)}`;
368
440
  const hasRetryCase = test.results.some((result)=>(result.retryCount || 0) > 0);
369
- utils.kg.log(title);
370
441
  if ('fail' !== test.status && !isTooSlow && !hasRetryCase) return;
371
442
  const showAllCases = isTooSlow && !test.results.some((result)=>(result.duration || 0) > slowTestThreshold);
372
443
  for (const result of test.results){
373
444
  const isSlowCase = (result.duration || 0) > slowTestThreshold;
374
445
  const retried = (result.retryCount || 0) > 0;
375
- if (!showAllCases && 'fail' !== result.status && !isSlowCase && !retried) continue;
376
- const icon = isSlowCase && 'pass' === result.status ? utils.$_.yellow(statusStr[result.status]) : statusColorfulStr[result.status];
377
- const nameStr = (0, utils.Yz)(result);
378
- const duration = void 0 !== result.duration ? ` (${(0, utils.AS)(result.duration)})` : '';
379
- const retry = result.retryCount ? utils.$_.yellow(` (retry x${result.retryCount})`) : '';
380
- console.log(` ${icon} ${nameStr}${utils.$_.gray(duration)}${retry}`);
381
- if (result.errors) for (const error of result.errors)console.error(utils.$_.red(` ${error.message}`));
446
+ if (showAllCases || 'fail' === result.status || isSlowCase || retried) logCase(result, slowTestThreshold);
382
447
  }
383
448
  }
384
449
  onTestCaseResult(_result) {}
@@ -420,14 +485,76 @@ export const __webpack_modules__ = {
420
485
  });
421
486
  }
422
487
  }
488
+ class GithubActionsReporter {
489
+ onWritePath;
490
+ rootPath;
491
+ constructor({ options, rootPath }){
492
+ this.onWritePath = options.onWritePath;
493
+ this.rootPath = rootPath;
494
+ }
495
+ async onTestRunEnd({ results, testResults, getSourcemap }) {
496
+ const failedTests = [
497
+ ...results.filter((i)=>'fail' === i.status && i.errors?.length),
498
+ ...testResults.filter((i)=>'fail' === i.status)
499
+ ];
500
+ if (0 === failedTests.length) return;
501
+ const { parseErrorStacktrace } = await Promise.all([
502
+ __webpack_require__.e("723"),
503
+ __webpack_require__.e("355")
504
+ ]).then(__webpack_require__.bind(__webpack_require__, "./src/utils/error.ts"));
505
+ for (const test of failedTests){
506
+ const { testPath } = test;
507
+ const nameStr = (0, utils.Yz)(test);
508
+ const shortPath = (0, external_pathe_.relative)(this.rootPath, testPath);
509
+ const title = `${shortPath} ${utils.Qd} ${nameStr}`;
510
+ for (const error of test.errors || []){
511
+ let file = testPath;
512
+ let line = 1;
513
+ let column = 1;
514
+ const message = `${error.message}${error.diff ? `\n${error.diff}` : ''}`;
515
+ const type = 'error';
516
+ if (error.stack) {
517
+ const stackFrames = await parseErrorStacktrace({
518
+ stack: error.stack,
519
+ fullStack: error.fullStack,
520
+ getSourcemap
521
+ });
522
+ if (stackFrames[0]) {
523
+ file = stackFrames[0].file || test.testPath;
524
+ line = stackFrames[0].lineNumber || 1;
525
+ column = stackFrames[0].column || 1;
526
+ }
527
+ }
528
+ utils.kg.log(`::${type} file=${this.onWritePath?.(file) || file},line=${line},col=${column},title=${escapeData(title)}::${escapeData(message)}`);
529
+ }
530
+ }
531
+ }
532
+ }
533
+ function escapeData(s) {
534
+ return s.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A').replace(/:/g, '%3A').replace(/,/g, '%2C');
535
+ }
536
+ class VerboseReporter extends DefaultReporter {
537
+ onTestFileResult(test) {
538
+ this.statusRenderer?.removeRunningModule(test.testPath);
539
+ const relativePath = (0, external_pathe_.relative)(this.rootPath, test.testPath);
540
+ const { slowTestThreshold } = this.config;
541
+ logFileTitle(test, relativePath, slowTestThreshold, true);
542
+ for (const result of test.results)logCase(result, slowTestThreshold);
543
+ }
544
+ }
423
545
  var helper = __webpack_require__("./src/utils/helper.ts");
424
546
  const reportersMap = {
425
- default: DefaultReporter
547
+ default: DefaultReporter,
548
+ verbose: VerboseReporter,
549
+ 'github-actions': GithubActionsReporter
426
550
  };
427
551
  function createReporters(reporters, initOptions = {}) {
428
552
  const result = (0, helper.XQ)(reporters).map((reporter)=>{
429
553
  if ('string' == typeof reporter || Array.isArray(reporter)) {
430
- const [name, options = {}] = (0, helper.XQ)(reporter);
554
+ const [name, options = {}] = 'string' == typeof reporter ? [
555
+ reporter,
556
+ {}
557
+ ] : reporter;
431
558
  if (name in reportersMap) {
432
559
  const Reporter = reportersMap[name];
433
560
  return new Reporter({
@@ -449,12 +576,12 @@ export const __webpack_modules__ = {
449
576
  rootPath,
450
577
  config: rstestConfig
451
578
  }) : [];
452
- const snapshotManager = new manager_.SnapshotManager({
579
+ const snapshotManager = new SnapshotManager({
453
580
  updateSnapshot: rstestConfig.update ? 'all' : external_std_env_.isCI ? 'none' : 'new'
454
581
  });
455
582
  return {
456
583
  command,
457
- version: "0.0.10",
584
+ version: "0.1.1",
458
585
  rootPath,
459
586
  reporters,
460
587
  snapshotManager,
package/dist/44.js CHANGED
@@ -1,3 +1,5 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
1
3
  export const __webpack_ids__ = [
2
4
  "44"
3
5
  ];