From https://docs.cypress.io/api/cypress-api/custom-commands.html
Put this in your support/commands.js file:
Cypress.Commands.add('subValues', (a, b) => { return a - b });
Put this in your support/index.js file, if it isn’t already there (it should be):
import "./commands";
Call it in your test like so:
describe ('Calling a function', function(){
it('Call the Subtract function and asert the calculation', function(){
cy
.subValues(15, 8)
.should('eq', 7) // true
});
});