Best JavaScript code snippet using storybook-root
addon-actions.stories.js
Source:addon-actions.stories.js
2const buttonStory = () => () => `<button type="button">Hello World</button>`;3export default {4 title: 'Addons/Actions',5};6export const Story1 = buttonStory();7Story1.storyName = 'Hello World';8Story1.parameters = {9 actions: {10 handles: ['click'],11 },12};13export const Story2 = buttonStory();14Story2.storyName = 'Multiple actions';15Story2.parameters = {16 actions: {17 handles: ['click', 'contextmenu'],18 },19};20export const Story3 = buttonStory();21Story3.storyName = 'Multiple actions + config';22Story3.parameters = {23 actions: {24 handles: ['click', 'contextmenu', { clearOnStoryChange: false }],25 },26};27export const Story4 = buttonStory();28Story4.storyName = 'Multiple actions, object';29Story4.parameters = {30 actions: {31 handles: [{ click: 'clicked', contextmenu: 'right clicked' }],32 },33};34export const Story5 = () => `35 <div>36 Clicks on this button will be logged: <button class="btn" type="button">Button</button>37 </div>38 `;39Story5.storyName = 'Multiple actions, selector';40Story5.parameters = {41 actions: {42 handles: [{ 'click .btn': 'clicked', contextmenu: 'right clicked' }],43 },44};45export const Story6 = buttonStory();46Story6.storyName = 'Multiple actions, object + config';47Story6.parameters = {48 actions: {49 handles: [{ click: 'clicked', contextmenu: 'right clicked' }, { clearOnStoryChange: false }],50 },51};52export const DeprecatedDecoratorsStory1 = buttonStory();53DeprecatedDecoratorsStory1.storyName = 'Deprecated decorators - Single action';54DeprecatedDecoratorsStory1.decorators = [withActions('click')];55export const DeprecatedDecoratorsStory2 = buttonStory();56DeprecatedDecoratorsStory2.storyName = 'Deprecated decorators - Multiple actions';57DeprecatedDecoratorsStory2.decorators = [withActions('click', 'contextmenu')];58export const DeprecatedDecoratorsStory3 = buttonStory();59DeprecatedDecoratorsStory3.storyName = 'Deprecated decorators - Multiple actions + config';60DeprecatedDecoratorsStory3.decorators = [61 withActions('click', 'contextmenu', { clearOnStoryChange: false }),62];63export const DeprecatedDecoratorsStory4 = buttonStory();64DeprecatedDecoratorsStory4.storyName = 'Deprecated decorators - Multiple actions, object';65DeprecatedDecoratorsStory4.decorators = [66 withActions({ click: 'clicked', contextmenu: 'right clicked' }),...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!