codesandbox / sandpack

A component toolkit for creating live-running code editing experiences, using the power of CodeSandbox.
https://sandpack.codesandbox.io
Apache License 2.0
4.7k stars 330 forks source link

Custom Jest asymmetric matchers break in SandpackTests #1137

Open EskiMojo14 opened 4 months ago

EskiMojo14 commented 4 months ago

Bug report

Packages affected

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
EskiMojo14 commented 4 months ago

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 ❤️