question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testing console output

See original GitHub issue

Hello,

we’re in the process of migrating lint-staged to Listr2, but I have some question regarding test output assertion.

The orginal Listr’s verbose renderer printed [started] and [completed] strings, while Listr2 uses fancy symbols like and . These symbols are different on each platform, though, so testing in a CI environment is a bit difficult.

You can see the progress in the PR https://github.com/okonet/lint-staged/pull/852 and how the assertions fail on our Windows tests: https://ci.appveyor.com/project/okonet/lint-staged/builds/32413566/job/qyae7t039cckykre

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
iirojcommented, Apr 24, 2020

Thanks, seems to be just what we need! I’ll also use the test renderer when TERM=dumb just in case those don’t support the fancy glyphs.

1reaction
cenk1cenk2commented, Apr 24, 2020

image Something in the ballpark of this hopefully does it. I will also add tests here when I have free time but been lazy lately.

To call the test renderer set the renderer to test.

  const tasks = new Listr<ListrCtx>([
    {
      // You can nest Listr objects, as in the original but now you can also call a new listr class throught task.newListr and inject a type as well
      title: 'Concurrent sub test.',
      task: (ctx, task): Listr => task.newListr<ListrCtx>([
        ...someTasks
  ], {
    renderer:'test'
  })

I will merge after I perform usual manual tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit Testing Console Output Made Easy - DZone
Capturing the console output and using that to assert isn't that hard in plain java. It is actually very easy but verbose. Most...
Read more >
How To Test Console Log - DEV Community ‍ ‍
In Jest, we have two ways to verify that console.log was called as we expect it to be. First, we can mock the...
Read more >
How to test console output (console.log, console.warn) with ...
How to test console output (console.log, console.warn) with RTL (React-Testing-Library) and Jest · const originalWarn = console.warnafterEach(() => (console.
Read more >
How to Write to Console in Unit Test in Visual Studio 2022
The easiest way to write output from the test is to use the Console.WriteLine method. [TestMethod] public void test_that_writes_to_console2() { Console.
Read more >
Console output unit testing in the Kotlin application
Are you looking for a way to test your console output (println()) in your Kotlin project? In this post, I'm going to walk...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found