codesandbox/sandpack

Custom Jest asymmetric matchers break in SandpackTests

Opened this issue · 1 comments

Bug report

Packages affected

  • sandpack-client
  • sandpack-react

Description of the problem

Custom asymmetric matchers break in Sandpack, because they're not being called with the required matcher context.

This does not affect native Jest asymmetric matchers, or custom symmetric matchers.

I've also tried this in the latest Jest version (on my local machine) and don't experience the issue, which is why I'm raising it here and not in the Jest repo.

What were you doing when the problem occurred?

Creating documentation for my package, https://eskimojo14.github.io/mix-n-matchers/.

What steps can we take to reproduce the problem?

Write a test that utilises a custom asymmetric matcher. This issue is visible both in the Mix 'n' Matchers documentation as well as the jest-extended playground.

You can also replicate it with a short example:

expect.extend({
  example() {
    this.isNot; // this should be fine, but throws
    return { pass: true, message: () => "" }
  }
})

it("throws when matcher is used", () => {
  expect("").toEqual(expect.example())
})

Your Environment

Software Name/Version
Sandpack-client version 2.13.8
Sandpack-react version 2.13.10
Browser Chrome
Operating System Windows, MacOS

on a more positive note, the fact that this project exists at all is very cool, and a major reason why I wanted a docusaurus site for my package vs a standard README ❤️