codeceptjs 3.0.6 → 3.1.2

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 (62) hide show
  1. package/CHANGELOG.md +92 -8
  2. package/README.md +9 -1
  3. package/bin/codecept.js +28 -17
  4. package/docs/build/Appium.js +69 -0
  5. package/docs/build/GraphQL.js +9 -10
  6. package/docs/build/Playwright.js +271 -63
  7. package/docs/build/Protractor.js +2 -0
  8. package/docs/build/Puppeteer.js +56 -18
  9. package/docs/build/REST.js +16 -3
  10. package/docs/build/WebDriver.js +82 -16
  11. package/docs/changelog.md +93 -9
  12. package/docs/configuration.md +15 -2
  13. package/docs/email.md +8 -8
  14. package/docs/examples.md +3 -3
  15. package/docs/helpers/Appium.md +66 -68
  16. package/docs/helpers/MockRequest.md +3 -3
  17. package/docs/helpers/Playwright.md +269 -203
  18. package/docs/helpers/Puppeteer.md +17 -1
  19. package/docs/helpers/REST.md +23 -9
  20. package/docs/helpers/WebDriver.md +3 -2
  21. package/docs/locators.md +27 -0
  22. package/docs/mobile.md +2 -1
  23. package/docs/nightmare.md +0 -5
  24. package/docs/parallel.md +14 -7
  25. package/docs/playwright.md +178 -11
  26. package/docs/plugins.md +61 -69
  27. package/docs/react.md +1 -1
  28. package/docs/reports.md +5 -4
  29. package/lib/actor.js +1 -2
  30. package/lib/codecept.js +13 -2
  31. package/lib/command/definitions.js +8 -1
  32. package/lib/command/interactive.js +4 -2
  33. package/lib/command/run-multiple/collection.js +4 -0
  34. package/lib/container.js +3 -3
  35. package/lib/helper/Appium.js +41 -0
  36. package/lib/helper/GraphQL.js +9 -10
  37. package/lib/helper/Playwright.js +218 -70
  38. package/lib/helper/Protractor.js +2 -0
  39. package/lib/helper/Puppeteer.js +56 -18
  40. package/lib/helper/REST.js +12 -0
  41. package/lib/helper/WebDriver.js +82 -16
  42. package/lib/helper/errors/ConnectionRefused.js +1 -1
  43. package/lib/helper/extras/Popup.js +1 -1
  44. package/lib/helper/extras/React.js +44 -32
  45. package/lib/interfaces/gherkin.js +1 -0
  46. package/lib/listener/exit.js +2 -4
  47. package/lib/listener/helpers.js +3 -4
  48. package/lib/locator.js +7 -0
  49. package/lib/mochaFactory.js +11 -6
  50. package/lib/output.js +5 -2
  51. package/lib/plugin/allure.js +7 -18
  52. package/lib/plugin/commentStep.js +1 -1
  53. package/lib/plugin/{puppeteerCoverage.js → coverage.js} +10 -22
  54. package/lib/plugin/customLocator.js +2 -2
  55. package/lib/plugin/screenshotOnFail.js +5 -0
  56. package/lib/plugin/subtitles.js +88 -0
  57. package/lib/plugin/tryTo.js +1 -1
  58. package/lib/step.js +4 -2
  59. package/lib/ui.js +6 -2
  60. package/package.json +5 -4
  61. package/typings/index.d.ts +44 -21
  62. package/typings/types.d.ts +137 -16
@@ -11,7 +11,7 @@ After running `codeceptjs init` it should be saved in test root.
11
11
 
12
12
  Here is an overview of available options with their defaults:
13
13
 
