Javascript Jest测试给出错误:“错误”;无法读取未定义的属性

Javascript Jest测试给出错误:“错误”;无法读取未定义的属性,javascript,vue.js,unit-testing,jestjs,Javascript,Vue.js,Unit Testing,Jestjs,我正在编写一个简单的jest测试,但收到以下错误: [Vue warn]: Error in render: "TypeError: Cannot read property 'fields' of undefined" [Vue warn]: Error in created hook: "TypeError: Cannot read property 'relationNumber' of undefined" 我的玩笑测试: import { m

我正在编写一个简单的jest测试,但收到以下错误:

[Vue warn]: Error in render: "TypeError: Cannot read property 'fields' of undefined"

[Vue warn]: Error in created hook: "TypeError: Cannot read property 'relationNumber' of undefined"
我的玩笑测试:

import { mount } from "@vue/test-utils";
import Step2 from "pathtoStep2.vue";

describe("Step2", () => {
  it("should enable button", async () => {
    const wrapper = mount(Step2);
    await wrapper
      .find("[data-testid='relationnumber-input']")
      .setValue("12341234123412");
    const button = wrapper.find("[data-testid='next-button']");
    expect(button.toBeEnabled());
  });
});
step2.vue中的我的字段数据对象:

  data () {
    return {
      fields: {
        relationNumber: '',
      }
    }
  }
据 不需要初始化数据对象吗?那么我做错了什么