How to use the @testing-library/svelte.render function in @testing-library/svelte

To help you get started, we’ve selected a few @testing-library/svelte examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shipshapecode / shepherd / test / unit / components / shepherd-element.spec.js View on Github external
it('exitOnEsc: true - ESC cancels the tour', async() => {
      const tour = new Tour();
      const step = new Step(tour, {});
      const stepCancelSpy = spy(step, 'cancel');

      const { container } = render(ShepherdElement, {
        props: {
          step
        }
      });
      fireEvent.keyDown(container.querySelector('.shepherd-element'), { keyCode: 27 });
      expect(stepCancelSpy.called).toBe(true);
    });
github mdauner / sveltejs-forms / tests / utils.js View on Github external
async function renderAndWait(component, options) {
  const renderedComponent = render(component, options);
  await wait();
  return renderedComponent;
}
github shipshapecode / shepherd / test / unit / components / shepherd-button.spec.js View on Github external
it('is enabled when false', () => {
      const config = {
        disabled: false
      };

      const { container } = render(ShepherdButton, {
        props: {
          config
        }
      });

      const button = container.querySelector('.shepherd-button');
      expect(button.disabled).toBeFalsy();
    });
github YogliB / svelte-component-template / tests / MyAwesomeComponent.spec.js View on Github external
it('Should render greeting', () => {
		const { container } = render(MyAwesomeComponent, {
			props: { name: 'world' },
		});

		expect(container.querySelector('h1')).toHaveTextContent('Hello world!');
	});
});
github shipshapecode / shepherd / test / unit / components / shepherd-footer.spec.js View on Github external
it('renders buttons for each item passed to `options.buttons`', () => {
    const step = {
      options: {
        buttons: [
          defaultButtons.cancel,
          defaultButtons.next
        ]
      }
    };

    const { container } = render(ShepherdFooter, {
      props: {
        step
      }
    });

    const buttons = container.querySelectorAll('.shepherd-footer .shepherd-button');
    expect(buttons.length).toBe(2);

    const cancelButton = container.querySelector('footer .cancel-button');
    expect(cancelButton).toHaveAttribute('tabindex', '0');
    expect(cancelButton).toHaveClass('shepherd-button-secondary cancel-button shepherd-button');
    expect(cancelButton).toHaveTextContent('Exit');

    const nextButton = container.querySelector('footer .next-button');
    expect(nextButton).toHaveAttribute('tabindex', '0');
    expect(nextButton).toHaveClass('shepherd-button-primary next-button shepherd-button');
github appist / appy / internal / templates / scaffold / web / src / components / App.svelte.spec.ts View on Github external
test("renders nothing", () => {
  const getById = queryByAttribute.bind(null, "id");
  const dom = render(App);

  expect(getById(dom.container, "app")).toBeNull();
});
github appist / appy / internal / templates / scaffold / web / src / pages / NotFound.svelte.spec.ts View on Github external
test("renders the not found message", () => {
  const { getByText } = render(NotFound);

  expect(getByText("Oops! The page you are looking for doesn't exist.")).toBeTruthy();
});
github appist / appy / internal / templates / scaffold / web / src / pages / Home.svelte.spec.ts View on Github external
test("renders the welcome message", () => {
  const { getByText } = render(Home);

  expect(getByText("An opinionated productive web framework that helps scaling business easier.")).toBeTruthy();
});
github pankod / svelte-boilerplate / src / Components / FetchExample / index.spec.js View on Github external
it('fetches links asynchronously', (next) => {
        const { container } = render(FetchExample)

        setTimeout(() => {
            expect(container.getElementsByTagName('li').length).toBe(2)
            expect(container).toMatchSnapshot()
            next()
        }, 10)
    });
});
github pankod / svelte-boilerplate / src / App / index.spec.js View on Github external
it('should render the app', () => {
        const { container, getAllByText } = render(App)

        expect(container.getElementsByClassName('layout').length).toBe(1)
        expect(container.getElementsByClassName('image-content').length).toBe(1)
        expect(container.getElementsByClassName('bg-image').length).toBe(1)
        expect(container.getElementsByClassName('title').length).toBe(1)
        expect(container.getElementsByClassName('title__top').length).toBe(1)
        expect(container.getElementsByClassName('title__back').length).toBe(1)
        expect(container.getElementsByClassName('title__front').length).toBe(1)

        expect(getAllByText('Hello').length).toBe(1)
        expect(getAllByText('World').length).toBe(2)

        expect(container).toMatchSnapshot()
    })
})