I'm trying to create a list of values during the tests execution adding them to an environment variable. After all the tests execute, I want to write those values into a file.
If I use the event 'after: spec' on the file cypress.config.js, I can't access the environment variables but I can write into files using 'fs-extra'
If I use the event 'test:after:run' on the commands.js, I can acess to the environment variables but I can't write into a file.
Using cy.writeFile doesn't trigger any error but doesn't do anything.
If I import fs-extra inside the file commands.js
const fs = require('fs-extra')
I get an error
----
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test.
We dynamically generated a new test to display this failure.
node_modules/fs-extra/lib/fs/index.js:121:1
119 |
120 | // fs.realpath.native sometimes not available if fs is monkey-patched
> 121 | if (typeof fs.realpath.native === 'function') {
| ^
122 | exports.realpath.native = u(fs.realpath.native)
123 | } else {
124 | process.emitWarning(
So, I'm a little blocked