You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, there is no ergonomic way for a test author to mock the behavior of an @wire dependency. A mechanism should be built so that the test environment can directly call or modify the state of a mock, on a per-test basis. Once this is in place, an additional layer should be built on top of the first to enable a test to modify the behavior of a wire.
importrecordApiMockfrom'mock{getRecord}:lightning/uiRecordApi';importmockWirefrom'@lwc/test-runner';describe(()=>{beforeEach(async()=>{awaitrecordApiMock.reset();});it('should be possible to mock the wire value',async()=>{constrecordApiWire=awaitmockWire(recordApiMock,'getRecord');awaitrecordApiWire.setWiredData({Name: {value: 'foo'}});// Test the component's subsequent behavior.});});
The text was updated successfully, but these errors were encountered:
Possibly. That library is largely agnostic to the test runner in which it is invoked, despite the name. We are looking at this one actively right now, although it is proving to be tricky to solve. We may need to revisit some of the baseline mock functionality to really make this ergonomic.
I'd be interested to hear what experiments/thinking you've done on this subject. Would pulling in the Jest util meet your needs? Or are there particular improvements of functionality that you'd like to see?
Currently, there is no ergonomic way for a test author to mock the behavior of an
@wire
dependency. A mechanism should be built so that the test environment can directly call or modify the state of a mock, on a per-test basis. Once this is in place, an additional layer should be built on top of the first to enable a test to modify the behavior of a wire.Example component code:
Example test code:
The text was updated successfully, but these errors were encountered: