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

feat: add support for jasmine-spec-reporter (displayStacktrace: true) #70

Merged
merged 4 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
"cookie-parser": "^1.3.5",
"express": "^4.13.1",
"express-session": "^1.11.3",
"jasmine-spec-reporter": "^4.2.1",
Copy link
Owner

Choose a reason for hiding this comment

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

Is this dependency actually needed? I'm fine with omitting it since we have generated the static test output

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not now that the conf using it is gone

"mocha": "^2.2.5",
"morgan": "^1.6.1",
"mversion": "^1.10.0",
"protractor": "^4.0.11",
"protractor": "^5.1.2",
"proxyquire": "^1.6.0",
"semantic-release": "^6.3.6",
"sinon": "^1.15.4",
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
parse (output) {
let failedSpecs = new Set()
let match = null
let FAILED_LINES = /at (?:\[object Object\]|Object)\.(?:<anonymous>|it) \((([A-Za-z]:\\)?.*?):.*\)/g
let FAILED_LINES = /at (?:\[object Object\]|Object|UserContext)\.(?:<anonymous>|it) \((([A-Za-z]:\\)?.*?):.*\)/g
while (match = FAILED_LINES.exec(output)) { // eslint-disable-line no-cond-assign
// windows output includes stack traces from
// webdriver so we filter those out here
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';
Copy link
Owner

Choose a reason for hiding this comment

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

I'd remove this file unless we need it since (we don't have an integration test that actually uses it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool... wasn't sure if you wanted a repeatable conf for the future [WOOSH SOUND]. The answer is no :) It's gone.


var JOB_NUMBER = (process.env.TRAVIS_JOB_NUMBER || '')
var JOB_NAME = 'Flake' + JOB_NUMBER

exports.config = {
specs: [
'../flakey-test.js',
'../passing-test.js'
],

capabilities: {
browserName: 'chrome',
name: JOB_NAME,
shardTestFiles: false,
maxInstances: 2,
'tunnel-identifier': JOB_NUMBER
},

sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,

baseUrl: 'http://localhost:3000/',

framework: 'jasmine2',

allScriptsTimeout: 10000,

getPageTimeout: 3000,

jasmineNodeOpts: {
defaultTimeoutInterval: 5000,
print: function() {} // remove dot reporter
},

onPrepare: function () {
// let protractor know it doesn't need to look for angular on the page
browser.ignoreSynchronization = true;

// make reports mo' pretty
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
jasmine.getEnv().addReporter(
new SpecReporter({
spec: {
displayStacktrace: true
}
})
);
}
};

10 changes: 10 additions & 0 deletions test/unit/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import parseOptions from '../../src/parse-options'

const failedSingleTestOutput = readFixture('failed-test-output.txt')
const failedShardedTestOutput = readFixture('sharded-failed-test-output.txt')
const failedJasmineSpecReporterTestOutput = readFixture('failed-jasmine-spec-reporter-test-output.txt')

describe('Protractor Flake', () => {
let spawnStub = null
Expand Down Expand Up @@ -93,6 +94,15 @@ describe('Protractor Flake', () => {
expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.retry', true, '--specs', '/tests/a-flakey.test.js'])
})

it('isolates individual failed specs from jasmine-spec-reporter output', () => {
protractorFlake({maxAttempts: 3})

spawnStub.dataCallback(failedJasmineSpecReporterTestOutput)
spawnStub.endCallback(1)

expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.retry', true, '--specs', '/tests/flakey.test.js'])
})

it('isolates failed specs for sharded protractor output', () => {
protractorFlake({maxAttempts: 3})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[08:04:24] I/launcher - Running 1 instances of WebDriver
[08:04:24] I/direct - Using ChromeDriver directly...
Jasmine started

a flakey integration test
✗ fails, in a horribly consistent manner
- Expected false to be truthy.
at UserContext.<anonymous> (/tests/flakey.test.js:7:39)
at node_modules/jasminewd2/index.js:112:25
at new ManagedPromise (node_modules/selenium-webdriver/lib/promise.js:1067:7)
at ControlFlow.promise (node_modules/selenium-webdriver/lib/promise.js:2396:12)
at schedulerExecute (node_modules/jasminewd2/index.js:95:18)
at TaskQueue.execute_ (node_modules/selenium-webdriver/lib/promise.js:2970:14)
at TaskQueue.executeNext_ (node_modules/selenium-webdriver/lib/promise.js:2953:27)
at asyncRun (node_modules/selenium-webdriver/lib/promise.js:2813:27)
at node_modules/selenium-webdriver/lib/promise.js:676:7

A test that passes
✓ passes

**************************************************
* Failures *
**************************************************

1) a flakey integration test fails, in a horribly consistent manner
- Expected false to be truthy.

Executed 2 of 2 specs (1 FAILED) in 0.742 sec.
[08:04:26] I/launcher - 0 instance(s) of WebDriver still running
[08:04:26] I/launcher - chrome #01 failed 1 test(s)
[08:04:26] I/launcher - overall: 1 failed spec(s)
[08:04:26] E/launcher - Process exited with error code 1