acuminous / yadda

A BDD javascript library
412 stars 73 forks source link

support YAML (or other formats) as example table #185

Closed hans-d closed 8 years ago

hans-d commented 8 years ago

For some tests I have quite some variables. Using separate fields makes the table quite long and hard to use. Currently adding some YAML inside fields, combined with a custom converter like

  Where:
    | field1 | field2       | field3 |
    |--------|--------------|--------|
    | 1      | some:        | def    |
    |        |   nested: 1  |        |
    |        |   value: abc |        |
    |--------|--------------|--------|
    | 2      | some:        | dfg    |
    |        |   nested: 4  |        |
    |        |   value: cde |        |

would be nice if I could it write it like:

  Where:
    - field1: 1
      field2:
        some: { nested: 1, value: abc }
     field3: def
   - field1: 2
     field2:
       some: { nested: 4, value: cde }
     field3: dfg

Currently cannot yet locate how/where to provide an alternate parsing.

cressie176 commented 8 years ago

Here's the standard parser. You can replace it with a custom one in options to the mocha plugin or if running yadda by some other means, instantiate it by hand, e.g. https://github.com/acuminous/yadda/blob/f95f70c24237665228e523bbd5adb4944d887a32/lib/plugins/mocha/BasePlugin.js#L30

cressie176 commented 8 years ago

How did you get on?

An alternative to writing a new parser would be to reference YAML files from the example table and parse them in the step (or using a dictionary converter).

cressie176 commented 8 years ago

Closing due to lack of response