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

Global config options does not support partial config #189

Closed
AtofStryker opened this issue Aug 25, 2020 · 1 comment · Fixed by #195
Closed

Global config options does not support partial config #189

AtofStryker opened this issue Aug 25, 2020 · 1 comment · Fixed by #195

Comments

@AtofStryker
Copy link

While tackling vuejs/vue-test-utils#1503, I ran into some issues while adding a global.config option to my component. The below error occured when running the following code:

TypeError: Cannot assign to read only property 'isNativeTag' of object '#<Object>'

// @ts-ignore
import TestComponent from "./TestComponent.vue";
import { shallowMount } from "@vue/test-utils";
import { createApp } from "vue";

describe("Test Error Handler Vue 3", () => {
  it("Mounts a global errorhandler without issue", async (done) => {
    const app = createApp({});
    app.config.errorHandler = (err: any, vm, info) => {
      if (info.includes("beforeMount")) {
        expect(err.message).toBe("test");
      }
      done();
    };

    shallowMount(TestComponent, {
      global: {
        /// the below causes the exception `Cannot assign to read only property 'isNativeTag' of object '#<Object>'`
        config: app.config,
        // the below also has problems. It looks the the type is Pick<> with almost all the values of the config. Should this be a Partial type?
        // config: {
        //   errorHandler: app.config.errorHandler
        // }
      },
    });
  });
});

I put a reproduction link here. This is my first time using Vue 3 and VTU 2.x so it is likely I am doing something incorrect and have no idea what I am doing 😆. Hopefully I am using this API correctly while vuejs/test-utils-docs#49 is completed.

@cexbrayat
Copy link
Member

@AtofStryker Thank you for this detailed repro! You're right, it should accept a partial config without complaining. I think I fixed it in #195 , you should be able to give it a try when we emrge and release this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants