Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

259
Vistas
How to have more than one plugin in cypress/plugins/index.js file?

I have 2 two different functionalities in plugins.

const fs = require('fs-extra');
const path = require('path');
const service = require('../../src/services/index');

function getConfigurationByFile(file) {
  const pathToConfigFile = path.resolve(
    '..',
    'pnb_e2e_tests/cypress/config',
    `${file}.json`
  );

  return fs.readJson(pathToConfigFile);
}

module.exports = (on, config) => {

  on('task', {
    async getAllPosts() {
      return await service.getAllPosts()
    }
  });

  const file = config.env.fileConfig || 'development';
  return getConfigurationByFile(file);
};

As you can see, one of them is for configuration file (development, production and stage) and it's executed when I start project. And the second one is knex.js which I use to work with database. When I try to call this function in tests I get an error which says Please check your plugins file:

cy.task('getAllPosts').then((config) => {
      console.log('config', config)
    })

I, probably, understand the problem, but can't resolve this.

P.S. Knex files:

const knex = require('../knex/knex')

module.exports = {
  async getAllPosts() {
    return knex('posts')
      .select('*')
  }
}

And just file with configurations:

const environment = process.env.NODE_ENV || 'development'
const config = require('./../../knexfile')[environment]
module.exports = require('knex')(config);
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda