Skip to content

Commit

Permalink
standardize mocking of file-saver to avoid sterr dump
Browse files Browse the repository at this point in the history
  • Loading branch information
b-cooper committed Feb 28, 2024
1 parent 5acb14d commit 5f29ad3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ResultsSummary } from '../'

import type { CalibrationPanelProps } from '../../../../organisms/CalibrationPanels/types'

// file-saver has circular dep, need to mock with factory to prevent error
vi.mock('file-saver', async importOriginal => {
const actual = await importOriginal<typeof saveAs>()
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ const PIPETTE_NAME = 'pipetteName'
const OT3_PIPETTE_NAME = OT3_PIPETTES[0]

const startCalibration = vi.fn()
vi.mock('file-saver')
// file-saver has circular dep, need to mock with factory to prevent error
vi.mock('file-saver', async importOriginal => {
const actual = await importOriginal<typeof saveAs>()
return {
...actual,
saveAs: vi.fn(),
}
})
vi.mock('@opentrons/react-api-client')
vi.mock('../../../../redux/sessions/selectors')
vi.mock('../../../../redux/discovery')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ import { renderWithProviders } from '../../../__testing-utils__'
import { useIsEstopNotDisengaged } from '../../../resources/devices/hooks/useIsEstopNotDisengaged'
import { CalibrationDataDownload } from '../CalibrationDataDownload'

vi.mock('file-saver')
// file-saver has circular dep, need to mock with factory to prevent error
vi.mock('file-saver', async importOriginal => {
const actual = await importOriginal<typeof saveAs>()
return {
...actual,
saveAs: vi.fn(),
}
})
vi.mock('@opentrons/react-api-client')
vi.mock('../../../redux/analytics')
vi.mock('../../../organisms/Devices/hooks')
Expand Down

0 comments on commit 5f29ad3

Please sign in to comment.