codeceptjs 3.5.4-beta.1 → 3.5.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +368 -0
  2. package/README.md +0 -2
  3. package/docs/build/Appium.js +48 -7
  4. package/docs/build/GraphQL.js +25 -0
  5. package/docs/build/Nightmare.js +15 -6
  6. package/docs/build/Playwright.js +436 -197
  7. package/docs/build/Protractor.js +17 -8
  8. package/docs/build/Puppeteer.js +37 -20
  9. package/docs/build/TestCafe.js +19 -10
  10. package/docs/build/WebDriver.js +45 -37
  11. package/docs/changelog.md +375 -0
  12. package/docs/community-helpers.md +8 -4
  13. package/docs/examples.md +8 -2
  14. package/docs/helpers/Appium.md +39 -2
  15. package/docs/helpers/GraphQL.md +21 -0
  16. package/docs/helpers/Nightmare.md +1260 -0
  17. package/docs/helpers/Playwright.md +223 -119
  18. package/docs/helpers/Protractor.md +1711 -0
  19. package/docs/helpers/Puppeteer.md +31 -29
  20. package/docs/helpers/TestCafe.md +18 -17
  21. package/docs/helpers/WebDriver.md +34 -32
  22. package/docs/playwright.md +24 -1
  23. package/docs/webapi/dontSeeInField.mustache +1 -1
  24. package/docs/webapi/executeAsyncScript.mustache +2 -0
  25. package/docs/webapi/executeScript.mustache +2 -0
  26. package/docs/webapi/seeInField.mustache +1 -1
  27. package/docs/wiki/Books-&-Posts.md +0 -0
  28. package/docs/wiki/Community-Helpers-&-Plugins.md +8 -4
  29. package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +46 -14
  30. package/docs/wiki/Examples.md +8 -2
  31. package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +0 -0
  32. package/docs/wiki/Home.md +0 -0
  33. package/docs/wiki/Migration-to-Appium-v2---CodeceptJS.md +83 -0
  34. package/docs/wiki/Release-Process.md +0 -0
  35. package/docs/wiki/Roadmap.md +0 -0
  36. package/docs/wiki/Tests.md +0 -0
  37. package/docs/wiki/Upgrading-to-CodeceptJS-3.md +0 -0
  38. package/docs/wiki/Videos.md +0 -0
  39. package/lib/codecept.js +1 -0
  40. package/lib/command/definitions.js +2 -7
  41. package/lib/command/init.js +40 -4
  42. package/lib/command/run-multiple/collection.js +17 -5
  43. package/lib/command/run-workers.js +4 -0
  44. package/lib/command/run.js +6 -0
  45. package/lib/helper/Appium.js +46 -5
  46. package/lib/helper/GraphQL.js +25 -0
  47. package/lib/helper/Nightmare.js +1415 -0
  48. package/lib/helper/Playwright.js +336 -62
  49. package/lib/helper/Protractor.js +1837 -0
  50. package/lib/helper/Puppeteer.js +31 -18
  51. package/lib/helper/TestCafe.js +15 -8
  52. package/lib/helper/WebDriver.js +39 -35
  53. package/lib/helper/clientscripts/nightmare.js +213 -0
  54. package/lib/helper/errors/ElementNotFound.js +2 -1
  55. package/lib/helper/scripts/highlightElement.js +1 -1
  56. package/lib/interfaces/bdd.js +1 -1
  57. package/lib/mochaFactory.js +2 -1
  58. package/lib/pause.js +6 -4
  59. package/lib/plugin/heal.js +2 -3
  60. package/lib/plugin/selenoid.js +6 -1
  61. package/lib/step.js +27 -10
  62. package/lib/utils.js +4 -0
  63. package/lib/workers.js +3 -1
  64. package/package.json +87 -87
  65. package/typings/promiseBasedTypes.d.ts +163 -126
  66. package/typings/types.d.ts +183 -144
  67. package/docs/build/Polly.js +0 -42
  68. package/docs/build/SeleniumWebdriver.js +0 -76
