Skip to content

Commit 2a242e4

Browse files
DavertMikDavertMik
and
DavertMik
authored
Feat/analyze result (#4753)
* added result object, improved transport of tests * fixed setting name for test * fixed workers tests * improved handling information between workers and main process * fixed tests * added result to typings * fixed printing steps * fixed def & failing tests * fixing timeout errors * fixed mocha hooks, analyze plugin, added custom reporter tests * improved prompt for analyze plugin * refactored timeouts to fix tests * fixed saving screenshot file * fixed step sections * fixed tests for timeout errors * added change fot pageInfo plugin * fixed timeout tests * fixed timeout tests with retries --------- Co-authored-by: DavertMik <davert@testomat.io>
1 parent f27e662 commit 2a242e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1661
-892
lines changed

.github/workflows/webdriver.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
3939
- name: start a server
4040
run: 'php -S 127.0.0.1:8000 -t test/data/app &'
41-
- name: Check CodeceptJS can be started
41+
- name: check
4242
run: './bin/codecept.js check -c test/acceptance/codecept.WebDriver.js'
4343
- name: run unit tests
4444
run: ./node_modules/.bin/mocha test/helper/WebDriver_test.js --exit

docs/plugins.md

+35-19
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ title: Plugins
77

88
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
99

10+
## analyze
11+
12+
### Parameters
13+
14+
- `config` **any** (optional, default `{}`)
15+
1016
## autoDelay
1117

1218
Sometimes it takes some time for a page to respond to user's actions.
@@ -521,29 +527,13 @@ I.click('=sign-up') // matches => [data-qa=sign-up],[data-test=sign-up]
521527
522528
- `config` &#x20;
523529
524-
## debugErrors
525-
526-
Prints errors found in HTML code after each failed test.
530+
## customReporter
527531
528-
It scans HTML and searches for elements with error classes.
529-
If an element found prints a text from it to console and adds as artifact to the test.
530-
531-
Enable this plugin in config:
532-
533-
```js
534-
plugins: {
535-
debugErrors: {
536-
enabled: true,
537-
}
538-
```
539-
540-
Additional config options:
541-
542-
- `errorClasses` - list of classes to search for errors (default: `['error', 'warning', 'alert', 'danger']`)
532+
Sample custom reporter for CodeceptJS.
543533
544534
### Parameters
545535
546-
- `config` (optional, default `{}`)
536+
- `config` &#x20;
547537
548538
## eachElement
549539
@@ -672,6 +662,32 @@ More config options are available:
672662
673663
- `config` (optional, default `{}`)
674664
665+
## pageInfo
666+
667+
Collects information from web page after each failed test and adds it to the test as an artifact.
668+
It is suggested to enable this plugin if you run tests on CI and you need to debug failed tests.
669+
This plugin can be paired with `analyze` plugin to provide more context.
670+
671+
It collects URL, HTML errors (by classes), and browser logs.
672+
673+
Enable this plugin in config:
674+
675+
```js
676+
plugins: {
677+
pageInfo: {
678+
enabled: true,
679+
}
680+
```
681+
682+
Additional config options:
683+
684+
- `errorClasses` - list of classes to search for errors (default: `['error', 'warning', 'alert', 'danger']`)
685+
- `browserLogs` - list of types of errors to search for in browser logs (default: `['error']`)
686+
687+
### Parameters
688+
689+
- `config` (optional, default `{}`)
690+
675691
## pauseOnFail
676692
677693
Automatically launches [interactive pause][11] when a test fails.

examples/codecept.config.js

+13-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require('./heal_recipes');
1+
require('./heal_recipes')
22

33
exports.config = {
44
output: './output',
@@ -34,22 +34,21 @@ exports.config = {
3434
},
3535
gherkin: {
3636
features: './features/*.feature',
37-
steps: [
38-
'./step_definitions/steps.js',
39-
],
37+
steps: ['./step_definitions/steps.js'],
4038
},
4139
plugins: {
42-
tryTo: {
43-
enabled: true,
44-
},
45-
heal: {
40+
analyze: {
4641
enabled: true,
4742
},
43+
// heal: {
44+
// enabled: true,
45+
// },
46+
// customReporter: {
47+
// enabled: true,
48+
// },
4849
wdio: {
4950
enabled: false,
50-
services: [
51-
'selenium-standalone',
52-
],
51+
services: ['selenium-standalone'],
5352
},
5453
stepByStepReport: {},
5554
autoDelay: {
@@ -61,10 +60,8 @@ exports.config = {
6160
subtitles: {
6261
enabled: true,
6362
},
64-
retryTo: {
65-
enabled: true,
66-
},
6763
},
64+
6865
tests: './*_test.js',
6966
// timeout: 100,
7067
multiple: {
@@ -73,11 +70,8 @@ exports.config = {
7370
},
7471
default: {
7572
grep: 'signin',
76-
browsers: [
77-
'chrome',
78-
'firefox',
79-
],
73+
browsers: ['chrome', 'firefox'],
8074
},
8175
},
8276
name: 'tests',
83-
};
77+
}

examples/github_test.js

+43-40
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
// / <reference path="./steps.d.ts" />
2-
Feature('GitHub');
2+
Feature('GitHub')
33

44
Before(({ I }) => {
5-
I.amOnPage('https://github.com');
6-
});
5+
I.amOnPage('https://github.com')
6+
I.see('GitLab')
7+
})
78

89
xScenario('test ai features', ({ I }) => {
9-
I.amOnPage('https://getbootstrap.com/docs/5.1/examples/checkout/');
10-
pause();
11-
});
10+
I.amOnPage('https://getbootstrap.com/docs/5.1/examples/checkout/')
11+
})
1212

