codeceptjs 3.1.1 → 3.2.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.
- package/CHANGELOG.md +120 -0
- package/README.md +2 -3
- package/bin/codecept.js +1 -0
- package/docs/advanced.md +94 -60
- package/docs/basics.md +1 -1
- package/docs/bdd.md +55 -1
- package/docs/build/Appium.js +22 -4
- package/docs/build/FileSystem.js +1 -0
- package/docs/build/Playwright.js +40 -42
- package/docs/build/Protractor.js +9 -24
- package/docs/build/Puppeteer.js +28 -30
- package/docs/build/REST.js +1 -0
- package/docs/build/WebDriver.js +2 -24
- package/docs/changelog.md +120 -0
- package/docs/commands.md +21 -7
- package/docs/configuration.md +15 -2
- package/docs/custom-helpers.md +1 -36
- package/docs/helpers/Appium.md +49 -50
- package/docs/helpers/FileSystem.md +1 -1
- package/docs/helpers/Playwright.md +16 -18
- package/docs/helpers/Puppeteer.md +18 -18
- package/docs/helpers/REST.md +3 -1
- package/docs/helpers/WebDriver.md +1 -17
- package/docs/mobile-react-native-locators.md +3 -0
- package/docs/playwright.md +40 -0
- package/docs/plugins.md +187 -70
- package/docs/reports.md +23 -5
- package/lib/actor.js +20 -2
- package/lib/codecept.js +15 -2
- package/lib/command/info.js +1 -1
- package/lib/config.js +13 -1
- package/lib/container.js +3 -1
- package/lib/data/dataTableArgument.js +35 -0
- package/lib/helper/Appium.js +22 -4
- package/lib/helper/FileSystem.js +1 -0
- package/lib/helper/Playwright.js +40 -32
- package/lib/helper/Protractor.js +2 -14
- package/lib/helper/Puppeteer.js +21 -20
- package/lib/helper/REST.js +1 -0
- package/lib/helper/WebDriver.js +2 -14
- package/lib/index.js +2 -0
- package/lib/interfaces/featureConfig.js +3 -0
- package/lib/interfaces/gherkin.js +7 -1
- package/lib/interfaces/scenarioConfig.js +4 -0
- package/lib/listener/helpers.js +1 -0
- package/lib/listener/steps.js +21 -3
- package/lib/listener/timeout.js +71 -0
- package/lib/locator.js +3 -0
- package/lib/mochaFactory.js +13 -9
- package/lib/plugin/allure.js +6 -1
- package/lib/plugin/{puppeteerCoverage.js → coverage.js} +10 -22
- package/lib/plugin/customLocator.js +2 -2
- package/lib/plugin/retryFailedStep.js +4 -3
- package/lib/plugin/retryTo.js +130 -0
- package/lib/plugin/screenshotOnFail.js +1 -0
- package/lib/plugin/stepByStepReport.js +7 -0
- package/lib/plugin/stepTimeout.js +90 -0
- package/lib/plugin/subtitles.js +88 -0
- package/lib/plugin/tryTo.js +1 -1
- package/lib/recorder.js +21 -8
- package/lib/step.js +7 -2
- package/lib/store.js +2 -0
- package/lib/ui.js +2 -2
- package/package.json +6 -7
- package/typings/index.d.ts +8 -1
- package/typings/types.d.ts +104 -71
- package/docs/angular.md +0 -325
- package/docs/helpers/Protractor.md +0 -1658
- package/docs/webapi/waitUntil.mustache +0 -11
- package/typings/Protractor.d.ts +0 -16
package/docs/plugins.md
CHANGED
|
@@ -409,6 +409,29 @@ Scenario('project update test', async (I) => {
|
|
|
409
409
|
|
|
410
410
|
- `config`
|
|
411
411
|
|
|
412
|
+
## coverage
|
|
413
|
+
|
|
414
|
+
Dumps code coverage from Playwright/Puppeteer after every test.
|
|
415
|
+
|
|
416
|
+
#### Configuration
|
|
417
|
+
|
|
418
|
+
```js
|
|
419
|
+
plugins: {
|
|
420
|
+
coverage: {
|
|
421
|
+
enabled: true
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
Possible config options:
|
|
427
|
+
|
|
428
|
+
- `coverageDir`: directory to dump coverage files
|
|
429
|
+
- `uniqueFileName`: generate a unique filename by adding uuid
|
|
430
|
+
|
|
431
|
+
### Parameters
|
|
432
|
+
|
|
433
|
+
- `config`
|
|
434
|
+
|
|
412
435
|
## customLocator
|
|
413
436
|
|
|
414
437
|
Creates a [custom locator][3] by using special attributes in HTML.
|
|
@@ -441,7 +464,7 @@ Using `data-test` attribute with `$` prefix:
|
|
|
441
464
|
// in codecept.conf.js
|
|
442
465
|
plugins: {
|
|
443
466
|
customLocator: {
|
|
444
|
-
enabled: true
|
|
467
|
+
enabled: true,
|
|
445
468
|
attribute: 'data-test'
|
|
446
469
|
}
|
|
447
470
|
}
|
|
@@ -460,7 +483,7 @@ Using `data-qa` attribute with `=` prefix:
|
|
|
460
483
|
// in codecept.conf.js
|
|
461
484
|
plugins: {
|
|
462
485
|
customLocator: {
|
|
463
|
-
enabled: true
|
|
486
|
+
enabled: true,
|
|
464
487
|
prefix: '=',
|
|
465
488
|
attribute: 'data-qa'
|
|
466
489
|
}
|
|
@@ -536,45 +559,6 @@ Enable it manually on each run via `-p` option:
|
|
|
536
559
|
|
|
537
560
|
npx codeceptjs run -p pauseOnFail
|
|
538
561
|
|
|
539
|
-
## puppeteerCoverage
|
|
540
|
-
|
|
541
|
-
Dumps puppeteers code coverage after every test.
|
|
542
|
-
|
|
543
|
-
#### Configuration
|
|
544
|
-
|
|
545
|
-
Configuration can either be taken from a corresponding helper (deprecated) or a from plugin config (recommended).
|
|
546
|
-
|
|
547
|
-
```js
|
|
548
|
-
plugins: {
|
|
549
|
-
puppeteerCoverage: {
|
|
550
|
-
enabled: true
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
```
|
|
554
|
-
|
|
555
|
-
Possible config options:
|
|
556
|
-
|
|
557
|
-
- `coverageDir`: directory to dump coverage files
|
|
558
|
-
- `uniqueFileName`: generate a unique filename by adding uuid
|
|
559
|
-
|
|
560
|
-
First of all, your mileage may vary!
|
|
561
|
-
|
|
562
|
-
To work, you need the client javascript code to be NOT uglified. They need to be built in "development" mode.
|
|
563
|
-
And the end of your tests, you'll get a directory full of coverage per test run. Now what?
|
|
564
|
-
You'll need to convert the coverage code to something istanbul can read. Good news is someone wrote the code
|
|
565
|
-
for you (see puppeteer-to-istanbul link below). Then using istanbul you need to combine the converted
|
|
566
|
-
coverage and create a report. Good luck!
|
|
567
|
-
|
|
568
|
-
Links:
|
|
569
|
-
|
|
570
|
-
- [https://github.com/GoogleChrome/puppeteer/blob/v1.12.2/docs/api.md#class-coverage][7]
|
|
571
|
-
- [https://github.com/istanbuljs/puppeteer-to-istanbul][8]
|
|
572
|
-
- [https://github.com/gotwarlost/istanbul][9]
|
|
573
|
-
|
|
574
|
-
### Parameters
|
|
575
|
-
|
|
576
|
-
- `config`
|
|
577
|
-
|
|
578
562
|
## retryFailedStep
|
|
579
563
|
|
|
580
564
|
Retries each failed step in a test.
|
|
@@ -595,9 +579,9 @@ Run tests with plugin enabled:
|
|
|
595
579
|
|
|
596
580
|
#### Configuration:
|
|
597
581
|
|
|
598
|
-
- `retries` - number of retries (by default
|
|
582
|
+
- `retries` - number of retries (by default 3),
|
|
599
583
|
- `when` - function, when to perform a retry (accepts error as parameter)
|
|
600
|
-
- `factor` - The exponential factor to use. Default is
|
|
584
|
+
- `factor` - The exponential factor to use. Default is 1.5.
|
|
601
585
|
- `minTimeout` - The number of milliseconds before starting the first retry. Default is 1000.
|
|
602
586
|
- `maxTimeout` - The maximum number of milliseconds between two retries. Default is Infinity.
|
|
603
587
|
- `randomize` - Randomizes the timeouts by multiplying with a factor between 1 to 2. Default is false.
|
|
@@ -642,6 +626,75 @@ Scenario('scenario tite', () => {
|
|
|
642
626
|
|
|
643
627
|
- `config`
|
|
644
628
|
|
|
629
|
+
## retryTo
|
|
630
|
+
|
|
631
|
+
Adds global `retryTo` which retries steps a few times before failing.
|
|
632
|
+
|
|
633
|
+
Enable this plugin in `codecept.conf.js` (enabled by default for new setups):
|
|
634
|
+
|
|
635
|
+
```js
|
|
636
|
+
plugins: {
|
|
637
|
+
retryTo: {
|
|
638
|
+
enabled: true
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
Use it in your tests:
|
|
644
|
+
|
|
645
|
+
```js
|
|
646
|
+
// retry these steps 5 times before failing
|
|
647
|
+
await retryTo((tryNum) => {
|
|
648
|
+
I.switchTo('#editor frame');
|
|
649
|
+
I.click('Open');
|
|
650
|
+
I.see('Opened')
|
|
651
|
+
}, 5);
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
Set polling interval as 3rd argument (200ms by default):
|
|
655
|
+
|
|
656
|
+
```js
|
|
657
|
+
// retry these steps 5 times before failing
|
|
658
|
+
await retryTo((tryNum) => {
|
|
659
|
+
I.switchTo('#editor frame');
|
|
660
|
+
I.click('Open');
|
|
661
|
+
I.see('Opened')
|
|
662
|
+
}, 5, 100);
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
Default polling interval can be changed in a config:
|
|
666
|
+
|
|
667
|
+
```js
|
|
668
|
+
plugins: {
|
|
669
|
+
retryTo: {
|
|
670
|
+
enabled: true,
|
|
671
|
+
pollInterval: 500,
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
Disables retryFailedStep plugin for steps inside a block;
|
|
677
|
+
|
|
678
|
+
Use this plugin if:
|
|
679
|
+
|
|
680
|
+
- you need repeat a set of actions in flaky tests
|
|
681
|
+
- iframe was not rendered and you need to retry switching to it
|
|
682
|
+
|
|
683
|
+
#### Configuration
|
|
684
|
+
|
|
685
|
+
- `pollInterval` - default interval between retries in ms. 200 by default.
|
|
686
|
+
- `registerGlobal` - to register `retryTo` function globally, true by default
|
|
687
|
+
|
|
688
|
+
If `registerGlobal` is false you can use retryTo from the plugin:
|
|
689
|
+
|
|
690
|
+
```js
|
|
691
|
+
const retryTo = codeceptjs.container.plugins('retryTo');
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
### Parameters
|
|
695
|
+
|
|
696
|
+
- `config`
|
|
697
|
+
|
|
645
698
|
## screenshotOnFail
|
|
646
699
|
|
|
647
700
|
Creates screenshot on failure. Screenshot is saved into `output` directory.
|
|
@@ -673,14 +726,14 @@ Possible config options:
|
|
|
673
726
|
|
|
674
727
|
## selenoid
|
|
675
728
|
|
|
676
|
-
[Selenoid][
|
|
729
|
+
[Selenoid][7] plugin automatically starts browsers and video recording.
|
|
677
730
|
Works with WebDriver helper.
|
|
678
731
|
|
|
679
732
|
### Prerequisite
|
|
680
733
|
|
|
681
734
|
This plugin **requires Docker** to be installed.
|
|
682
735
|
|
|
683
|
-
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][
|
|
736
|
+
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][8] tool from Selenoid
|
|
684
737
|
|
|
685
738
|
### Usage
|
|
686
739
|
|
|
@@ -709,7 +762,7 @@ plugins: {
|
|
|
709
762
|
}
|
|
710
763
|
```
|
|
711
764
|
|
|
712
|
-
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][
|
|
765
|
+
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][9] and start Selenoid automatically.
|
|
713
766
|
It will also create `browsers.json` file required by Selenoid.
|
|
714
767
|
|
|
715
768
|
In automatic mode the latest version of browser will be used for tests. It is recommended to specify exact version of each browser inside `browsers.json` file.
|
|
@@ -721,10 +774,10 @@ In automatic mode the latest version of browser will be used for tests. It is re
|
|
|
721
774
|
While this plugin can create containers for you for better control it is recommended to create and launch containers manually.
|
|
722
775
|
This is especially useful for Continous Integration server as you can configure scaling for Selenoid containers.
|
|
723
776
|
|
|
724
|
-
> Use [Selenoid Configuration Manager][
|
|
777
|
+
> Use [Selenoid Configuration Manager][8] to create and start containers semi-automatically.
|
|
725
778
|
|
|
726
779
|
1. Create `browsers.json` file in the same directory `codecept.conf.js` is located
|
|
727
|
-
[Refer to Selenoid documentation][
|
|
780
|
+
[Refer to Selenoid documentation][10] to know more about browsers.json.
|
|
728
781
|
|
|
729
782
|
_Sample browsers.json_
|
|
730
783
|
|
|
@@ -749,7 +802,7 @@ _Sample browsers.json_
|
|
|
749
802
|
|
|
750
803
|
2. Create Selenoid container
|
|
751
804
|
|
|
752
|
-
Run the following command to create a container. To know more [refer here][
|
|
805
|
+
Run the following command to create a container. To know more [refer here][11]
|
|
753
806
|
|
|
754
807
|
```bash
|
|
755
808
|
docker create \
|
|
@@ -782,7 +835,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
782
835
|
| enableVideo | Enable video recording and use `video` folder of output (default: false) |
|
|
783
836
|
| enableLog | Enable log recording and use `logs` folder of output (default: false) |
|
|
784
837
|
| deletePassed | Delete video and logs of passed tests (default : true) |
|
|
785
|
-
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][
|
|
838
|
+
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][12] to know more |
|
|
786
839
|
|
|
787
840
|
### Parameters
|
|
788
841
|
|
|
@@ -790,7 +843,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
790
843
|
|
|
791
844
|
## stepByStepReport
|
|
792
845
|
|
|
793
|
-
![step-by-step-report][
|
|
846
|
+
![step-by-step-report][13]
|
|
794
847
|
|
|
795
848
|
Generates step by step report for a test.
|
|
796
849
|
After each step in a test a screenshot is created. After test executed screenshots are combined into slideshow.
|
|
@@ -818,11 +871,81 @@ Possible config options:
|
|
|
818
871
|
- `fullPageScreenshots`: should full page screenshots be used. Default: false.
|
|
819
872
|
- `output`: a directory where reports should be stored. Default: `output`.
|
|
820
873
|
- `screenshotsForAllureReport`: If Allure plugin is enabled this plugin attaches each saved screenshot to allure report. Default: false.
|
|
874
|
+
- \`disableScreenshotOnFail : Disables the capturing of screeshots after the failed step. Default: true.
|
|
821
875
|
|
|
822
876
|
### Parameters
|
|
823
877
|
|
|
824
878
|
- `config` **any**
|
|
825
879
|
|
|
880
|
+
## stepTimeout
|
|
881
|
+
|
|
882
|
+
Set timeout for test steps globally.
|
|
883
|
+
|
|
884
|
+
Add this plugin to config file:
|
|
885
|
+
|
|
886
|
+
```js
|
|
887
|
+
plugins: {
|
|
888
|
+
stepTimeout: {
|
|
889
|
+
enabled: true
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
Run tests with plugin enabled:
|
|
895
|
+
|
|
896
|
+
npx codeceptjs run --plugins stepTimeout
|
|
897
|
+
|
|
898
|
+
#### Configuration:
|
|
899
|
+
|
|
900
|
+
- `timeout` - global step timeout, default 150 seconds
|
|
901
|
+
- `force` - whether to use timeouts set in plugin config to override step timeouts set in code with I.limitTime(x).action(...), default false
|
|
902
|
+
- `noTimeoutSteps` - an array of steps with no timeout. Default:
|
|
903
|
+
|
|
904
|
+
- `amOnPage`
|
|
905
|
+
- `wait*`
|
|
906
|
+
|
|
907
|
+
you could set your own noTimeoutSteps which would replace the default one.
|
|
908
|
+
|
|
909
|
+
- `customTimeoutSteps` - an array of step actions with custom timeout. Use it to override or extend noTimeoutSteps.
|
|
910
|
+
You can use step names or step prefixes ending with `*`. As such, `wait*` will match all steps starting with `wait`.
|
|
911
|
+
|
|
912
|
+
#### Example
|
|
913
|
+
|
|
914
|
+
```js
|
|
915
|
+
plugins: {
|
|
916
|
+
stepTimeout: {
|
|
917
|
+
enabled: true,
|
|
918
|
+
force: true,
|
|
919
|
+
noTimeoutSteps: [
|
|
920
|
+
'scroll*', // ignore all scroll steps
|
|
921
|
+
/Cookie/, // ignore all steps with a Cookie in it (by regexp)
|
|
922
|
+
],
|
|
923
|
+
customTimeoutSteps: [
|
|
924
|
+
['myFlakyStep*', 1],
|
|
925
|
+
['scrollWhichRequiresTimeout', 5],
|
|
926
|
+
]
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
```
|
|
930
|
+
|
|
931
|
+
### Parameters
|
|
932
|
+
|
|
933
|
+
- `config`
|
|
934
|
+
|
|
935
|
+
## subtitles
|
|
936
|
+
|
|
937
|
+
Automatically captures steps as subtitle, and saves it as an artifact when a video is found for a failed test
|
|
938
|
+
|
|
939
|
+
#### Configuration
|
|
940
|
+
|
|
941
|
+
```js
|
|
942
|
+
plugins: {
|
|
943
|
+
subtitles: {
|
|
944
|
+
enabled: true
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
```
|
|
948
|
+
|
|
826
949
|
## tryTo
|
|
827
950
|
|
|
828
951
|
Adds global `tryTo` function inside of which all failed steps won't fail a test but will return true/false.
|
|
@@ -897,7 +1020,7 @@ This plugin allows to run webdriverio services like:
|
|
|
897
1020
|
- browserstack
|
|
898
1021
|
- appium
|
|
899
1022
|
|
|
900
|
-
A complete list of all available services can be found on [webdriverio website][
|
|
1023
|
+
A complete list of all available services can be found on [webdriverio website][14].
|
|
901
1024
|
|
|
902
1025
|
#### Setup
|
|
903
1026
|
|
|
@@ -909,7 +1032,7 @@ See examples below:
|
|
|
909
1032
|
|
|
910
1033
|
#### Selenium Standalone Service
|
|
911
1034
|
|
|
912
|
-
Install `@wdio/selenium-standalone-service` package, as [described here][
|
|
1035
|
+
Install `@wdio/selenium-standalone-service` package, as [described here][15].
|
|
913
1036
|
It is important to make sure it is compatible with current webdriverio version.
|
|
914
1037
|
|
|
915
1038
|
Enable `wdio` plugin in plugins list and add `selenium-standalone` service:
|
|
@@ -928,7 +1051,7 @@ Please note, this service can be used with Protractor helper as well!
|
|
|
928
1051
|
|
|
929
1052
|
#### Sauce Service
|
|
930
1053
|
|
|
931
|
-
Install `@wdio/sauce-service` package, as [described here][
|
|
1054
|
+
Install `@wdio/sauce-service` package, as [described here][16].
|
|
932
1055
|
It is important to make sure it is compatible with current webdriverio version.
|
|
933
1056
|
|
|
934
1057
|
Enable `wdio` plugin in plugins list and add `sauce` service:
|
|
@@ -970,28 +1093,22 @@ In the same manner additional services from webdriverio can be installed, enable
|
|
|
970
1093
|
|
|
971
1094
|
[6]: /basics/#pause
|
|
972
1095
|
|
|
973
|
-
[7]: https://
|
|
974
|
-
|
|
975
|
-
[8]: https://github.com/istanbuljs/puppeteer-to-istanbul
|
|
976
|
-
|
|
977
|
-
[9]: https://github.com/gotwarlost/istanbul
|
|
978
|
-
|
|
979
|
-
[10]: https://aerokube.com/selenoid/
|
|
1096
|
+
[7]: https://aerokube.com/selenoid/
|
|
980
1097
|
|
|
981
|
-
[
|
|
1098
|
+
[8]: https://aerokube.com/cm/latest/
|
|
982
1099
|
|
|
983
|
-
[
|
|
1100
|
+
[9]: https://hub.docker.com/u/selenoid
|
|
984
1101
|
|
|
985
|
-
[
|
|
1102
|
+
[10]: https://aerokube.com/selenoid/latest/#_prepare_configuration
|
|
986
1103
|
|
|
987
|
-
[
|
|
1104
|
+
[11]: https://aerokube.com/selenoid/latest/#_option_2_start_selenoid_container
|
|
988
1105
|
|
|
989
|
-
[
|
|
1106
|
+
[12]: https://docs.docker.com/engine/reference/commandline/create/
|
|
990
1107
|
|
|
991
|
-
[
|
|
1108
|
+
[13]: https://codecept.io/img/codeceptjs-slideshow.gif
|
|
992
1109
|
|
|
993
|
-
[
|
|
1110
|
+
[14]: https://webdriver.io
|
|
994
1111
|
|
|
995
|
-
[
|
|
1112
|
+
[15]: https://webdriver.io/docs/selenium-standalone-service.html
|
|
996
1113
|
|
|
997
|
-
[
|
|
1114
|
+
[16]: https://webdriver.io/docs/sauce-service.html
|
package/docs/reports.md
CHANGED
|
@@ -7,8 +7,8 @@ title: Reporters
|
|
|
7
7
|
|
|
8
8
|
## Cli
|
|
9
9
|
|
|
10
|
-
By default CodeceptJS provides cli reporter with console output.
|
|
11
|
-
Test names and failures will be printed
|
|
10
|
+
By default, CodeceptJS provides cli reporter with console output.
|
|
11
|
+
Test names and failures will be printed out on screen.
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
14
|
GitHub --
|
|
@@ -33,8 +33,8 @@ GitHub --
|
|
|
33
33
|
Run with --verbose flag to see NodeJS stacktrace
|
|
34
34
|
|
|
35
35
|
```
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
|
|
37
|
+
output steps use `--steps` option:
|
|
38
38
|
```
|
|
39
39
|
npx codeceptjs run --steps
|
|
40
40
|
```
|
|
@@ -201,7 +201,7 @@ npx codeceptjs dry-run --debug -p allure
|
|
|
201
201
|
|
|
202
202
|
## ReportPortal
|
|
203
203
|
|
|
204
|
-
Allure is a great
|
|
204
|
+
Allure is a great reporting tool, however, if you are running tests on different machines it is hard to merge its XML result files to build a proper report. So, for enterprise grade reporting we recommend using [ReportPortal](https://reportportal.io).
|
|
205
205
|
|
|
206
206
|

|
|
207
207
|
|
|
@@ -376,3 +376,21 @@ npx codeceptjs run --reporter mocha-multi
|
|
|
376
376
|
```
|
|
377
377
|
|
|
378
378
|
This will give you cli with steps in console and HTML report in `output` directory.
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
## Testrail
|
|
382
|
+
|
|
383
|
+
Testrail integration with CodeceptJS is now so seamless. The test run is created automatically afterwards. The screenshots of failed tests are also attached to test results.
|
|
384
|
+
|
|
385
|
+
Try to use [codeceptjs-testrail](https://www.npmjs.com/package/codeceptjs-testrail) plugin
|
|
386
|
+
|
|
387
|
+
Install it via NPM:
|
|
388
|
+
|
|
389
|
+
```sh
|
|
390
|
+
npm i codeceptjs-testrail --save
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+

|
|
394
|
+
|
|
395
|
+
Now there is new feature, add the configuration to test run of test plan
|
|
396
|
+

|
package/lib/actor.js
CHANGED
|
@@ -27,8 +27,26 @@ class Actor {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
+
* set the maximum execution time for the next step
|
|
30
31
|
* @function
|
|
31
|
-
* @param {
|
|
32
|
+
* @param {number} timeout - step timeout in seconds
|
|
33
|
+
* @return {this}
|
|
34
|
+
* @inner
|
|
35
|
+
*/
|
|
36
|
+
limitTime(timeout) {
|
|
37
|
+
if (!store.timeouts) return this;
|
|
38
|
+
|
|
39
|
+
event.dispatcher.prependOnceListener(event.step.before, (step) => {
|
|
40
|
+
output.log(`Timeout to ${step}: ${timeout}s`);
|
|
41
|
+
step.totalTimeout = timeout * 1000;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @function
|
|
49
|
+
* @param {*} [opts]
|
|
32
50
|
* @return {this}
|
|
33
51
|
* @inner
|
|
34
52
|
*/
|
|
@@ -114,7 +132,7 @@ function recordStep(step, args) {
|
|
|
114
132
|
step.startTime = Date.now();
|
|
115
133
|
}
|
|
116
134
|
return val = step.run(...args);
|
|
117
|
-
});
|
|
135
|
+
}, false, undefined, step.totalTimeout);
|
|
118
136
|
|
|
119
137
|
event.emit(event.step.after, step);
|
|
120
138
|
|
package/lib/codecept.js
CHANGED
|
@@ -77,6 +77,7 @@ class Codecept {
|
|
|
77
77
|
global.inject = container.support;
|
|
78
78
|
global.share = container.share;
|
|
79
79
|
global.secret = require('./secret').secret;
|
|
80
|
+
global.codecept_debug = output.debug;
|
|
80
81
|
global.codeceptjs = require('./index'); // load all objects
|
|
81
82
|
|
|
82
83
|
// BDD
|
|
@@ -95,6 +96,7 @@ class Codecept {
|
|
|
95
96
|
runHook(require('./listener/steps'));
|
|
96
97
|
runHook(require('./listener/config'));
|
|
97
98
|
runHook(require('./listener/helpers'));
|
|
99
|
+
runHook(require('./listener/timeout'));
|
|
98
100
|
runHook(require('./listener/exit'));
|
|
99
101
|
|
|
100
102
|
// custom hooks
|
|
@@ -130,7 +132,16 @@ class Codecept {
|
|
|
130
132
|
let patterns = [pattern];
|
|
131
133
|
if (!pattern) {
|
|
132
134
|
patterns = [];
|
|
133
|
-
|
|
135
|
+
|
|
136
|
+
// If the user wants to test a specific set of test files as an array or string.
|
|
137
|
+
if (this.config.tests && !this.opts.features) {
|
|
138
|
+
if (Array.isArray(this.config.tests)) {
|
|
139
|
+
patterns.push(...this.config.tests);
|
|
140
|
+
} else {
|
|
141
|
+
patterns.push(this.config.tests);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
134
145
|
if (this.config.gherkin.features && !this.opts.tests) {
|
|
135
146
|
if (Array.isArray(this.config.gherkin.features)) {
|
|
136
147
|
this.config.gherkin.features.forEach(feature => {
|
|
@@ -147,7 +158,9 @@ class Codecept {
|
|
|
147
158
|
if (!fsPath.isAbsolute(file)) {
|
|
148
159
|
file = fsPath.join(global.codecept_dir, file);
|
|
149
160
|
}
|
|
150
|
-
this.testFiles.
|
|
161
|
+
if (!this.testFiles.includes(fsPath.resolve(file))) {
|
|
162
|
+
this.testFiles.push(fsPath.resolve(file));
|
|
163
|
+
}
|
|
151
164
|
});
|
|
152
165
|
}
|
|
153
166
|
}
|
package/lib/command/info.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = async function (path) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
output.print('***************************************');
|
|
35
|
-
output.print('If you have questions ask them in our Slack:
|
|
35
|
+
output.print('If you have questions ask them in our Slack: http://bit.ly/chat-codeceptjs');
|
|
36
36
|
output.print('Or ask them on our discussion board: https://codecept.discourse.group/');
|
|
37
37
|
output.print('Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues');
|
|
38
38
|
output.print('***************************************');
|
package/lib/config.js
CHANGED
|
@@ -13,6 +13,7 @@ const defaultConfig = {
|
|
|
13
13
|
include: {},
|
|
14
14
|
mocha: {},
|
|
15
15
|
bootstrap: null,
|
|
16
|
+
timeout: null,
|
|
16
17
|
teardown: null,
|
|
17
18
|
hooks: [],
|
|
18
19
|
gherkin: {},
|
|
@@ -21,6 +22,17 @@ const defaultConfig = {
|
|
|
21
22
|
enabled: true, // will be disabled by default in 2.0
|
|
22
23
|
},
|
|
23
24
|
},
|
|
25
|
+
stepTimeout: 0,
|
|
26
|
+
stepTimeoutOverride: [
|
|
27
|
+
{
|
|
28
|
+
pattern: 'wait.*',
|
|
29
|
+
timeout: 0,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
pattern: 'amOnPage',
|
|
33
|
+
timeout: 0,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
24
36
|
};
|
|
25
37
|
|
|
26
38
|
let hooks = [];
|
|
@@ -128,7 +140,7 @@ function loadConfigFile(configFile) {
|
|
|
128
140
|
const extensionName = path.extname(configFile);
|
|
129
141
|
|
|
130
142
|
// .conf.js config file
|
|
131
|
-
if (extensionName === '.js' || extensionName === '.ts') {
|
|
143
|
+
if (extensionName === '.js' || extensionName === '.ts' || extensionName === '.cjs') {
|
|
132
144
|
return Config.create(require(configFile).config);
|
|
133
145
|
}
|
|
134
146
|
|
package/lib/container.js
CHANGED
|
@@ -7,6 +7,7 @@ const MochaFactory = require('./mochaFactory');
|
|
|
7
7
|
const recorder = require('./recorder');
|
|
8
8
|
const event = require('./event');
|
|
9
9
|
const WorkerStorage = require('./workerStorage');
|
|
10
|
+
const store = require('./store');
|
|
10
11
|
|
|
11
12
|
let container = {
|
|
12
13
|
helpers: {},
|
|
@@ -45,6 +46,7 @@ class Container {
|
|
|
45
46
|
container.support = createSupportObjects(config.include || {});
|
|
46
47
|
container.plugins = createPlugins(config.plugins || {}, opts);
|
|
47
48
|
if (config.gherkin) loadGherkinSteps(config.gherkin.steps || []);
|
|
49
|
+
if (opts && typeof opts.timeouts === 'boolean') store.timeouts = opts.timeouts;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
|
@@ -233,7 +235,7 @@ function createSupportObjects(config) {
|
|
|
233
235
|
const currentObject = objects[object];
|
|
234
236
|
Object.keys(currentObject).forEach((method) => {
|
|
235
237
|
const currentMethod = currentObject[method];
|
|
236
|
-
if (currentMethod[Symbol.toStringTag] === 'AsyncFunction') {
|
|
238
|
+
if (currentMethod && currentMethod[Symbol.toStringTag] === 'AsyncFunction') {
|
|
237
239
|
objects[object][method] = asyncWrapper(currentMethod);
|
|
238
240
|
}
|
|
239
241
|
});
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataTableArgument class to store the Cucumber data table from
|
|
3
|
+
* a step as an object with methods that can be used to access the data.
|
|
4
|
+
*/
|
|
1
5
|
class DataTableArgument {
|
|
6
|
+
/** @param {*} gherkinDataTable */
|
|
2
7
|
constructor(gherkinDataTable) {
|
|
3
8
|
this.rawData = gherkinDataTable.rows.map((row) => {
|
|
4
9
|
return row.cells.map((cell) => {
|
|
@@ -7,16 +12,25 @@ class DataTableArgument {
|
|
|
7
12
|
});
|
|
8
13
|
}
|
|
9
14
|
|
|
15
|
+
/** Returns the table as a 2-D array
|
|
16
|
+
* @returns {string[][]}
|
|
17
|
+
*/
|
|
10
18
|
raw() {
|
|
11
19
|
return this.rawData.slice(0);
|
|
12
20
|
}
|
|
13
21
|
|
|
22
|
+
/** Returns the table as a 2-D array, without the first row
|
|
23
|
+
* @returns {string[][]}
|
|
24
|
+
*/
|
|
14
25
|
rows() {
|
|
15
26
|
const copy = this.raw();
|
|
16
27
|
copy.shift();
|
|
17
28
|
return copy;
|
|
18
29
|
}
|
|
19
30
|
|
|
31
|
+
/** Returns an array of objects where each row is converted to an object (column header is the key)
|
|
32
|
+
* @returns {any[]}
|
|
33
|
+
*/
|
|
20
34
|
hashes() {
|
|
21
35
|
const copy = this.raw();
|
|
22
36
|
const header = copy.shift();
|
|
@@ -26,6 +40,27 @@ class DataTableArgument {
|
|
|
26
40
|
return r;
|
|
27
41
|
});
|
|
28
42
|
}
|
|
43
|
+
|
|
44
|
+
/** Returns an object where each row corresponds to an entry
|
|
45
|
+
* (first column is the key, second column is the value)
|
|
46
|
+
* @returns {Record<string, string>}
|
|
47
|
+
*/
|
|
48
|
+
rowsHash() {
|
|
49
|
+
const rows = this.raw();
|
|
50
|
+
const everyRowHasTwoColumns = rows.every((row) => row.length === 2);
|
|
51
|
+
if (!everyRowHasTwoColumns) {
|
|
52
|
+
throw new Error('rowsHash can only be called on a data table where all rows have exactly two columns');
|
|
53
|
+
}
|
|
54
|
+
/** @type {Record<string, string>} */
|
|
55
|
+
const result = {};
|
|
56
|
+
rows.forEach((x) => (result[x[0]] = x[1]));
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Transposed the data */
|
|
61
|
+
transpose() {
|
|
62
|
+
this.rawData = this.rawData[0].map((x, i) => this.rawData.map((y) => y[i]));
|
|
63
|
+
}
|
|
29
64
|
}
|
|
30
65
|
|
|
31
66
|
module.exports = DataTableArgument;
|