[英]Jest snapshot tests failing in GitHub Actions due to missing color
[英]Jest not creating snapshot or failing tests
我正在為React學習一門課程,在我的第一個測試中開玩笑之后,似乎應該在創建快照,但是它沒有說它有快照,並且我沒有看到快照文件。
當我更改組件中的內容並再次運行Jest時,它不會像我期望的那樣失敗。 我只是在命令行上jest
,它可以找到測試,但無論我如何更改組件,它總是可以通過。 (我假設是因為它沒有創建要進行比較的快照?)
我可能做錯了什么?
這是測試:
import React from 'react'
import Search from './Search'
import renderer from 'react-test-renderer'
test('Search snapshot test', () => {
const component = renderer.create(<Search />)
const tree = component.toJSON()
expect(tree).toMatchSnapshot
})
您錯過了()
結尾:
expect(tree).toMatchSnapshot()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.