|
10 | 10 | // scripts for running tests take care of that.
|
11 | 11 | //
|
12 | 12 | // The globalAgent module manages an agent stub instance that can be used globally for all tests.
|
13 |
| - |
14 |
| -const { startGlobalAgent, stopGlobalAgent } = require('./globalAgent'); |
| 13 | +const path = require('path'); |
15 | 14 | const isCI = require('@instana/core/test/test_util/is_ci');
|
16 | 15 | const config = require('@instana/core/test/config');
|
17 | 16 | const fs = require('fs');
|
18 | 17 |
|
19 | 18 | exports.mochaHooks = {
|
20 | 19 | async beforeAll() {
|
| 20 | + // NOTE: mocha --watch has a bug (https://github.com/mochajs/mocha/issues/5149) |
| 21 | + // We manually clear the file from the cache here. |
| 22 | + const globalAgentModulePath = path.resolve(__dirname, './globalAgent'); |
| 23 | + delete require.cache[globalAgentModulePath]; |
| 24 | + |
| 25 | + const { startGlobalAgent } = require('./globalAgent'); |
| 26 | + |
21 | 27 | // eslint-disable-next-line no-console
|
22 | 28 | console.log(`@instana/collector test suite starting at ${timestamp()}.`);
|
23 | 29 | this.timeout(config.getTestTimeout());
|
@@ -54,6 +60,15 @@ exports.mochaHooks = {
|
54 | 60 | },
|
55 | 61 |
|
56 | 62 | async afterAll() {
|
| 63 | + // NOTE: mocha --watch has a bug (https://github.com/mochajs/mocha/issues/5149) |
| 64 | + // We manually clear the file from the cache here. |
| 65 | + const globalAgentModulePath = path.resolve(__dirname, './globalAgent'); |
| 66 | + delete require.cache[globalAgentModulePath]; |
| 67 | + |
| 68 | + const { stopGlobalAgent } = require('./globalAgent'); |
| 69 | + |
| 70 | + // eslint-disable-next-line no-console |
| 71 | + console.log(`@instana/collector test suite stopping at ${timestamp()}.`); |
57 | 72 | this.timeout(config.getTestTimeout());
|
58 | 73 | await stopGlobalAgent();
|
59 | 74 | }
|
|
0 commit comments