cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.06k stars 1.09k forks source link

Feature: Allow non-formatted data table in final log #1664

Open plocket opened 3 years ago

plocket commented 3 years ago

Our data table has some very long strings in it. The final log tries to make all the columns line up. That combination makes the whole table quite a lot longer than it needs to be. We'd prefer that the log not attempt to make the table columns all the same width.

aslakhellesoy commented 3 years ago

I think I understand the problem. I have an idea for a different feature that I think would address your problem, and also preserve readability.

We trim the values of long cells. The cell width can be computed by querying the terminal's width. Alternatively you could supply one with CUCUMBER_MAX_CELL_WIDTH=number

Would that work for you?

plocket commented 3 years ago

Those options sound good in some cases, but in our cases I suspect we'd sometimes want to see the full contents of each cell. We just wouldn't want every cell to need to have the same width.

plocket commented 3 years ago

My second post apparently did not post:

On second thought, maybe I'm making assumptions. The option you suggested would require a couple extra steps when trying to troubleshoot a problem (scroll through to find which file and test was run and then look up the test itself in its file), but maybe it wouldn't be that big of a burden. Or maybe it would. It probably just needs some user testing.

I do think there would need to be some indicator in a cell when its input did get truncated.

aslakhellesoy commented 3 years ago

How about this then:

Would you be interested in submitting a pull request for this @plocket?

plocket commented 3 years ago

Both sound good. Great CSS inspiration. No need for a custom cell size unless someone asks for it - I'm sure that can be hard-coded at first. Do they have to be env vars or can they get passed in as options? Would allow more flexibility with the names.

CUCUMBER_TEXT_OVERFLOW alternative names depending on type of var: CUCUMBER_TABLE_OVERFLOW, TABLE_OVERFLOW, table_overflow

CUCUMBER_TABLE_UNFORMATTED alternative names depending on type of var: CUCUMBER_UNFORMATTED_TABLE, unformatted_table, remove_table_formatting, cell_fit_content, table_fit_content, equal_table_cell_width (which would be the opposite).

As for me coding it up, I think it may be over my head. I'm not very experienced and I don't have a ton of bandwidth. If you don't mind my asking a ton of questions to take some of that load off, that would be more doable, but then it probably wouldn't help the team that much.

Looking at cli-table3, a reasonable mvp might be to allow the dev to set the column width directly.

aslakhellesoy commented 3 years ago

Happy to answer any questions if you or anyone else want to take a stab at it.

davidjgoss commented 3 years ago

To be clear when we talk about the "final log" do we mean the summary (default) formatter?

If so we could lean on the --format-options mechanism rather than introducing new flags or env variables. Other formatters could then also use (or ignore) these cues for formatting.