User supplied parsers #45

Closed
wants to merge 4 commits into
from

Projects

None yet

2 participants

@NickTomlin
Owner

This adds the ability for users to supply a custom parser by:

  • providing the path to a module that will be required, the path must end in a .* extension
  • providing a custom parsing object (when used programmatically)

This should help in cases where a custom reporter is being used; it allows users to design a parser that fits their needs without having to update protractor-flake itself.

Eventually it would be nice to provide some tools to make parsing output easier but this is a first step.

added some commits Dec 9, 2016
@NickTomlin fix: Move option parsing into a separate module 2052ed9
@NickTomlin feat: Add ability to pass custom parser path/function
adb6a78
@NickTomlin
Owner

@wswebcreation I'd love to hear any thoughts you have on this

@wswebcreation
Collaborator

Sorry for my late reaction

Will check it tomorrow

src/parsers/index.js
+ return parserObject
+}
+
+function handlePah (parserPath) {
@wswebcreation
wswebcreation Dec 17, 2016 Collaborator

Typo? handlePath

@NickTomlin
NickTomlin Dec 17, 2016 Owner

Yep! Great catch!

+Parsers should be defined as an object with a `parse` method (and optionally a `name` property):
+
+```
+module.exports = {
@wswebcreation
wswebcreation Dec 17, 2016 Collaborator

Use this as an example from your last merge to get more consistency?

module.exports = {
  parse (protractorTestOutput) {
    let failedSpecs = new Set()
    // ... analyze protractor test output
    // ... and add to specFiles

    // specFiles to be re-run by protractor-flake
    // if an empty array is returned, all specs will be re-run
    return [...failedSpecs]
  }
}
@NickTomlin
NickTomlin Dec 17, 2016 Owner

I think that makes a lot of sense ๐Ÿ‘

@wswebcreation
Collaborator

Hi @NickTomlin,

PR looks nice, 2 small comments. Can be merged afterwards.

Grtz

Wim

added some commits Dec 17, 2016
@NickTomlin chore: Update custom parser example to use set 2d9271c
@NickTomlin fix: Correct typo in parsers
b23bdc5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment