Skip to content

An utility for using lazy variables in a BDD test environment with nested `describe`s, and `it`s.

License

Notifications You must be signed in to change notification settings

vhoyer/lazy-let

Repository files navigation

@vhoyer/lazy-let

GitHub Workflow Status bundle size npm

An utility for using lazy variables in a BDD test environment with nested describes, and its.

Installation

npm install --save-dev @vhoyer/lazy-let

Usage

import { describe, it, expect, afterEach } from 'vitest';
import { lazylet } from '@vhoyer/lazy-let';
import { render } from '@testing-library/vue';
import MyFooter from '../my-footer.vue';

describe('dummy test', () => {
  const $0 = lazylet(afterEach, {
    value: () => 1,
    wrapper: () => render(MyFooter, {
      props: $0.props, // defaults to undefined
    }),
  });

  it('renders', () => {
    expect($0.wrapper.container).toMatchSnapshot();
  });

  describe('change props', () => {
    const $1 = $0(beforeEach, {
      props: () => ({ prop: $1.value }),
      propsAlternative: ($) => ({ prop: $.value }),
    });

    it('renders different', () => {
      expect($1.wrapper.container).toMatchSnapshot();
    });
  });
});

About

An utility for using lazy variables in a BDD test environment with nested `describe`s, and `it`s.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published