@@ -147,11 +147,10 @@ module.exports = function (config = {}) {
147
147
  async function tryToHeal(failedStep, err) {
148
148
  output.debug(`Running OpenAI to heal ${failedStep.toCode()} step`);
149
149
 
150
- const codeSnippets = await aiAssistant.healFailedStep(
151
- failedStep, err, currentTest,
152
- );
150
+ const codeSnippets = await aiAssistant.healFailedStep(failedStep, err, currentTest);
153
151
 
154
152
  output.debug(`Received ${codeSnippets.length} suggestions from OpenAI`);
153
+ const I = Container.support('I'); // eslint-disable-line
155
154
 
156
155
  for (const codeSnippet of codeSnippets) {
157
156
  try {
@@ -58,7 +58,12 @@ let seleniumUrl = 'http://localhost:$port$';
58
58
  const supportedHelpers = ['WebDriver'];
59
59
  const SELENOID_START_TIMEOUT = 2000;
60
60
  const SELENOID_STOP_TIMEOUT = 10000;
61
- const wait = time => new Promise((res) => setTimeout(() => res(), time));
61
+ const wait = time => new Promise((res) => {
62
+ setTimeout(() => {
63
+ // @ts-ignore
64
+ res();
65
+ }, time);
66
+ });
62
67
 
63
68
  /**
64
69
  * [Selenoid](https://aerokube.com/selenoid/) plugin automatically starts browsers and video recording.
package/lib/step.js CHANGED
@@ -138,13 +138,7 @@ class Step {
138
138
 
139
139
  /** @return {string} */
140
140
  humanize() {
141
- return this.name
142
- // insert a space before all caps
143
- .replace(/([A-Z])/g, ' $1')
144
- // _ chars to spaces
145
- .replace('_', ' ')
146
- // uppercase the first character
147
- .replace(/^(.)|\s(.)/g, $1 => $1.toLowerCase());
141
+ return humanizeString(this.name);
148
142
  }
149
143
 
150
144
  /** @return {string} */
@@ -247,12 +241,21 @@ class MetaStep extends Step {
247
241
  }
248
242
 
249
243
  toString() {
250
- const actorText = !this.isBDD() && !this.isWithin() ? `${this.actor}:` : this.actor;
251
- return `${this.prefix}${actorText} ${this.humanize()} ${this.humanizeArgs()}${this.suffix}`;
244
+ const actorText = this.actor;
245
+
246
+ if (this.isBDD() || this.isWithin()) {
247
+ return `${this.prefix}${actorText} ${this.name} "${this.humanizeArgs()}${this.suffix}"`;
248
+ }
249
+
250
+ if (actorText === 'I') {
251
+ return `${this.prefix}${actorText} ${this.humanize()} ${this.humanizeArgs()}${this.suffix}`;
252
+ }
253
+
254
+ return `On ${this.prefix}${actorText}: ${this.humanize()} ${this.humanizeArgs()}${this.suffix}`;
252
255
  }
253
256
 
254
257
  humanize() {
255
- return this.name;
258
+ return humanizeString(this.name);
256
259
  }
257
260
 
258
261
  setTrace() {
@@ -316,3 +319,17 @@ function dryRunResolver() {
316
319
  },
317
320
  };
318
321
  }
322
+
323
+ function humanizeString(string) {
324
+ // split strings by words, then make them all lowercase
325
+ const _result = string.replace(/([a-z](?=[A-Z]))/g, '$1 ')
326
+ .split(' ')
327
+ .map(word => word.toLowerCase());
328
+
329
+ _result[0] = _result[0] === 'i' ? capitalizeFLetter(_result[0]) : _result[0];
330
+ return _result.join(' ').trim();
331
+ }
332
+
333
+ function capitalizeFLetter(string) {
334
+ return (string[0].toUpperCase() + string.slice(1));
335
+ }
package/lib/utils.js CHANGED
@@ -472,3 +472,7 @@ module.exports.printObjectProperties = (obj) => {
472
472
 
473
473
  return `{${result}}`;
474
474
  };
475
+
476
+ module.exports.normalizeSpacesInString = (string) => {
477
+ return string.replace(/\s+/g, ' ');
478
+ };
package/lib/workers.js CHANGED
@@ -344,7 +344,9 @@ class Workers extends EventEmitter {
344
344
  this._listenWorkerEvents(workerThread);
345
345
  }
346
346
  });
347
- return new Promise(resolve => this.on('end', resolve));
347
+ return new Promise(resolve => {
348
+ this.on('end', resolve);
349
+ });
348
350
  }
349
351
 
350
352
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.5.4-beta.1",
3
+ "version": "3.5.5",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",
@@ -54,99 +54,99 @@
54
54
  "def": "./runok.js def",
55
55
  "dev:graphql": "node test/data/graphql/index.js",
56
56
  "publish:site": "./runok.js publish:site",
