Unit testing Vue.js单元测试测试组件,出现道具类型错误

Unit testing Vue.js单元测试测试组件,出现道具类型错误,unit-testing,vue.js,Unit Testing,Vue.js,我正在尝试测试音频播放器的启动、暂停、停止、静音、定位、下载事件 export default { name: "audioPlayer", props: { file: { type: Object, default: null }, autoPlay: { type: Boolean, default: false }, 在我的测试规范中,我将文件道具设置为 const file = new Fil

我正在尝试测试音频播放器的启动、暂停、停止、静音、定位、下载事件

export default {
  name: "audioPlayer",
  props: {
    file: {
      type: Object,
      default: null
    },
    autoPlay: {
      type: Boolean,
      default: false
    },
在我的测试规范中,我将文件道具设置为

  const file = new File(["../../src/assets/audio/ultimo_desejo.mp3"], "ultimo_desejo", { type: "audio/mp3"});
  const ended = jest.fn();
但是当我运行测试时,我得到一个错误:

console.error节点_modules/vue/dist/vue.runtime.common.js:589 [Vue warn]:无效的属性:属性文件的类型检查失败。预期对象,已获取文件

found in

---> <AudioPlayer>
       <Root>
如何设置文件属性

感谢您的反馈

将文件道具的类型字段更改为文件:

然后,您可以在文件道具中传递一个新文件:

它'需要一个文件道具',=>{ const file=新文件['foo'],'foo.txt'; const wrapper=shallwmountmyfoo{ propsData:{file} }; expectwrapper.vm.file.toBeTruthy; }
谢谢但我正在与url抗争。。。我应该在哪里存储foo文件?如果我将其存储在src/assets/audio/foo.mp3中。。。哪个网址?
props: {
  file: {
    type: File,
    default: null
  },
}