1313
Scenario('Incorrect search for Codeceptjs', ({ I }) => {
14-
I.fillField('.search-input', 'CodeceptJS');
15-
I.pressKey('Enter');
16-
I.waitForElement('[data-testid=search-sub-header]', 10);
17-
I.see('Supercharged End 2 End Testing');
18-
});
14+
I.fillField('.search-input', 'CodeceptJS')
15+
I.pressKey('Enter')
16+
I.waitForElement('[data-testid=search-sub-header]', 10)
17+
I.see('Supercharged End 2 End Testing')
18+
})
1919

2020
Scenario('Visit Home Page @retry', async ({ I }) => {
2121
// .retry({ retries: 3, minTimeout: 1000 })
22-
I.retry(2).see('GitHub');
23-
I.retry(3).see('ALL');
24-
I.retry(2).see('IMAGES');
25-
});
22+
I.retry(2).see('GitHub')
23+
I.retry(3).see('ALL')
24+
I.retry(2).see('IMAGES')
25+
})
2626

2727
Scenario('search @grop', { timeout: 6 }, ({ I }) => {
28-
I.amOnPage('https://github.com/search');
28+
I.amOnPage('https://github.com/search')
2929
const a = {
3030
b: {
3131
c: 'asdasdasd',
3232
},
33-
};
33+
}
3434
const b = {
3535
users: {
3636
admin: {
@@ -42,35 +42,38 @@ Scenario('search @grop', { timeout: 6 }, ({ I }) => {
4242
other: (world = '') => `Hello ${world}`,
4343
},
4444
urls: {},
45-
};
46-
I.fillField('Search GitHub', 'CodeceptJS');
45+
}
46+
I.fillField('Search GitHub', 'CodeceptJS')
4747
// pause({ a, b });
48-
I.pressKey('Enter');
49-
I.wait(3);
48+
I.pressKey('Enter')
49+
I.wait(3)
5050
// pause();
51-
I.see('Codeception/CodeceptJS', locate('.repo-list .repo-list-item').first());
52-
});
51+
I.see('Codeception/CodeceptJS', locate('.repo-list .repo-list-item').first())
52+
})
5353

5454
Scenario('signin @sign', { timeout: 6 }, ({ I, loginPage }) => {
55-
I.say('it should not enter');
56-
loginPage.login('something@totest.com', '123456');
57-
I.see('Incorrect username or password.', '.flash-error');
58-
}).tag('normal').tag('important').tag('@slow');
55+
I.say('it should not enter')
56+
loginPage.login('something@totest.com', '123456')
57+
I.see('Incorrect username or password.', '.flash-error')
58+
})
59+
.tag('normal')
60+
.tag('important')
61+
.tag('@slow')
5962

6063
Scenario('signin2', { timeout: 1 }, ({ I, Smth }) => {
61-
Smth.openAndLogin();
62-
I.see('Incorrect username or password.', '.flash-error');
63-
});
64+
Smth.openAndLogin()
65+
I.see('Incorrect username or password.', '.flash-error')
66+
})
6467

6568
Scenario('register', ({ I }) => {
6669
within('.js-signup-form', () => {
67-
I.fillField('user[login]', 'User');
68-
I.fillField('user[email]', 'user@user.com');
69-
I.fillField('user[password]', 'user@user.com');
70-
I.fillField('q', 'aaa');
71-
I.click('button');
72-
});
73-
I.see('There were problems creating your account.');
74-
I.click('Explore');
75-
I.seeInCurrentUrl('/explore');
76-
});
70+
I.fillField('user[login]', 'User')
71+
I.fillField('user[email]', 'user@user.com')
72+
I.fillField('user[password]', 'user@user.com')
73+
I.fillField('q', 'aaa')
74+
I.click('button')
75+
})
76+
I.see('There were problems creating your account.')
77+
I.click('Explore')
78+
I.seeInCurrentUrl('/explore')
79+
})

examples/selenoid-example/browsers.json

-22
This file was deleted.

examples/selenoid-example/codecept.conf.js

-29
This file was deleted.

examples/selenoid-example/git_test.js

-16
This file was deleted.

lib/actor.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ const MetaStep = require('./step/meta')
33
const recordStep = require('./step/record')
44
const container = require('./container')
55
const { methodsOfObject } = require('./utils')
6-
const { TIMEOUT_ORDER } = require('./step/timeout')
7-
const recorder = require('./recorder')
6+
const { TIMEOUT_ORDER } = require('./timeout')
87
const event = require('./event')
98
const store = require('./store')
109
const output = require('./output')

0 commit comments

Comments
 (0)