Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate Component is not a constructor #1

Open
IgnusG opened this issue Sep 16, 2020 · 0 comments
Open

Investigate Component is not a constructor #1

IgnusG opened this issue Sep 16, 2020 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@IgnusG
Copy link
Owner

IgnusG commented Sep 16, 2020

Loading external components works fine with the currently documented approach but mocking your own components results in this error. The code to solve this looks like this:

jest.mock('src/components/button/button.svelte', () => {
  const html = require('svelte-htm');
  const component = html`<div>Button Mock</div>`;

  return require('svelte-jester-mock').mockComponent(component).default;
});

import type { MockedComponent } from 'svelte-jester-mock';
import Button from 'src/components/button/button.svelte';

beforeEach(() => (Button as unknown as MockedComponent).mockClear());

Why are custom components different from external components? Is it always like that or is it just some external libraries?

The matchers are smart enough to guess which variant (wrapped or not) it is

@IgnusG IgnusG added bug Something isn't working help wanted Extra attention is needed labels Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant