-
-
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.
- Loading branch information
Pax
committed
Mar 3, 2020
1 parent
c77a006
commit 6e689f7
Showing
2 changed files
with
54 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
/** | ||
* START `Implement cleaner stack traces` | ||
* See https://github.com/cypress-io/cypress/issues/881#issuecomment-485235225 | ||
*/ | ||
const stacktraces = [] | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
before(() => { | ||
stacktraces.length = 0 | ||
}) | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') | ||
Cypress.Commands.each(({ name }) => { | ||
const fn = cy[name] | ||
cy[name] = (...args) => { | ||
const ret = fn.call(cy, ...args) | ||
stacktraces.push({ | ||
stack: new Error().stack, | ||
chainerId: ret.chainerId | ||
}) | ||
return ret | ||
} | ||
}) | ||
|
||
Cypress.on('fail', (err, runnable) => { | ||
const commands = runnable.commands | ||
const cmdIdx = Cypress._.findLastIndex(commands, (cmd) => { | ||
return (cmd.state === 'pending' || cmd.state === 'failed') && cmd.chainerId | ||
}) | ||
const cmd = commands && commands[cmdIdx] | ||
if (cmd) { | ||
const data = Cypress._.find(stacktraces, { chainerId: cmd.chainerId }) | ||
if (data && data.stack) { | ||
console.log(data.stack, data.chainerId) | ||
} | ||
} | ||
throw err | ||
}) | ||
/** END of `Implement cleaner stack traces` */ |