Skip to content

Add snapshot testing tool #78

Description

@lemonmade

Some similar ideas to vitest, probably also powered by Vite:

// MyComponent.tsx

export function MyComponent() {
  // ...
}

// in-file snapshots
if (import.meta.env.snapshot) {
  const {snapshot: defaultSnapshot} = await import('@lemonmade/react-snapshots');

  // Like my testing library
  const snapshot = defaultSnapshot.extend({
    render: (element) => <AdditionalContext>{element}</AdditionalContext>,
  });

  snapshot('default', () => <MyComponent />);
}

// ===
// MyComponent.snapshots.tsx

import {snapshot} from '@lemonmade/react-snapshots';
import {MyComponent} from './MyComponent.tsx';

snapshot('primary', () => <MyComponent primary />);
snapshot('subdued', () => <MyComponent subdued />);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions