diff --git a/testing/helpers.ts b/testing/helpers.ts index 7c4db18d4902..fb40435942d3 100644 --- a/testing/helpers.ts +++ b/testing/helpers.ts @@ -1,8 +1,8 @@ /* eslint-disable max-classes-per-file */ import { basename, dirname, join } from 'path'; import { fileURLToPath } from 'url'; +import { merge, set, snakeCase } from 'lodash-es'; import { YeomanTest, RunContext, RunContextSettings, RunResult, result } from 'yeoman-test'; -import { merge, set } from 'lodash-es'; import { globSync } from 'glob'; import type { BaseEnvironmentOptions, GetGeneratorConstructor, BaseGenerator as YeomanGenerator } from '@yeoman/types'; @@ -249,6 +249,12 @@ class JHipsterRunContext extends RunContext { return this.withSharedData({ sharedApplication: this.sharedApplication }); } + withMockedNodeDependencies() { + return this.withSharedApplication({ + nodeDependencies: new Proxy({}, { get: (_target, prop) => `${snakeCase(prop.toString()).toUpperCase()}_VERSION` }), + }); + } + /** * Mock every built-in generators except the ones in the except and bootstrap-* generators. * Note: Boostrap generator is mocked by default.