小编inn*_*nis的帖子

使用 jest 运行测试时如何修复“测试套件运行失败”

我正在学习如何用笑话编写测试,当我运行它们时,我得到了这个巨大的日志退出。

\n\n

由于它是一个很小的代码,因此我认为将其完全发布没有问题。

\n\n
describe(\'First test\', async () => {\n  const OLD_ENV = process.env;\n\n  beforeEach(() => {\n    jest.resetModules();\n    process.env = { MONGO_CLUSTER_URI: <<<hidden for security reasons>>>\' };\n  })\n\n  afterEach(() => {\n    process.env = OLD_ENV;\n  })\n\n  test(\'Should pass\', async () => {\n    console.log(\'Testing...\');\n    const response = await index.handler({ event: \'input\' }, { });\n    console.log(response);\n    expect(response).toBe(true);\n  })\n})\n
Run Code Online (Sandbox Code Playgroud)\n\n

我不知道它是否应该给我带来这么大的输出,但我认为它不是,因为它看起来像是抛出了某种错误。我将输出发布在下面,以便你们可以帮助我。

\n\n
tvrsky@pc:~/lambda-testes-jest/functions/cf_post_processing$ lerna run test --scope cf_post_processing\ninfo cli using local version of lerna\nlerna notice cli v3.16.4\nlerna info versioning independent\nlerna info filter [ \'cf_post_processing\' …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing node.js jestjs

4
推荐指数
1
解决办法
2万
查看次数

当我在 github 上上传代码时,如何隐藏我的不和谐机器人令牌?

我正在编写这个 discordbot 并希望它在 github 上。如何在不公开其令牌的情况下上传它?

const Discord = require('discord.js');
const client = new Discord.Client();
// Following is the part that matter, the code before is just to get some context 
const token = '[hidden for security reasons]'; 
Run Code Online (Sandbox Code Playgroud)

我想我应该把它放在一个单独的文件中,但我不知道如何在我的 index.js 文件中引用它。

我该如何解决问题?

git

3
推荐指数
1
解决办法
2062
查看次数

标签 统计

git ×1

javascript ×1

jestjs ×1

node.js ×1

unit-testing ×1