简体   繁体   English

使用 jest 和 discord.js 的分段错误

[英]segmentation fault using jest and discord.js

I'm using jest nodejs (nestjs) and discord.js我正在使用 jest nodejs (nestjs) 和 discord.js

during the development my code works, during jest tests I get this error在开发过程中我的代码有效,在开玩笑的测试中我得到了这个错误

[1]    49780 segmentation fault  npm run test:e2e

Debugging, I notice that this call creates the problem调试,我注意到这个调用造成了问题

channel.send({ 'content': 'xxx', 'files':[file] } )

file is an AttachmentBuilder object like: file 是一个 AttachmentBuilder 对象,例如:

    AttachmentBuilder {
      attachment: <Buffer ff... 510935 more bytes>,
      name: undefined,
      description: undefined
   }

If I use如果我使用

channel.send({ 'content': 'xxx' } )

my tests work.我的测试有效。

My import is:我的导入是:

import { Client, Partials, Collection, GatewayIntentBits, TextChannel, AttachmentBuilder, MessageCreateOptions, EmbedBuilder } from 'discord.js';

Already tried to remove node_modules and install it again已经尝试删除 node_modules 并重新安装

  • node v18.12.1节点 v18.12.1
  • "jest": "^27.4.5" “开玩笑”:“^27.4.5”
  • "discord.js": "^14.7.1", "discord.js": "^14.7.1",

Downgrading your Node.js version to v16 may help fixing this issue.将 Node.js 版本降级到 v16 可能有助于解决此问题。 It helped for me.这对我有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM