Me gustaría verificar si existe un archivo .env en la carpeta raíz antes de ejecutar la prueba. He agregado la siguiente función en index.js pero no verifica si el archivo existe. ¿Podría alguien aconsejar el problema aquí?
ciprés/ complementos/ index.js
const filePath = "../../../.env"; module.exports = (on, config) => { on('file:preprocessor', cucumber()), on('before:browser:launch', (browser, launchOptions) => { console.log("Print browser name: "+browser.name); fileCheck(filePath); // calling the function here }); }; function fileCheck(filePath) => { try { if (fs.existsSync(filePath)) { console.log("Awesome ! .env file exists in the root directory ! "); } } catch(err) { console.error(err) console.log("Oh !, .env file is missing, please add !"); } }Tal vez sea suficiente verificarlo en una acción anterior, luego puede hacer:
before(() => { cy.on('fail', (error) => { error.message = 'Oh !, .env file is missing, please add !'; throw error; }) cy.readFile('.env', {timeout: 50}).should('exist');});