Skip to content

Instantly share code, notes, and snippets.

@Tallyb
Created October 13, 2023 08:43
Show Gist options
  • Save Tallyb/ce073bd23699a3ddf6f2d15395ee41be to your computer and use it in GitHub Desktop.
Save Tallyb/ce073bd23699a3ddf6f2d15395ee41be to your computer and use it in GitHub Desktop.
test.use({
storyPath: 'story name on storybook', // uses to load the component and set the base locators
fakeTime: '01/01/2023', // fakes time using sinon in the browser
});
test('Should make sure event was fired', async ({
componentLocators, // automatic locators to go to the comget the component root element
attachEvent, //automatic event attachement to the component and counting the times it was fired
getEventMockCallsCount, // returns the number of time the event was called (should be moved to custom expect)
getEventMockCallsData // returns the data the event was called with
}) => {
const { component } = componentLocators;
const event = 'someCustomEvent')
await attachEventMock('someCustomEvent');
await component.getByRole('button').click();
expect(await getEventMockCallsCount(event)).toBe(1);
expect(await getEventMockCallsData(event, 1)).toEqual(false);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment