title: How do I increment automatically a variable when calling a Cypress method?
body: <p><strong>createUserPatch</strong> is an API custom command to create a new User.</p>
  <p>You can see that I have created a variable &quot;<strong>A</strong>&quot;  inside it.</p>
  <p>The variable is used in the body emails part <code>[a]+'freddie.doe@example.com','type': 'work','primary': true}]</code></p>
  <p>I want to find a way to automatically increase the variable &quot;<strong>A</strong>&quot; whenever I call the command createUserPatch.</p>
  <pre><code>Cypress.Commands.add('createUserPatch', (user) =&gt; {
      var A = 1;
      cy.request({
          method: 'POST',
          url:  '/scim/v2/users',
          qs: {
              key : Cypress.env('apiKey')                         
          }, 
          body :{
              schemas: user.schemas,
              userName: user.userName,
              emails: [{ 'value': [A]+'freddie.doe@example.com','type': 'work','primary': true}],
              name : 'Maurice'
          }   
      }).then(res =&gt; {
          return res.body;
      });        
  });
  </code></pre>
  <p>I use this command in the test below in a before each.</p>
  <pre><code>let user = {
      schemas:'[&quot;urn:ietf:params:scim:schemas:core:2.0:User&quot;]',
      userName: 'John',
      userId: null,
      groupID: null 
  };
  
  describe('Deactivating a user ', () =&gt; {
  
      beforeEach(() =&gt; {        
          
          cy.createUserPatch(user).then((newUser) =&gt; {
              return user.userId = newUser.id;
          });
      });
  ....
  </code></pre>
  <p>Each time I run this test.
  I want the value of the email to be increased.</p>
  <p>First test -&gt; 0freddie.doe@example.com</p>
  <p>Second test -&gt; 1freddie.doe@example.com</p>
  <p>Third test -&gt; 2freddie.doe@example.com</p>
  <p>etc...</p>