-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Describe the bug
After update to Vitest 0.25.1 inline snapshot don't get written in the source code as usual, so that expect(container).toMatchInlineSnapshot(); stay always empty. At the same time, in case the under the hood generated snapshot has changed, Vitest will output an error in the console with both expected and received content.
Reproduction
Install Vitest 0.25.1 and try to generate an inline snapshot for this component:
// component spinner.tsx
export function Spinner() {
return (
<svg
className="currentColor -ml-1 mr-3 h-5 w-5 animate-spin"
fill="none"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<title>Loading spinner</title>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
></circle>
<path
className="opacity-75"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
fill="currentColor"
></path>
</svg>
);
}
// test spinner.test.tsx
import { render } from "@testing-library/react";
import { Spinner } from "./spinner";
describe("<Spinner />", () => {
it("should match snapshot", () => {
const { container } = render(<Spinner />);
expect(container).toMatchInlineSnapshot();
});
});vitest.config.ts:
export default defineConfig({
plugins: [react(), tsconfigPaths()],
test: {
globals: true,
environment: "jsdom",
setupFiles: ["./test/setup-test-env.ts"],
include: ["./app/**/*.{test,spec}.{js,ts,jsx,tsx}"],
watchExclude: [".*\\/node_modules\\/.*", ".*\\/build\\/.*"],
clearMocks: true,
mockReset: true,
restoreMocks: true,
},
});System Info
System:
OS: macOS 13.0.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 5.52 GB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
Yarn: 3.2.1 - ~/.nvm/versions/node/v16.14.2/bin/yarn
npm: 8.13.2 - ~/.nvm/versions/node/v16.14.2/bin/npm
Browsers:
Brave Browser: 105.1.43.93
Chrome: 107.0.5304.110
Firefox: 105.0.3
Safari: 16.1
npmPackages:
@vitejs/plugin-react: ^2.2.0 => 2.2.0
vitest: ^0.25.1 => 0.25.1Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels