@camperaid/watest 2.4.1 → 2.4.4

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/.watestrc.js CHANGED
@@ -53,6 +53,12 @@ const cfg = {
53
53
  * Servicer module.
54
54
  */
55
55
  servicer: process.env.WATEST_SERVICER_MODULE,
56
+
57
+ /**
58
+ * Regular expression defining a file name pattern
59
+ * to exclude from the tests.
60
+ */
61
+ ignore_pattern: process.env.WATEST_IGNORE_PATTERN,
56
62
  };
57
63
 
58
64
  module.exports = cfg;
package/core/base.js CHANGED
@@ -123,7 +123,11 @@ function contains(
123
123
  })
124
124
  )
125
125
  ) {
126
- fail_(`${msg}, array has no expected item ${stringify(e)}`);
126
+ fail_(
127
+ `${msg}, array has no expected item ${stringify(e)}, got: ${stringify(
128
+ got
129
+ )}`
130
+ );
127
131
  return false;
128
132
  }
129
133
  }
package/core/series.js CHANGED
@@ -30,6 +30,9 @@ const {
30
30
  const root_folder = 'tests';
31
31
  const root_dir = path.resolve('.');
32
32
 
33
+ const kKungFuDeathGripTimeout = {};
34
+ const kKungFuDeathGripCancelled = {};
35
+
33
36
  process.on('unhandledRejection', error => {
34
37
  log_error(error);
35
38
  fail(`Unhandled Promise rejection`);
@@ -635,26 +638,41 @@ class Series {
635
638
  // Invoke a test.
636
639
  log(`\n!Running: ${name}, path: ${path}\n`);
637
640
  let start_time = new Date();
641
+ let kungFuDeathGrip = null;
642
+ let kungFuDeathGripResolve = null;
643
+ let kungFuDeathGripTimer = 0;
638
644
  try {
639
645
  this.core.setExpectedFailures(failures_info);
640
646
 
641
647
  // If timeout is given then race it against the test.
642
648
  if (settings.timeout) {
643
- let kungFuDeathGripTimer = 0;
644
- let kungFuDeathGrip = new Promise(r => {
645
- kungFuDeathGripTimer = setTimeout(r, settings.timeout);
646
- }).then(() =>
647
- fail(
648
- `Test ${name} takes longer than ${settings.timeout}ms. It's either slow or never ends.`
649
- )
649
+ kungFuDeathGrip = new Promise(
650
+ resolve => (kungFuDeathGripResolve = resolve)
651
+ ).then(value => {
652
+ if (value != kKungFuDeathGripCancelled) {
653
+ fail(
654
+ `Test ${name} takes longer than ${settings.timeout}ms. It's either slow or never ends.`
655
+ );
656
+ return kKungFuDeathGripTimeout;
657
+ }
658
+ });
659
+ kungFuDeathGripTimer = setTimeout(
660
+ kungFuDeathGripResolve,
661
+ settings.timeout
650
662
  );
651
-
652
- await Promise.race([func(), kungFuDeathGrip]);
653
- clearTimeout(kungFuDeathGripTimer);
663
+ let retval = await Promise.race([func(), kungFuDeathGrip]);
664
+ if (retval != kKungFuDeathGripTimeout) {
665
+ clearTimeout(kungFuDeathGripTimer);
666
+ kungFuDeathGripResolve(kKungFuDeathGripCancelled);
667
+ }
654
668
  } else {
655
669
  await func(); // execute the test
656
670
  }
657
671
  } catch (e) {
672
+ if (kungFuDeathGripTimer) {
673
+ clearTimeout(kungFuDeathGripTimer);
674
+ kungFuDeathGripResolve(kKungFuDeathGripCancelled);
675
+ }
658
676
  let failmsg = e;
659
677
  if (e instanceof Error) {
660
678
  log_error(e);
@@ -878,7 +896,11 @@ class Series {
878
896
  getTestFileList(folder) {
879
897
  return fs
880
898
  .readdirSync(path.join(root_dir, folder))
881
- .filter(n => n.startsWith('t_'));
899
+ .filter(
900
+ n =>
901
+ n.startsWith('t_') &&
902
+ (!settings.ignorePattern || !settings.ignorePattern.test(n))
903
+ );
882
904
  }
883
905
 
884
906
  performInChildProcess({ name, path, loader, webdriver }) {
package/core/settings.js CHANGED
@@ -46,6 +46,10 @@ class Settings {
46
46
  return this._invocation;
47
47
  }
48
48
 
49
+ get ignorePattern() {
50
+ return rc.ignore_pattern && new RegExp(rc.ignore_pattern);
51
+ }
52
+
49
53
  get debunkLimit() {
50
54
  return parseInt(rc.debunk_limit) || 5;
51
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camperaid/watest",
3
- "version": "2.4.1",
3
+ "version": "2.4.4",
4
4
  "description": "Web Application Testsuite",
5
5
  "engines": {
6
6
  "node": ">=14.15.1"
@@ -47,7 +47,7 @@ module.exports.test = async () => {
47
47
  await is_output(
48
48
  () => contains([0, 1], [1, 3], `Array contains`),
49
49
  [],
50
- [`Failed: Array contains, array has no expected item 3`],
50
+ [`Failed: Array contains, array has no expected item 3, got: [0, 1]`],
51
51
  `failure`
52
52
  );
53
53
  };
@@ -76,7 +76,7 @@ unexpected character: 'y' at 2 pos, expected: 'o' at '' line`,
76
76
  ),
77
77
  [`Test: scriptRetvalContains. Expected: ['heo']`],
78
78
  [
79
- `Failed: script retval contains ['heo'], array has no expected item 'heo'`,
79
+ `Failed: script retval contains ['heo'], array has no expected item 'heo', got: ['hey', 'bo']`,
80
80
  `Failed: scriptRetvalContains, timeout while waiting to meet criteria`,
81
81
  `Failed: scriptRetvalContains`,
82
82
  ],