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

stdout trim issue in tests #1385

Closed
Bartheleway opened this issue Apr 9, 2024 · 3 comments
Closed

stdout trim issue in tests #1385

Bartheleway opened this issue Apr 9, 2024 · 3 comments

Comments

@Bartheleway
Copy link
Contributor

Bartheleway commented Apr 9, 2024

Hi,

I'm trying to write a plugin for inquirer and while writing tests I found a weird issue.

All my tests are running fine on Github actions but fails when running on my computer (Windows).

It seems that long lines are truncated to 80 caracters and if ends with a space are truncated in Github actions but not in Windows Powershell.

New test in input.test.mts

it('handle long question', async () => {
  const { answer, events, getScreen } = await render(input, {
    message: 'This is a very_very_very_very_very_very_very_very_very_very_very_very_very long question',
  });

  expect(getScreen()).toMatchInlineSnapshot([
    '"? This is a very_very_very_very_very_very_very_very_very_very_very_very_very',
    'long question"'
  ].join('\n'));
});

How should I workaround that?

Best regards,
Barthélemy

@Bartheleway Bartheleway changed the title stdout width issue in tests stdout trim issue in tests Apr 9, 2024
@SBoudrias
Copy link
Owner

SBoudrias commented Apr 9, 2024

Ohhh interesting. My educated guess is that cli-width returns a different value between windows/linux in this context. I don't have a windows machine, so I would really appreciate it if you could test it out and report what you find!

@SBoudrias
Copy link
Owner

I'm not sure how we could automatically make this consistent from @inquirer/testing. Mocks are unlikely to work since they're now test framework agnostic, and CLI_WIDTH env variable would need to be set from outside.

At the very least, will add a note to the documentation.

@Bartheleway
Copy link
Contributor Author

Bartheleway commented Apr 9, 2024

I changed the issue after realising it was just a trim issue more than a width issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants