Skip to content

Commit 29e1be1

Browse files
author
DavertMik
committed
improved prompt for analyze plugin
1 parent 1f30058 commit 29e1be1

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

lib/plugin/analyze.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ const defaultConfig = {
3232
.map((test, index) => {
3333
if (!test || !test.err) return
3434
return `
35-
TEST #${index + 1}: ${serializeTest(test)}
36-
ERROR: ${serializeError(test.err).slice(0, MAX_DATA_LENGTH / tests.length)}`
35+
#${index + 1}: ${serializeTest(test)}
36+
${serializeError(test.err).slice(0, MAX_DATA_LENGTH / tests.length)}`.trim()
3737
})
38-
.join('\n\n---\n\n')
38+
.join('\n\n--------\n\n')
3939

4040
const messages = [
4141
{
@@ -60,25 +60,29 @@ const defaultConfig = {
6060
If there is no groups of tests, say: "No patterns found"
6161
Preserve error messages but cut them if they are too long.
6262
Respond clearly and directly, without introductory words or phrases like ‘Of course,’ ‘Here is the answer,’ etc.
63-
Do not list more than 3 tests in the group.
6463
Do not list more than 3 errors in the group.
6564
If you identify that all tests in the group have the same tag, add this tag to the group report, otherwise ignore TAG section.
6665
If you identify that all tests in the group have the same suite, add this suite to the group report, otherwise ignore SUITE section.
6766
Pick different emojis for each group.
67+
Do not include group into report if it has only one test in affected tests section.
6868
6969
Provide list of groups in following format:
7070
7171
_______________________________
7272
73-
## Group <group_number> <(percentage of failed tests in group compare to all failed tests)'>
73+
## Group <group_number>
7474
7575
* CATEGORY <category_of_failure>
7676
* ERROR <error_message_1>, <error_message_2>, ...
7777
* SUMMARY <summary_of_errors>
78-
* STEP <step_of_failure> (in format I.click(), I.see(), etc; if all failures happend on the same step)
79-
* AFFECTED TESTS (<total number of tests>)
80-
* SUITE <suite_title>, <suite_title> (only if all tests in the group have the same suite or suites)
81-
* TAG <tag> (if all tags in group have the same tag)
78+
* STEP <step_of_failure> (use CodeceptJS format I.click(), I.see(), etc; if all failures happend on the same step)
79+
* SUITE <suite_title>, <suite_title> (if SUITE is present, and if all tests in the group have the same suite or suites)
80+
* TAG <tag> (if TAG is present, and if all tests in the group have the same tag)
81+
* AFFECTED TESTS (<total number of tests>):
82+
x <test1 title>
83+
x <test2 title>
84+
x <test3 title>
85+
x ...
8286
`,
8387
},
8488
{
@@ -318,9 +322,12 @@ function serializeTest(test) {
318322
if (test.suite) {
319323
testMessage += '\n SUITE: ' + test.suite.title
320324
}
325+
if (test.parent) {
326+
testMessage += '\n SUITE: ' + test.parent.title
327+
}
321328

322329
if (test.steps?.length) {
323-
const failedSteps = test.steps.filter(s => s.status === 'failed')
330+
const failedSteps = test.steps
324331
if (failedSteps.length) testMessage += '\n STEP: ' + failedSteps.map(s => s.toCode()).join('; ')
325332
}
326333

@@ -339,5 +346,6 @@ function formatResponse(response) {
339346
.map(line => line.trim())
340347
.filter(line => !/^[A-Z\s]+$/.test(line))
341348
.map(line => markdownToAnsi(line))
349+
.map(line => line.replace(/^x /gm, ` ${colors.red.bold('x')} `))
342350
.join('\n')
343351
}

0 commit comments

Comments
 (0)