Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda