@camperaid/watest 2.4.2 → 2.4.5

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/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.2",
3
+ "version": "2.4.5",
4
4
  "description": "Web Application Testsuite",
5
5
  "engines": {
6
6
  "node": ">=14.15.1"
@@ -902,6 +902,34 @@ else {
902
902
  });
903
903
  }
904
904
 
905
+ //
906
+ // Clipboard
907
+ //
908
+
909
+ clipboardIs(value, msg) {
910
+ return this.matchScriptRetval({
911
+ script: `window.navigator.clipboard.readText()`,
912
+ expected: value,
913
+ msg,
914
+ test: got => test_is(got, value, { ignore_unexpected: true }),
915
+ is_matched: got =>
916
+ is(got, value, `${msg}, clipboard value`, {
917
+ ignore_unexpected: true,
918
+ }),
919
+ });
920
+ }
921
+
922
+ getClipboardText() {
923
+ return this.executeScript(
924
+ `window.navigator.clipboard.readText()`,
925
+ `Read clipboard text`
926
+ );
927
+ }
928
+
929
+ //
930
+ // DOM: elements count and visibility, focus.
931
+ //
932
+
905
933
  /**
906
934
  * Waits until elements count matches.
907
935
  */