Universal Code Test with Cypress

1 · Gleb Bahmutov · Nov. 11, 2020, 4:48 p.m.
Note: you can find the source code for this blog post in the repository bahmutov/cypress-universal-test.StartLet's take a piece of JavaScript codesrc/sum.js1234function add(a, b) { return a + b}console.log('2 + 3 =', add(2, 3))This JavaScript code is universal - it runs the same way in the browser and in Node. Can we confirm this using just the Cypress test runner? Sure. We can directly import this file from the spec and it runs.12$ npm i -D cypress+ [email protected]/integration/spec.js1234...