-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Open
Description
Describe the bug
When trying to use toMatchSnapshot matcher in the interaction tests it would throw the following error:
Invalid Chai property: toMatchSnapshot
Reproduction link
https://stackblitz.com/edit/github-hx2exbv1?file=src%2FTest.stories.tsx
Reproduction steps
- Have a story
- Write an interaction test and use
expect(string).toMatchSnapshot(key)
System
System:
OS: macOS 15.7.1
CPU: (11) arm64 Apple M3 Pro
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.20.0 - /Users/hamid/.nvm/versions/node/v22.20.0/bin/node
npm: 10.9.3 - /Users/hamid/.nvm/versions/node/v22.20.0/bin/npm <----- active
Browsers:
Safari: 18.6
npmPackages:
@storybook/addon-a11y: ^10.0.8 => 10.0.8
@storybook/addon-docs: ^10.0.8 => 10.0.8
@storybook/addon-vitest: ^10.0.8 => 10.0.8
@storybook/addon-webpack5-compiler-swc: ^4.0.2 => 4.0.2
@storybook/react-vite: ^10.0.8 => 10.0.8
@storybook/react-webpack5: ^10.0.8 => 10.0.8
@storybook/test-runner: ^0.24.1 => 0.24.1
chromatic: ^12.2.0 => 12.2.0
eslint-plugin-storybook: ^10.0.8 => 10.0.8
storybook: ^10.0.8 => 10.0.8Additional context
from the docs I can see that the exported expect from storybook/test when using Vitest addon is derived from Vitest and it's extending the @testing-library/jest-dom matchers, but I'm not sure why this matcher doesn't exist.
KIM that using composible tests works, and not importing expect (with the test.globals option in Vite enabled) or importing it from vitest will fix the issue, but obviously we can't do that since it's recommended to use exported expect from storybook/test
dosubot