-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from smartprocure/feature/browser-result-parser
Feature/browser result parser
- Loading branch information
Showing
10 changed files
with
538 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,12 @@ | |
"bin": { | ||
"duti": "bin/duti" | ||
}, | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"main": "src/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://[email protected]/smartprocure/duti.git" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=8.0.0" | ||
|
@@ -30,6 +34,11 @@ | |
"sourceType": "module" | ||
} | ||
}, | ||
"prettier": { | ||
"singleQuote": true, | ||
"semi": false, | ||
"trailingComma": "es5" | ||
}, | ||
"dependencies": { | ||
"bluebird": "^3.5.0", | ||
"cosmiconfig": "^2.2.2", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
let _ = require('lodash/fp') | ||
|
||
let hasBrowserErrors = ({ browserResults, fail, message }) => { | ||
if (_.isNil(browserResults)) { | ||
message('Could not find any browser results.') | ||
return | ||
} | ||
|
||
let { result, summary } = browserResults | ||
|
||
if (result && summary) { | ||
let { error, failed, exitCode } = summary | ||
if (error === false && failed === 0 && exitCode === 0) { | ||
message('Your PR has no browser errors. Great job!') | ||
return | ||
} | ||
|
||
if (failed > 0) { | ||
_.flow( | ||
// Flatten test results into one array. | ||
_.values, | ||
_.flatten, | ||
// Filter by failed tests. | ||
_.reject({ success: true }), | ||
// Format error log. | ||
_.map( | ||
f => `\nSuite: ${f.suite}\nDescription: ${f.description}\n${f.log}\n` | ||
), | ||
_.concat([`Your PR has ${failed} failed browser tests:`]), | ||
_.join('\n'), | ||
fail | ||
)(result) | ||
return | ||
} | ||
|
||
// All other cases: error is not false, exitCode is not 0 etc. | ||
fail('Browser test error. Please see CI logs for more details.') | ||
} else { | ||
message( | ||
'Incorrect browser result format. Please see CI logs for more details.' | ||
) | ||
} | ||
} | ||
|
||
module.exports = { | ||
hasBrowserErrors: hasBrowserErrors, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-env jest */ | ||
|
||
let browser = require('./browserResults') | ||
let browserHelpers = require('../test-data/browser-results') | ||
|
||
describe('browser results', () => { | ||
it('fails if they have errors', () => { | ||
let fail = jest.fn() | ||
let message = jest.fn() | ||
let browserResults = browserHelpers.failing | ||
browser.hasBrowserErrors({ browserResults, fail, message }) | ||
|
||
expect(fail).toHaveBeenCalled() | ||
expect(message).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('doesnt fail if it is passing', () => { | ||
let fail = jest.fn() | ||
let message = jest.fn() | ||
let browserResults = browserHelpers.passing | ||
browser.hasBrowserErrors({ browserResults, fail, message }) | ||
|
||
expect(message).toHaveBeenCalled() | ||
expect(fail).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('doesnt fail but message should be called if data is incorrect', () => { | ||
let fail = jest.fn() | ||
let message = jest.fn() | ||
let browserResults = {} | ||
browser.hasBrowserErrors({ browserResults, fail, message }) | ||
|
||
expect(message).toHaveBeenCalled() | ||
expect(fail).not.toHaveBeenCalled() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.