Skip to content

context.root.$store is undefined in tests with the Composition API #1655

Closed
@saifahn

Description

@saifahn

Version

1.0.4

Reproduction link

https://github.com/saifahn/composition-api-context-store-undefined-vtu

Steps to reproduce

  1. Run the test suite via npm run test:unit

You will see the error.

What is expected?

  • Ideally vue-test-utils be able to handle this and provide the store to the context of the Composition API components.
  • context.root.$store should return the store provided in the tests rather than undefined.

What is actually happening?

  • context.root.$store returns undefined, so tests involving components that use context.root.$store will fail.
  • The component itself is functional, so it looks like a problem with vtu, unless I am mistaken.

I have seen people with similar problems using context.root.$router as well.
Here's one:

https://forum.vuejs.org/t/vue-composition-api-vue-router-unit-test/88702

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions