Hey,
I am having a hard time testing my code and would like to find out if and how some of my event handlers are actually being called, when I run fireEvent.click() on a button.
Some background: I am running solid inside a Tauri-Application which works very well.
However my issue is, that on the click of a button nothing observable seems to happen (it works perfectly fine in the real running application).
Basically what I am trying to do, is to setup some stores, render my app, find a button that should start a timer, advance these timers by using vitests fake timers and afterwards inspect, that a stop button is being rendered and the time has been adjusted accordingly.
My current (simplified without timers) test looks like this:
it('should run on toggle start', async () => {
// Arrange
render(() => <App />, { location: '/' })
const TEST_ID = 'TEST_ENTRY'
setTimeEntries(TEST_ID, {
id: TEST_ID,
savedTimeInMs: 0,
date: '2023-07-02T00:00:00.000Z',
description: 'This is a test entry',
isBillable: true,
isFavorite: false,
})
setRunningTimer({
timeEntryId: TEST_ID,
savedTimeInMs: 0,
isRunning: false,
})
setIsHydrating(false)
// Act
const currentTimerStartButton = await screen.findByRole('button', { name: 'start-current-timer' })
mockIPC(() => {
fireEvent.click(currentTimerStartButton)
})
// Assert
expect(await screen.findByRole('button', { name: 'stop-current-timer' })).toBeInTheDocument()
expect(await screen.findByTestId('running-timer-time')).toHaveTextContent('00:00:03')
})
(continuation in thread)