Skip to content

Commit

Permalink
add withMockedNodeDependencies to test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jul 3, 2024
1 parent 0e4571b commit b745046
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion testing/helpers.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -249,6 +249,12 @@ class JHipsterRunContext extends RunContext<GeneratorTestType> {
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.
Expand Down

0 comments on commit b745046

Please sign in to comment.