Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

fix: useFetch in jest unit testsΒ #437

Open
@FloryanFilip

Description

@FloryanFilip

πŸ› The bug
When unit testing a component that uses useFetch composable, I'm getting weird error.
Zrzut ekranu 2021-04-2 o 22 29 09
Zrzut ekranu 2021-04-2 o 22 29 15

πŸ› οΈ To reproduce
Steps to reproduce the behavior:

  1. Create a component that uses setup function with useFetch composable inside of it
  2. Write a test suite with any unit test of said component
  3. See error

I'd be very grateful for a link to a gist or repo that reproduces the bug.

🌈 Expected behaviour
The test suite runs smoothly

ℹ️ Additional context
My component

export default defineComponent({
  setup() {

    const { fetch } = useFetch(async () => {
      //
    });

    return {
      //
    };
  },

My test suite


describe('MainSearch', () => {
  let wrapper!: Wrapper<any>;
  const factory = (data?: object) => shallowMount(MainSearchComponent, {
    stubs: {
      ...
    },
    vuetify: new Vuetify(),
  });

  beforeEach(() => {
    wrapper = factory();
  });

  afterEach(() => {
    wrapper.destroy();
  });

  it('should match snapshot', () => {
    expect(wrapper.html())
      .toMatchSnapshot();
  });

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationneeds-reproWaiting for code that can reproduce the issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions