Skip to content

Commit

Permalink
testing: add Environment type to JHipsterRunResult
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Sep 27, 2024
1 parent 7973ba7 commit c186a77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/testing/helpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('helpers', () => {
});
it('should register not jhipster generators namespaces', () => {
expect(
Object.keys(runResult.env.store._meta)
Object.keys((runResult.env as any).store._meta)
.filter(ns => ns !== DUMMY_NAMESPACE)
.sort(),
).toHaveLength(0);
Expand All @@ -22,7 +22,7 @@ describe('helpers', () => {
});
it('should register jhipster generators namespaces', () => {
expect(
Object.keys(runResult.env.store._meta)
Object.keys((runResult.env as any).store._meta)
.filter(ns => ns !== DUMMY_NAMESPACE)
.sort(),
).toMatchSnapshot();
Expand All @@ -34,7 +34,7 @@ describe('helpers', () => {
});
it('should register jhipster generators namespaces', () => {
expect(
Object.keys(runResult.env.store._meta)
Object.keys((runResult.env as any).store._meta)
.filter(ns => ns !== DUMMY_NAMESPACE)
.sort(),
).toMatchSnapshot();
Expand All @@ -48,7 +48,7 @@ describe('helpers', () => {
});
it('should register jhipster generators namespaces', () => {
expect(
Object.keys(runResult.env.store._meta)
Object.keys((runResult.env as any).store._meta)
.filter(ns => ns !== DUMMY_NAMESPACE)
.sort(),
).toMatchSnapshot();
Expand Down
5 changes: 4 additions & 1 deletion lib/testing/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { mock } from 'node:test';
import { merge, set, snakeCase } from 'lodash-es';
import type { RunContextSettings, RunResult } from 'yeoman-test';
import { RunContext, YeomanTest, result } from 'yeoman-test';
import type Environment from 'yeoman-environment';
import { globSync } from 'glob';

import type { BaseEnvironmentOptions, GetGeneratorConstructor, BaseGenerator as YeomanGenerator } from '@yeoman/types';
Expand Down Expand Up @@ -43,7 +44,9 @@ type WithJHipsterGenerators = {
useEnvironmentBuilder?: boolean;
};

type JHipsterRunResult<GeneratorType extends CoreGenerator = CoreGenerator> = RunResult<GeneratorType> & {
type JHipsterRunResult<GeneratorType extends CoreGenerator = CoreGenerator> = Omit<RunResult<GeneratorType>, 'env'> & {
env: Environment;

/**
* First argument of mocked source calls.
*/
Expand Down

0 comments on commit c186a77

Please sign in to comment.