Vue Test Utils 2 - MountingOptions<> 的正确输入/设置是什么?

问题描述

我看到 MountingOptions 采用 PropsData 作为泛型类型。我不确定这些类型来自哪里。我当前的设置如下,我目前使用“任何”。我想避免使用“任何”并使用定义的道具和数据。

我在哪里可以让道具和数据类型传递到 MountingOptions?

/* eslint-disable @typescript-eslint/no-explicit-any */ //--> Would like to avoid this

import { shallowMount,MountingOptions } from '@vue/test-utils';
import mergeWith from 'lodash.mergewith';
import SomeComponent from '@/components/SomeComponent.vue';

const factory = (overrides: MountingOptions<any>) => { // Replace "any" with?
  const defaults: MountingOptions<any> = {}; // Replace "any" with?
  return shallowMount(SomeComponent,mergeWith(defaults,overrides));
};

describe('SomeComponent.vue',() => {
  it.todo('create requirements');
});

编辑:

看来我只想创建自己的界面,该界面与我的道具和/或数据的形状相同。因此,在测试文件中:

interface Props {
   someProp: string;
}

然后

MountingOptions<Props>

正确吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)