Skip to content

Fix undefined this in toMatchInterpolatedText, clearer error message

What does this MR do and why?

  • Fixes TypeError: Cannot read property 'utils' of undefined error on assertion failure
  • Improves error message to clearly indicate the expected and received values

Screenshots or screen recordings

Before
TypeError: Cannot read property 'utils' of undefined

      23 |         `
      24 |       \n\n
    > 25 |       Expected: ${this.utils.printExpected(clearReceived)}
         |                        ^
      26 |       To equal: ${this.utils.printReceived(clearMatch)}
      27 |       `;
      28 |
After
Expected to be: <expected string>
Received: <actual string>
Expected to not be: <expected string>
Received: <actual string>

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Find an assertion that uses toMatchInterpolatedText
  2. Change the expected value
  3. Run the test

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #351382 (closed)

Edited by Vamsi Vempati

Merge request reports