View Slide
describe('deprecated.plugin', () => {it('should throw error',() => {…});});
describe('deprecated.plugin', () => {it('Property: Should throw an errorif the deprecated prop is used',() => {…});});
describe('Context menu', () => {it('should open the context menu on click', async () => {const wrapper = createWrapper();expect(wrapper.vm).toBeTruthy();await wrapper.trigger('click');const selector = '.sw-context-menu';expect(wrapper.find(selector).isVisible()).toBeTruthy();});});
describe('Context menu', () => {it('should open the context menu on click', () => { });});
describe('Context menu', () => {it('should open the context menu on click', () => { });});// Arrangeconst wrapper = createWrapper();const selector = '.sw-context-menu';
describe('Context menu', () => {it('should open the context menu on click', () => { });});// Arrangeconst wrapper = createWrapper();const selector = '.sw-context-menu';// Actawait wrapper.trigger('click');
describe('Context menu', () => {it('should open the context menu on click', () => { });});// Arrangeconst wrapper = createWrapper();const selector = '.sw-context-menu';// Actawait wrapper.trigger('click');// Assertexpect(wrapper.vm).toBeTruthy();expect(wrapper.find(selector).isVisible()).toBeTruthy();
“…arrange my test == what I’m given.”
“…arrange my test == what I’m given.”“…act in my test == when something happens.”
“…arrange my test == what I’m given.”“…act in my test == when something happens.”“…assert the results == something happensthen this is what I expect as the outcome.”
describe('Context menu', () => {it('should open the context menu on click', () => {// Givenconst contextButtonSelector = 'sw-context-button';const contextMenuSelector = '.sw-context-menu';// Whenlet contextMenu = wrapper.find(contextMenuSelector);expect(contextMenu.isVisible()).toBe(false);const contextButton = wrapper.find(contextButtonSelector);await contextButton.trigger('click');// ThencontextMenu = wrapper.find(contextMenuSelector);expect(contextMenu.isVisible()).toBe(true);});});
it('should create and read product', () => {…cy.get('.sw-field—product-name').type('T-Shirt Ackbar');cy.get('.sw-select-product__select_manufacturer').type('Space Company’);…});
Cypress.Commands.add('typeSingleSelect', {prevSubject: 'element',},(subject, value, selector) => {…cy.wait(500);cy.get(`${selector} input`).type(value);});