Best JavaScript code snippet using storybook-root
ArgsStore.test.ts
Source: ArgsStore.test.ts
...122 const story = {123 id: 'id',124 argTypes: { a: stringType },125 } as any;126 store.updateFromPersisted(story, { a: 'str' });127 expect(store.get('id')).toEqual({ a: 'str' });128 store.updateFromPersisted(story, { a: 42 });129 expect(store.get('id')).toEqual({ a: '42' });130 });131 it('merges objects and sparse arrays', () => {132 const store = new ArgsStore();133 store.setInitial({ id: 'id', initialArgs: { a: { foo: 'bar' }, b: ['1', '2', '3'] } } as any);134 const story = {135 id: 'id',136 argTypes: {137 a: { type: { name: 'object', value: { name: 'string' } } },138 b: { type: { name: 'array', value: { name: 'string' } } },139 },140 } as any;141 store.updateFromPersisted(story, { a: { baz: 'bing' } });142 expect(store.get('id')).toEqual({143 a: { foo: 'bar', baz: 'bing' },144 b: ['1', '2', '3'],145 });146 // eslint-disable-next-line no-sparse-arrays147 store.updateFromPersisted(story, { b: [, , '4'] });148 expect(store.get('id')).toEqual({149 a: { foo: 'bar', baz: 'bing' },150 b: ['1', '2', '4'],151 });152 });153 it('checks args are allowed options', () => {154 const store = new ArgsStore();155 store.setInitial({ id: 'id', initialArgs: {} } as any);156 const story = {157 id: 'id',158 argTypes: { a: { type: { name: 'string' }, options: ['a', 'b'] } },159 } as any;160 store.updateFromPersisted(story, { a: 'random' });161 expect(store.get('id')).toEqual({});162 store.updateFromPersisted(story, { a: 'a' });163 expect(store.get('id')).toEqual({ a: 'a' });164 });165 });...
GlobalsStore.ts
Source: GlobalsStore.ts
...20 const defaultGlobals: Globals = getValuesFromArgTypes(globalTypes);21 this.initialGlobals = { ...defaultGlobals, ...globals };22 this.globals = this.initialGlobals;23 if (delta && delta !== DEEPLY_EQUAL) {24 this.updateFromPersisted(delta);25 }26 }27 filterAllowedGlobals(globals: Globals) {28 return Object.entries(globals).reduce((acc, [key, value]) => {29 if (this.allowedGlobalNames.has(key)) acc[key] = value;30 return acc;31 }, {} as Globals);32 }33 updateFromPersisted(persisted: Globals) {34 const allowedUrlGlobals = this.filterAllowedGlobals(persisted);35 // Note that unlike args, we do not have the same type information for globals to allow us36 // to type check them here, so we just set them naively37 this.globals = { ...this.globals, ...allowedUrlGlobals };38 }39 get() {40 return this.globals;41 }42 update(newGlobals: Globals) {43 Object.keys(newGlobals).forEach((key) => {44 if (!this.allowedGlobalNames.has(key)) {45 setUndeclaredWarning();46 }47 });...
Check out the latest blogs from LambdaTest on this topic:
Development practices are constantly changing and as testers, we need to embrace change. One of the changes that we can experience is the move from monthly or quarterly releases to continuous delivery or continuous deployment. This move to continuous delivery or deployment offers testers the chance to learn new skills.
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
With the rise of Agile, teams have been trying to minimize the gap between the stakeholders and the development team.
In today’s tech world, where speed is the key to modern software development, we should aim to get quick feedback on the impact of any change, and that is where CI/CD comes in place.
Hey everyone! We hope you had a great Hacktober. At LambdaTest, we thrive to bring you the best with each update. Our engineering and tech teams work at lightning speed to deliver you a seamless testing experience.
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!!