Build Your Own Test Framework by 2023

Build Your Own Test Framework by 2023

Author:2023
Language: eng
Format: epub


CHAPTER 6

Formatting

Expectation Errors

One of the signs of a “good” test is that when it fails, it very quickly pinpoints to you why it failed so that you can get to fixing the problem quickly.

To that end, our current expectation errors are not as helpful as they

could be. In Chapter 5, you saw how matchers are used to output “pretty”

expectation failure messages. However, when a failure occurs, we’ll also get an exception stack trace printout, and it’s this that we can improve on.

In this chapter, we’ll take the stack trace and rework it into something

that’s directly useful to your test runs.

By the end of the chapter, you’ll have seen how to dig into the V8 API,

which underpins Node, to extract the constituent parts of a stack trace and format them appropriately for a terminal.

Utilizing Stack Traces with

Testing Workflows

A standard stack trace includes a list of call sites that highlight each entry in the call stack where an exception originated from. Each call site is made up of four parts:

• A function name, if the call site is within a function

• A file path, if the function was defined within a script

© Daniel Irvine 2023

101

D. Irvine, Build Your Own Test Framework, https://doi.org/10.1007/978-1-4842-9247-1_6



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.