hapi.js

Hapijs running test ignoring the leaks


I am building a web application using HapiJS. I am writing tests for my application. I am running the test using the following command:

lab -v test/**/*.test.js

When I run the tests I am getting the following error even though all the tests pass:

The following leaks were detected:__extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __createBinding, __values, __read, __spread, __spreadArrays, __spreadArray, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet

I am trying to ignore that using the following commands:

lab -v --globals test/**/*.test.js

lab -v -I test/**/*.test.js

lab -v --ignore test/**/*.test.js

But none of the commands above are working. How can I ignore that error?


Solution

  • From the doc

    -l, --leaks - disables global variable leak detection.

    Or

    -I, --ignore - ignore a list of globals for the leak detection (comma separated), this is an alias of globals property in .labrc file. To ignore symbols, pass the symbol's string representation (e.g. Symbol(special)).

    .labrc.js Example

    module.exports = {
        globals: ['__extends', '__assign', '__rest', ...],
    };
    

    You can check the example HERE