text: /*
   * (c) Copyright IBM Corp. 2021
   * (c) Copyright Instana Inc. and contributors 2018
   */
  
  'use strict';
  
  const expect = require('chai').expect;
  const semver = require('semver');
  
  const config = require('../../../../../core/test/config');
  const supportedVersion = require('@instana/core').tracing.supportedVersion;
  const testUtils = require('../../../../../core/test/test_util');
  const ProcessControls = require('../../../test_util/ProcessControls');
  const globalAgent = require('../../../globalAgent');
  
  const mochaSuiteFn =
    supportedVersion(process.versions.node) && semver.gte(process.versions.node, '8.0.0') ? describe : describe.skip;
  
  mochaSuiteFn('tracing/requireHook', function () {
    this.timeout(config.getTestTimeout());
  
    globalAgent.setUpCleanUpHooks();
    const agentControls = globalAgent.instance;
  
    const controls = new ProcessControls({
      dirname: __dirname,
      useGlobalAgent: true
    });
    ProcessControls.setUpHooks(controls);
  
    describe('stealthy require', () => {
      it('must not apply caching when not necessary / or when something is fishy', () =>
        controls
          .sendRequest({
            method: 'GET',
            path: '/requireRequestPromiseMultipleTimes'
          })
          .then(() =>
            testUtils.retry(() =>
              agentControls.getSpans().then(spans => {
                testUtils.expectAtLeastOneMatching(spans, [
                  span => expect(span.n).to.equal('node.http.server'),
                  span => expect(span.data.http.status).to.equal(200)
                ]);
              })
            )
          ));
    });
  });
  