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

178
Vistas
How to retrieve current test from parent mocha suite

I'm trying to setup plugin and I stumbled upon a problem with test framework mocha.

My goal is to get name of the test, in which library instance currently executes method run without passing this into each method call.

Library is instantiated at the top suite with passed suite instance this. Problem is that this in parent suite contains array of suites and tests, but no information about currently executed test.

const { SuperfaceTest } = require('@superfaceai/testing');
const chai = require('chai');
const { jestSnapshotPlugin } = require('mocha-chai-jest-snapshot');

chai.use(jestSnapshotPlugin());

const expect = chai.expect;

describe('usecases', function () {
  const superfaceTest = new SuperfaceTest({ testInstance: this });

  describe('starwars', function () {
    it('character info luke', async function () {
      const input = {
        characterName: 'Luke Skywalker',
      };

      expect(
        await superfaceTest.run({
          profile: 'starwars/character-information',
          provider: 'swapi',
          useCase: 'RetrieveCharacterInformation',
          input,
        })
      ).toMatchSnapshot();
    });
  });
});

I'm trying to figure out a way to recognize current executing test just from instance of top suite.

Is there some property that I've missed, that could indicate currently executed test? Or is there some other way how to get current test in mocha from outside that test?

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