57
- "update-contributor-faces": "contributor-faces .",
57
+ "update-contributor-faces": "./runok.js contributor:faces",
58
58
  "dtslint": "dtslint typings --localTs './node_modules/typescript/lib'",
59
59
  "prepare": "husky install"
60
60
  },
61
61
  "dependencies": {
62
- "@codeceptjs/configure": "^0.10.0",
63
- "@codeceptjs/helper": "^1.0.2",
64
- "@cucumber/cucumber-expressions": "^16",
65
- "@cucumber/gherkin": "^26",
66
- "@cucumber/messages": "^21.0.1",
67
- "@xmldom/xmldom": "^0.7.9",
68
- "acorn": "^8.10.0",
69
- "arrify": "^2.0.1",
70
- "axios": "^1.3.3",
71
- "chai": "^4.3.6",
72
- "chai-deep-match": "^1.2.1",
73
- "chalk": "^4.1.2",
74
- "commander": "^11.0.0",
75
- "cross-spawn": "^7.0.3",
76
- "css-to-xpath": "^0.1.0",
77
- "envinfo": "^7.8.1",
78
- "escape-string-regexp": "^4.0.0",
79
- "figures": "^3.2.0",
80
- "fn-args": "^4.0.0",
81
- "fs-extra": "^8.1.0",
82
- "glob": "^6.0.1",
83
- "html-minifier": "^4.0.0",
84
- "inquirer": "^6.5.2",
85
- "joi": "^17.6.0",
86
- "js-beautify": "^1.14.0",
87
- "lodash.clonedeep": "^4.5.0",
88
- "lodash.merge": "^4.6.2",
89
- "mkdirp": "^1.0.4",
90
- "mocha": "^10.2.0",
91
- "ms": "^2.1.3",
92
- "openai": "^3.2.1",
93
- "ora-classic": "^5.4.2",
94
- "parse-function": "^5.6.4",
95
- "parse5": "^7.1.2",
96
- "promise-retry": "^1.1.1",
97
- "resq": "^1.10.2",
98
- "sprintf-js": "^1.1.1",
99
- "uuid": "^9.0"
62
+ "@codeceptjs/configure": "0.10.0",
63
+ "@codeceptjs/helper": "2.0.1",
64
+ "@cucumber/cucumber-expressions": "16",
65
+ "@cucumber/gherkin": "26",
66
+ "@cucumber/messages": "22.0.0",
67
+ "@xmldom/xmldom": "0.8.10",
68
+ "acorn": "8.10.0",
69
+ "arrify": "2.0.1",
70
+ "axios": "1.3.3",
71
+ "chai": "4.3.6",
72
+ "chai-deep-match": "1.2.1",
73
+ "chalk": "4.1.2",
74
+ "commander": "11.0.0",
75
+ "cross-spawn": "7.0.3",
76
+ "css-to-xpath": "0.1.0",
77
+ "envinfo": "7.8.1",
78
+ "escape-string-regexp": "4.0.0",
79
+ "figures": "3.2.0",
80
+ "fn-args": "4.0.0",
81
+ "fs-extra": "8.1.0",
82
+ "glob": "6.0.1",
83
+ "html-minifier": "4.0.0",
84
+ "inquirer": "6.5.2",
85
+ "joi": "17.6.0",
86
+ "js-beautify": "1.14.0",
87
+ "lodash.clonedeep": "4.5.0",
88
+ "lodash.merge": "4.6.2",
89
+ "mkdirp": "1.0.4",
90
+ "mocha": "10.2.0",
91
+ "ms": "2.1.3",
92
+ "openai": "3.2.1",
93
+ "ora-classic": "5.4.2",
94
+ "parse-function": "5.6.4",
95
+ "parse5": "7.1.2",
96
+ "promise-retry": "1.1.1",
97
+ "resq": "1.10.2",
98
+ "sprintf-js": "1.1.1",
99
+ "uuid": "9.0"
100
100
  },