14
- * **tests**: `"./*_test.js"` - pattern to locate tests. Allows to enter [glob pattern](https://github.com/isaacs/node-glob).
14
+ * **tests**: `"./*_test.js"` - pattern to locate tests. Allows to enter [glob pattern](https://github.com/isaacs/node-glob), Can either be a pattern to locate tests or an array of patterns to locate tests / test file names.
15
15
  * **grep**: - pattern to filter tests by name
16
16
  * **include**: `{}` - actors and page objects to be registered in DI container and included in tests. Accepts objects and module `require` paths
17
17
  * **timeout**: `10000` - default tests timeout
@@ -47,7 +47,20 @@ exports.config = {
47
47
  require: ["ts-node/register", "should"]
48
48
  }
49
49
  ```
50
-
50
+ For array of test pattern
51
+ ```js
52
+ exports.config = {
53
+ tests: ['./*_test.js','./sampleTest.js'],
54
+ timeout: 10000,
55
+ output: '',
56
+ helpers: {},
57
+ include: {},
58
+ bootstrap: false,
59
+ mocha: {},
60
+ // require modules
61
+ require: ["ts-node/register", "should"]
62
+ }
63
+ ```
51
64
  ## Dynamic Configuration
52
65
 
53
66
  By default `codecept.json` is used for configuration. You can override its values in runtime by using `--override` or `-o` option in command line, passing valid JSON as a value:
package/docs/email.md CHANGED
@@ -6,10 +6,10 @@ title: Email Testing
6
6
  # Email Testing
7
7
 
8
8
  In End 2 End testing we need to interact with emails.
9
- Email delivery can't tested locally or mocked while testing.
10
- That's why for an end to end test you need to use a real emails to be sent and real email address to receive that emails.
9
+ Email delivery can't be tested locally or mocked while testing.
10
+ That's why for an end to end test you need real emails to be sent and real email address to receive that emails.
11
11
 
12
- Setting up an email server can be hard. So we recommend to use a [MailSlurp](https://mailslurp.com/) - a service designed for testing emails. It creates disposable mailboxes and provides you an access to those mailboxes via REST API.
12
+ Setting up an email server can be hard. So we recommend to use [MailSlurp](https://mailslurp.com/) - a service designed for testing emails. It creates disposable mailboxes and provides you an access to those mailboxes via REST API.
13
13
 
14
14
  > You no longer need to open your gmail account in a browser to check for an email!
15
15
 
@@ -41,7 +41,7 @@ npx codeceptjs def
41
41
 
42
42
  ## Creating Mailbox
43
43
 
44
- MailSlurp allows you to create disposable mailboxes. It means that an email address is created for a one test only and is deleted afterwards. So you can be confident that no other emails are received at that address.
44
+ MailSlurp allows you to create disposable mailboxes. It means that an email address is created for one test only and is deleted afterwards. So you can be confident that no other emails are received at that address.
45
45
 
46
46
  To create a mailbox use `I.haveNewMailbox()` command:
47
47
 
@@ -57,7 +57,7 @@ mailbox object contains:
57
57
 
58
58
  > See [MailSlurp's guide](https://www.mailslurp.com/guides/getting-started/#create-email-addresses) for details.
59
59
 
60
- Mailbox is opened on creation. If you need more than one mailboxes and you want to switch between them use `openMailbox` method:
60
+ Mailbox is opened on creation. If you need more than one mailbox and you want to switch between them use `openMailbox` method:
61
61
 
62
62
  ```js
63
63
  const mailbox1 = await I.haveNewMailbox();
@@ -71,7 +71,7 @@ I.openMailbox(mailbox1);
71
71
 
72
72
  A last created mailbox will be activated. It means that it will be used by default to check for emails.
73
73
 
74
- After an action that triggers sending an email is performed on a website you should wait for this email to be received.
74
+ After an action that triggers sending an email is performed on a website, you should wait for this email to be received.
75
75
  A timeout for waiting an email can be set globally for a helper or for a one call.
76
76
 
77
77
  Use `waitForLatestEmail` function to return the first email from a mailbox:
@@ -109,7 +109,7 @@ const email = await I.waitForLatestEmail();
109
109
  ```
110
110
  > Please note, that we use `await` to assign email. This should be declared inside async function
111
111
 
112
- An `email` object contains following fields:
112
+ An `email` object contains the following fields:
113
113
 
114
114
  * `subject`
115
115
  * `for`
@@ -130,7 +130,7 @@ I.amOnPage(url);
130
130
 
131
131
  ## Assertions
132
132
 
133
- Assertions are performed on the currently opened email.Email is opened on `waitFor` email call, however, you can open an exact email by using `openEmail` function.
133
+ Assertions are performed on the currently opened email. Email is opened on `waitFor` email call, however, you can open an exact email by using `openEmail` function.
134
134
 
135
135
  ```js
136
136
  const email1 = await I.waitForLatestEmail();
package/docs/examples.md CHANGED
@@ -8,9 +8,9 @@ editLink: false
8
8
 
9
9
  # Examples
10
10
  > Add your own examples to our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Examples)
11
- ## [TodoMVC Examples](https://github.com/codeceptjs/examples)
11
+ ## [TodoMVC Examples](https://github.com/codecept-js/examples)
12
12
 
13
- ![](https://github.com/codeceptjs/examples/raw/master/todo.png)
13
+ ![](https://github.com/codecept-js/examples/raw/master/todo.png)
14
14
 
15
15
  Playground repository where you can run tests in different helpers on a basic single-page website.
16
16
 
@@ -155,4 +155,4 @@ Suggestions and improvements are welcome , please raise a ticket in Issue tab.
155
155
  * Step by step setup in README
156
156
  * Two helpers are added. UI - Puppeteer , API - REST and chai-codeceptJS for assetion
157
157
  * ESLint for code check
158
- * Upcoming : API generic functions , Adaptor design pattern , More utilities
158
+ * Upcoming : API generic functions , Adaptor design pattern , More utilities
@@ -945,6 +945,57 @@ If multiple elements found returns first element.
945
945
 
946
946
  Returns **[Promise][13]<[string][4]>** attribute value
947
947
 
948
+ ### grabNumberOfVisibleElements
949
+
950
+ Grab number of visible elements by locator.
951
+ Resumes test execution, so **should be used inside async function with `await`** operator.
952
+
953
+ ```js
954
+ let numOfElements = await I.grabNumberOfVisibleElements('p');
955
+ ```
956
+
957
+ #### Parameters
958
+
959
+ - `locator` **([string][4] \| [object][6])** located by CSS|XPath|strict locator.
960
+
961
+ Returns **[Promise][13]<[number][8]>** number of visible elements
962
+
963
+ ### grabAttributeFrom
964
+
965
+ Can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
966
+
967
+ Retrieves an attribute from an element located by CSS or XPath and returns it to test.
968
+ Resumes test execution, so **should be used inside async with `await`** operator.
969
+ If more than one element is found - attribute of first element is returned.
970
+
971
+ ```js
972
+ let hint = await I.grabAttributeFrom('#tooltip', 'title');
973
+ ```
974
+
975
+ #### Parameters
976
+
977
+ - `locator` **([string][4] \| [object][6])** element located by CSS|XPath|strict locator.
978
+ - `attr` **[string][4]** attribute name.
979
+
980
+ Returns **[Promise][13]<[string][4]>** attribute value
981
+
982
+ ### grabAttributeFromAll
983
+
984
+ Can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
985
+ Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
986
+ Resumes test execution, so **should be used inside async with `await`** operator.
987
+
988
+ ```js
989
+ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
990
+ ```
991
+
992
+ #### Parameters
993
+
994
+ - `locator` **([string][4] \| [object][6])** element located by CSS|XPath|strict locator.
995
+ - `attr` **[string][4]** attribute name.
996
+
997
+ Returns **[Promise][13]<[Array][14]<[string][4]>>** attribute value
998
+
948
999
  ### grabValueFromAll
949
1000
 
950
1001
  Retrieves an array of value from a form located by CSS or XPath and returns it to test.
@@ -976,6 +1027,19 @@ let email = await I.grabValueFrom('input[name=email]');
976
1027
 
977
1028
  Returns **[Promise][13]<[string][4]>** attribute value
978
1029
 
1030
+ ### saveScreenshot
1031
+
1032
+ Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
1033
+ Filename is relative to output folder.
1034
+
1035
+ ```js
1036
+ I.saveScreenshot('debug.png');
1037
+ ```
1038
+
1039
+ #### Parameters
1040
+
1041
+ - `fileName` **[string][4]** file name to save.
1042
+
979
1043
  ### scrollIntoView
980
1044
 
981
1045
  Scroll element into viewport.
@@ -1437,39 +1501,6 @@ let postHTML = await I.grabHTMLFrom('#post');
1437
1501
 
1438
1502
  Returns **[Promise][13]<[string][4]>** HTML code for an element
1439
1503
 
1440
- ### grabAttributeFromAll
1441
-
1442
- Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
1443
- Resumes test execution, so **should be used inside async with `await`** operator.
1444
-
1445
- ```js
1446
- let hints = await I.grabAttributeFromAll('.tooltip', 'title');
1447
- ```
1448
-
1449
- #### Parameters
1450
-
1451
- - `locator` **([string][4] \| [object][6])** element located by CSS|XPath|strict locator.
1452
- - `attr` **[string][4]** attribute name.
1453
-
1454
- Returns **[Promise][13]<[Array][14]<[string][4]>>** attribute valueAppium: can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
1455
-
1456
- ### grabAttributeFrom
1457
-
1458
- Retrieves an attribute from an element located by CSS or XPath and returns it to test.
1459
- Resumes test execution, so **should be used inside async with `await`** operator.
1460
- If more than one element is found - attribute of first element is returned.
1461
-
1462
- ```js
1463
- let hint = await I.grabAttributeFrom('#tooltip', 'title');
1464
- ```
1465
-
1466
- #### Parameters
1467
-
1468
- - `locator` **([string][4] \| [object][6])** element located by CSS|XPath|strict locator.
1469
- - `attr` **[string][4]** attribute name.
1470
-
1471
- Returns **[Promise][13]<[string][4]>** attribute valueAppium: can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
1472
-
1473
1504
  ### seeTextEquals
1474
1505
 
1475
1506
  Checks that text is equal to provided one.
@@ -1597,21 +1628,6 @@ I.seeAttributesOnElements('//form', { method: "post"});
1597
1628
  - `locator` **([string][4] \| [object][6])** located by CSS|XPath|strict locator.
1598
1629
  - `attributes` **[object][6]** attributes and their values to check.
1599
1630
 
1600
- ### grabNumberOfVisibleElements
1601
-
1602
- Grab number of visible elements by locator.
1603
- Resumes test execution, so **should be used inside async function with `await`** operator.
1604
-
1605
- ```js
1606
- let numOfElements = await I.grabNumberOfVisibleElements('p');
1607
- ```
1608
-
1609
- #### Parameters
1610
-
1611
- - `locator` **([string][4] \| [object][6])** located by CSS|XPath|strict locator.
1612
-
1613
- Returns **[Promise][13]<[number][8]>** number of visible elements
1614
-
1615
1631
  ### scrollTo
1616
1632
 
1617
1633
  Scrolls to element matched by locator.
@@ -1660,27 +1676,11 @@ I.saveElementScreenshot(`#submit`,'debug.png');
1660
1676
  - `locator` **([string][4] \| [object][6])** element located by CSS|XPath|strict locator.
1661
1677
  - `fileName` **[string][4]** file name to save.
1662
1678
 
1663
- ### saveScreenshot
1664
-
1665
- Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
1666
- Filename is relative to output folder.
1667
- Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
1668
-
1669
- ```js
1670
- I.saveScreenshot('debug.png');
1671
- I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
1672
- ```
1673
-
1674
- #### Parameters
1675
-
1676
- - `fileName` **[string][4]** file name to save.
1677
- - `fullPage` **[boolean][20]** (optional, `false` by default) flag to enable fullscreen screenshot mode. (optional, default `false`)
1678
-
1679
1679
  ### type
1680
1680
 
1681
1681
  Types out the given text into an active field.
1682
1682
  To slow down typing use a second parameter, to set interval between key presses.
1683
- _Note:_ Should be used when [`fillField`][21] is not an option.
1683
+ _Note:_ Should be used when [`fillField`][20] is not an option.
1684
1684
 
1685
1685
  ```js
1686
1686
  // passing in a string
@@ -1918,6 +1918,4 @@ Returns **([Promise][13]<DOMRect> | [Promise][13]<[number][8]>)** Element
1918
1918
 
1919
1919
  [19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
1920
1920
 
1921
- [20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
1922
-
1923
- [21]: #fillfield
1921
+ [20]: #fillfield
@@ -56,7 +56,7 @@ helpers: {
56
56
  Puppeteer: {
57
57
  // regular Puppeteer config here
58
58
  },
59
- MockRequest: {
59
+ MockRequestHelper: {
60
60
  require: '@codeceptjs/mock-request',
61
61
  }
62
62
  }
@@ -67,7 +67,7 @@ helpers: {
67
67
  ```js
68
68
  // sample options
69
69
  helpers: {
70
- MockRequest: {
70
+ MockRequestHelper: {
71
71
  require: '@codeceptjs/mock-request',
72
72
  mode: record,
73
73
  recordIfMissing: true,
@@ -115,7 +115,7 @@ helpers: {
115
115
  WebDriver: {
116
116
  // regular WebDriver config here
117
117
  },
118
- MockRequest: {
118
+ MockRequestHelper: {
119
119
  require: '@codeceptjs/mock-request',
120
120
  }
121
121
  }