小编fos*_*owe的帖子

如何使用 Jest 测试一个数组是否包含另一个数组中的任何值?

我有一个数组:

   Const domesticAnimals = ['Chicken','lama','Donkey']
   Const wildAnimals =['lama','lion','elephant']
Run Code Online (Sandbox Code Playgroud)

如何测试数组wildAnimals 中是否列出了任何内容domesticAnimals

我努力了

test('test If any wild animal is in the domestic animal list', async() =>{
expect(domesticAnimals ).toContain('lama')
}) //works perfectly

test('test If any wild animal is in the domestic animal list', async() =>{
expect(domesticAnimals ).toContain(wildAnimals) // does not work
})
Run Code Online (Sandbox Code Playgroud)

javascript jestjs

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

标签 统计

javascript ×1

jestjs ×1