Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add run context to reportItem #2703 #2720

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default class Reporter {
errs: [],
unstable: false,
startTime: null,
testRunInfo: null
testRunInfo: null,
contexts: []
Copy link
Collaborator

@miherlosev miherlosev Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two different contexts: fixture and test.
See this help topic for more detail.
So instead of a single context prop, please add two properties: ctx and fixtureCtx.

};
}

Expand All @@ -43,7 +44,8 @@ export default class Reporter {
screenshotPath: reportItem.screenshotPath,
screenshots: reportItem.screenshots,
quarantine: reportItem.quarantine,
skipped: reportItem.test.skip
skipped: reportItem.test.skip,
contexts: sortBy(reportItem.contexts, 'userAgent')
Copy link
Collaborator

@miherlosev miherlosev Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess sorting is not necessary.
In general case, a custom reporter plugin should decide itself will it sort contexts or not.

};
}

Expand Down Expand Up @@ -94,6 +96,7 @@ export default class Reporter {
reportItem.pendingRuns--;
reportItem.unstable = reportItem.unstable || testRun.unstable;
reportItem.errs = reportItem.errs.concat(testRun.errs);
reportItem.contexts = reportItem.contexts.concat(Object.assign({}, testRun.ctx, { userAgent: testRun.browserConnection.userAgent }));

if (!reportItem.pendingRuns) {
if (task.screenshots.hasCapturedFor(testRun.test)) {
Expand Down
149 changes: 131 additions & 18 deletions test/server/reporter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ describe('Reporter', function () {
errs: [],
quarantine: {
attempts: [['1', '2'], []]
},
ctx: {
account: 'chromeAccountTest1'
}
},

Expand All @@ -131,40 +134,57 @@ describe('Reporter', function () {
errs: [
{ text: 'err1' },
{ text: 'err2' }
]
],
ctx: {
tag: 'chrome'
}
},

//fixture1test3
{
test: testMocks[2],
unstable: false,
browserConnection: browserConnectionMocks[0],
errs: []

errs: [],
ctx: {
logs: [
{
message: 'verify password hint',
browser: 'chrome'
},
{
message: 'verify username hint',
browser: 'chrome',
}
]
}
},

//fixture2test1
{
test: testMocks[3],
unstable: false,
browserConnection: browserConnectionMocks[0],
errs: []
errs: [],
ctx: {}
},

//fixture2test2
{
test: testMocks[4],
unstable: false,
browserConnection: browserConnectionMocks[0],
errs: []
errs: [],
ctx: {}
},

//fixture3test1
{
test: testMocks[5],
unstable: false,
browserConnection: browserConnectionMocks[0],
errs: []
errs: [],
ctx: {}
}
];

Expand All @@ -178,6 +198,9 @@ describe('Reporter', function () {
errs: [],
quarantine: {
attempts: [['1', '2'], []]
},
ctx: {
account: 'firefoxAccountTest1'
}
},

Expand All @@ -187,39 +210,57 @@ describe('Reporter', function () {
unstable: false,
browserConnection: browserConnectionMocks[1],

errs: [{ text: 'err1' }]
errs: [{ text: 'err1' }],
ctx: {
tag: 'firefox'
}
},

//fixture1test3
{
test: testMocks[2],
unstable: false,
browserConnection: browserConnectionMocks[1],
errs: []
errs: [],
ctx: {
logs: [
{
message: 'verify password hint',
browser: 'firefox'
},
{
message: 'verify username hint',
browser: 'firefox',
}
]
}
},

//fixture2test1
{
test: testMocks[3],
unstable: false,
browserConnection: browserConnectionMocks[1],
errs: []
errs: [],
ctx: {}
},

//fixture2test2
{
test: testMocks[4],
unstable: false,
browserConnection: browserConnectionMocks[1],
errs: []
errs: [],
ctx: {}
},

//fixture3test1
{
test: testMocks[5],
unstable: true,
browserConnection: browserConnectionMocks[1],
errs: [{ text: 'err1' }]
errs: [{ text: 'err1' }],
ctx: {}
}
];

Expand Down Expand Up @@ -332,7 +373,17 @@ describe('Reporter', function () {
userAgent: 'chrome',
takenOnFail: false,
quarantineAttempt: 2
}]
}],
contexts: [
{
account: 'chromeAccountTest1',
userAgent: 'Chrome'
},
{
account: 'firefoxAccountTest1',
userAgent: 'Firefox',
}
]
},
{
run: 'run-001'
Expand Down Expand Up @@ -376,7 +427,17 @@ describe('Reporter', function () {
userAgent: 'chrome',
takenOnFail: true,
quarantineAttempt: null
}]
}],
contexts: [
{
tag: 'chrome',
userAgent: 'Chrome'
},
{
tag: 'firefox',
userAgent: 'Firefox'
}
]
},
{
run: 'run-001'
Expand All @@ -394,11 +455,39 @@ describe('Reporter', function () {
skipped: false,
quarantine: null,
screenshotPath: null,
screenshots: []
screenshots: [],
contexts: [
{
logs: [
{
browser: 'chrome',
message: 'verify password hint'
},
{
browser: 'chrome',
message: 'verify username hint'
}
],
userAgent: 'Chrome'
},
{
logs: [
{
browser: 'firefox',
message: 'verify password hint'
},
{
browser: 'firefox',
message: 'verify username hint'
}
],
userAgent: 'Firefox'
}
]
},
{
run: 'run-001'
}
},
]
},
{
Expand All @@ -422,7 +511,15 @@ describe('Reporter', function () {
skipped: false,
quarantine: null,
screenshotPath: null,
screenshots: []
screenshots: [],
contexts: [
{
userAgent: 'Chrome'
},
{
userAgent: 'Firefox'
}
]
},
{
run: 'run-001'
Expand All @@ -440,7 +537,15 @@ describe('Reporter', function () {
skipped: false,
quarantine: null,
screenshotPath: null,
screenshots: []
screenshots: [],
contexts: [
{
userAgent: 'Chrome'
},
{
userAgent: 'Firefox'
}
]
},
{
run: 'run-001'
Expand Down Expand Up @@ -472,7 +577,15 @@ describe('Reporter', function () {
skipped: false,
quarantine: null,
screenshotPath: null,
screenshots: []
screenshots: [],
contexts: [
{
userAgent: 'Chrome'
},
{
userAgent: 'Firefox'
}
]
},
{
run: 'run-001'
Expand Down