101
101
  "devDependencies": {
102
- "@codeceptjs/detox-helper": "^1.0.2",
103
- "@codeceptjs/mock-request": "^0.3.1",
104
- "@faker-js/faker": "^7.6.0",
105
- "@pollyjs/adapter-puppeteer": "^6.0.5",
106
- "@pollyjs/core": "^5.1.0",
107
- "@types/inquirer": "^0.0.35",
108
- "@types/node": "^8.10.66",
109
- "@wdio/sauce-service": "^8.3.8",
110
- "@wdio/selenium-standalone-service": "^8.3.2",
111
- "@wdio/utils": "^8.3.0",
102
+ "@codeceptjs/detox-helper": "1.0.2",
103
+ "@codeceptjs/mock-request": "0.3.1",
104
+ "@faker-js/faker": "7.6.0",
105
+ "@pollyjs/adapter-puppeteer": "6.0.5",
106
+ "@pollyjs/core": "5.1.0",
107
+ "@types/inquirer": "9.0.3",
108
+ "@types/node": "20.4.4",
109
+ "@wdio/sauce-service": "8.3.8",
110
+ "@wdio/selenium-standalone-service": "8.3.2",
111
+ "@wdio/utils": "8.3.0",
112
112
  "apollo-server-express": "2.25.3",
113
- "chai-as-promised": "^7.1.1",
114
- "chai-subset": "^1.6.0",
115
- "contributor-faces": "^1.0.3",
116
- "documentation": "^12.3.0",
117
- "dtslint": "^4.1.6",
118
- "electron": "^25.2.0",
119
- "eslint": "^8.45.0",
120
- "eslint-config-airbnb-base": "^15.0.0",
121
- "eslint-plugin-import": "^2.25.4",
122
- "eslint-plugin-mocha": "^6.3.0",
123
- "expect": "^26.6.2",
124
- "express": "^4.17.2",
125
- "graphql": "^14.6.0",
126
- "husky": "^8.0.1",
127
- "inquirer-test": "^2.0.1",
128
- "jsdoc": "^3.6.10",
129
- "jsdoc-typeof-plugin": "^1.0.0",
130
- "json-server": "^0.10.1",
131
- "playwright": "^1.35.1",
132
- "puppeteer": "^10.4.0",
133
- "qrcode-terminal": "^0.12.0",
134
- "rosie": "^2.1.0",
135
- "runok": "^0.9.2",
136
- "sinon": "^15.2.0",
137
- "sinon-chai": "^3.7.0",
138
- "testcafe": "^2.1.0",
139
- "ts-morph": "^3.1.3",
140
- "ts-node": "^10.9.1",
141
- "tsd-jsdoc": "^2.5.0",
142
- "typedoc": "^0.23.10",
143
- "typedoc-plugin-markdown": "^3.13.4",
144
- "typescript": "^4.8.4",
145
- "wdio-docker-service": "^1.5.0",
146
- "webdriverio": "^8.3.8",
147
- "xml2js": "^0.6.0",
148
- "xmldom": "^0.6.0",
149
- "xpath": "0.0.27"
113
+ "chai-as-promised": "7.1.1",
114
+ "chai-subset": "1.6.0",
115
+ "contributor-faces": "1.0.3",
116
+ "documentation": "12.3.0",
117
+ "dtslint": "4.1.6",
118
+ "electron": "26.1.0",
119
+ "eslint": "8.45.0",
120
+ "eslint-config-airbnb-base": "15.0.0",
121
+ "eslint-plugin-import": "2.25.4",
122
+ "eslint-plugin-mocha": "6.3.0",
123
+ "expect": "29.6.2",
124
+ "express": "4.17.2",
125
+ "graphql": "14.6.0",
126
+ "husky": "8.0.1",
127
+ "inquirer-test": "2.0.1",
128
+ "jsdoc": "3.6.10",
129
+ "jsdoc-typeof-plugin": "1.0.0",
130
+ "json-server": "0.10.1",
131
+ "playwright": "1.35.1",
132
+ "puppeteer": "21.1.1",
133
+ "qrcode-terminal": "0.12.0",
134
+ "rosie": "2.1.0",
135
+ "runok": "0.9.2",
136
+ "sinon": "15.2.0",
137
+ "sinon-chai": "3.7.0",
138
+ "testcafe": "3.0.1",
139
+ "ts-morph": "19.0.0",
140
+ "ts-node": "10.9.1",
141
+ "tsd-jsdoc": "2.5.0",
142
+ "typedoc": "0.24.8",
143
+ "typedoc-plugin-markdown": "3.13.4",
144
+ "typescript": "5.1.6",
145
+ "wdio-docker-service": "1.5.0",
146
+ "webdriverio": "8.3.8",
147
+ "xml2js": "0.6.0",
148
+ "xmldom": "0.6.0",
149
+ "xpath": "0.0.33"
150
150
  },
151
151
  "engines": {
152
152
  "node": ">=16.0",