diff --git a/generators/base-application/generator.spec.ts b/generators/base-application/generator.spec.ts index eeafed6384c6..545fc27285f9 100644 --- a/generators/base-application/generator.spec.ts +++ b/generators/base-application/generator.spec.ts @@ -24,7 +24,6 @@ import { snakeCase } from 'lodash-es'; import EnvironmentBuilder from '../../cli/environment-builder.mjs'; import Generator from './index.js'; -import type { BaseApplication } from '../base-application/types.js'; import { defaultHelpers as helpers } from '../../testing/index.js'; import { shouldSupportFeatures } from '../../test/support/tests.js'; @@ -318,7 +317,7 @@ describe(`generator - ${generator}`, () => { const writingEntities = esmocha.fn(); const postWritingEntities = esmocha.fn(); - class CustomGenerator extends Generator { + class CustomGenerator extends Generator { async beforeQueue() { await this.dependsOnJHipster('bootstrap-application'); } diff --git a/generators/client/generator-needles.spec.ts b/generators/client/generator-needles.spec.ts index c4bce5b6bf42..e1d1007c535b 100644 --- a/generators/client/generator-needles.spec.ts +++ b/generators/client/generator-needles.spec.ts @@ -15,7 +15,7 @@ const mockBlueprintSubGen: any = class extends ClientGenerator { get [ClientGenerator.POST_WRITING]() { return this.asPostWritingTaskGroup({ webpackPhase({ source }) { - source.addWebpackConfig({ config: '{devServer:{}}' }); + source!.addWebpackConfig!({ config: '{devServer:{}}' }); }, }); } diff --git a/generators/client/needle-client.spec.ts b/generators/client/needle-client.spec.ts index f2e55eb41b58..a5cb07295786 100644 --- a/generators/client/needle-client.spec.ts +++ b/generators/client/needle-client.spec.ts @@ -19,7 +19,7 @@ const mockBlueprintSubGen: any = class extends ClientGenerator { return this.asPostWritingTaskGroup({ // @ts-ignore async additionalResource({ source }) { - source.addExternalResourceToRoot({ + source!.addExternalResourceToRoot!({ resource: '', comment: 'Comment added by JHipster API', }); @@ -38,7 +38,7 @@ describe('needle API Client: JHipster client generator with blueprint', () => { .withOptions({ blueprint: 'myblueprint', }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']]); + .withGenerators([[mockBlueprintSubGen, { namespace: 'jhipster-myblueprint:client' }]]); }); it('Assert index.html contain the comment and the resource added', () => { diff --git a/generators/entity/database-changelog.spec.ts b/generators/entity/database-changelog.spec.ts index 367d5377415b..d2d06a1491c0 100644 --- a/generators/entity/database-changelog.spec.ts +++ b/generators/entity/database-changelog.spec.ts @@ -21,7 +21,7 @@ describe('generator - entity database changelogs', () => { before(async () => { await helpers .run(getGenerator('entity')) - .withGenerators([[MockedLanguagesGenerator, 'jhipster:languages']]) + .withGenerators([[MockedLanguagesGenerator, { namespace: 'jhipster:languages' }]]) .withJHipsterConfig({ databaseType: 'cassandra' }, [entityFoo]) .withArguments(['Foo']) .withOptions({ regenerate: true, force: true, ignoreNeedlesError: true }); @@ -35,7 +35,7 @@ describe('generator - entity database changelogs', () => { before(async () => { await helpers .run(getGenerator('entity')) - .withGenerators([[MockedLanguagesGenerator, 'jhipster:languages']]) + .withGenerators([[MockedLanguagesGenerator, { namespace: 'jhipster:languages' }]]) .withJHipsterConfig({ applicationType: 'gateway' }, [ { ...entityFoo, microservicePath: 'microservice1', microserviceName: 'microservice1' }, ]) diff --git a/generators/entity/single-entity.spec.ts b/generators/entity/single-entity.spec.ts index 920bd7296ceb..60bb4cdbe71c 100644 --- a/generators/entity/single-entity.spec.ts +++ b/generators/entity/single-entity.spec.ts @@ -23,7 +23,7 @@ describe('generator - entity --single-entity', () => { before(async () => { await helpers .runJHipster(GENERATOR_ENTITY) - .withGenerators([[MockedLanguagesGenerator, 'jhipster:languages']]) + .withGenerators([[MockedLanguagesGenerator, { namespace: 'jhipster:languages' }]]) .withJHipsterConfig({}, [entityFoo, entityBar]) .withArguments(['Foo']) .withOptions({ ignoreNeedlesError: true, regenerate: true, force: true, singleEntity: true }) @@ -56,7 +56,7 @@ describe('generator - entity --single-entity', () => { before(async () => { runResult = await helpers .runJHipster(GENERATOR_ENTITY) - .withGenerators([[MockedLanguagesGenerator, 'jhipster:languages']]) + .withGenerators([[MockedLanguagesGenerator, { namespace: 'jhipster:languages' }]]) .withJHipsterConfig({ databaseType: 'cassandra' }, [entityFoo, entityBar]) .withArguments(['Foo']) .withOptions({ ignoreNeedlesError: true, regenerate: true, force: true, singleEntity: true }); diff --git a/generators/gradle/needles.spec.ts b/generators/gradle/needles.spec.ts index 48506c23b014..9c4b112d7f56 100644 --- a/generators/gradle/needles.spec.ts +++ b/generators/gradle/needles.spec.ts @@ -49,7 +49,7 @@ describe('needle API server gradle: JHipster server generator with blueprint', ( clientFramework: 'no', buildTool: 'gradle', }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]); + .withGenerators([[mockBlueprintSubGen, { namespace: 'jhipster-myblueprint:server' }]]); }); it('Assert gradle.properties has the property added', () => { diff --git a/generators/java/support/checks/check-java.spec.ts b/generators/java/support/checks/check-java.spec.ts index 45eb8946aa3e..8afb25ab890e 100644 --- a/generators/java/support/checks/check-java.spec.ts +++ b/generators/java/support/checks/check-java.spec.ts @@ -1,10 +1,11 @@ import { after, before, it, describe, expect, resetAllMocks, esmocha } from 'esmocha'; -import { ExecaSyncReturnValue } from 'execa'; +import { SyncResult } from 'execa'; import quibble from 'quibble'; const execa = { execa: esmocha.fn(), execaSync: esmocha.fn(), execaCommandSync: esmocha.fn(), execaCommand: esmocha.fn() }; -const baseResult: ExecaSyncReturnValue = { +const baseResult: SyncResult = { + cwd: '', command: 'java', escapedCommand: 'java', exitCode: 0, @@ -12,8 +13,7 @@ const baseResult: ExecaSyncReturnValue = { stderr: '', failed: false, timedOut: false, - killed: false, -}; +} as any; describe('generator - server - checkJava', () => { before(async () => { @@ -34,7 +34,7 @@ describe('generator - server - checkJava', () => { before(async () => { execa.execaCommandSync.mockReturnValue({ ...baseResult, stderr } as any); const { default: checkJava } = await import('./check-java.js'); - result = checkJava(); + result = checkJava([]); }); it('should return info and javaVersion', async () => { @@ -53,7 +53,7 @@ describe('generator - server - checkJava', () => { before(async () => { execa.execaCommandSync.mockReturnValue({ ...baseResult, exitCode, stderr } as any); const { default: checkJava } = await import('./check-java.js'); - result = checkJava(); + result = checkJava([]); }); it('should return error', async () => { @@ -69,7 +69,7 @@ describe('generator - server - checkJava', () => { throw new Error('foo'); }); const { default: checkJava } = await import('./check-java.js'); - result = checkJava(); + result = checkJava([]); }); it('should return error', async () => { diff --git a/generators/java/support/doc.ts b/generators/java/support/doc.ts index 6a754aa0046b..3dd5ba55c95c 100644 --- a/generators/java/support/doc.ts +++ b/generators/java/support/doc.ts @@ -45,7 +45,7 @@ export const formatDocAsJavaDoc = (text: string, indentSize = 0): string => { return rows.join('\n'); }; -export const formatDocAsApiDescription = (text: string): string => { +export const formatDocAsApiDescription = (text?: string): string | undefined => { if (!text) { return text; } diff --git a/generators/liquibase/needles.spec.ts b/generators/liquibase/needles.spec.ts index 88477eba0e83..9dc5bf36dbd1 100644 --- a/generators/liquibase/needles.spec.ts +++ b/generators/liquibase/needles.spec.ts @@ -45,7 +45,7 @@ describe('generator - liquibase - needles', () => { .withOptions({ skipPriorities: ['writing'], }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:liquibase']]); + .withGenerators([[mockBlueprintSubGen, { namespace: 'jhipster-myblueprint:liquibase' }]]); }); it('Assert changelog is added to master.xml', () => { diff --git a/generators/maven/generator.spec.ts b/generators/maven/generator.spec.ts index 10b8b9eb8aa7..e59357f428c1 100644 --- a/generators/maven/generator.spec.ts +++ b/generators/maven/generator.spec.ts @@ -94,7 +94,7 @@ describe(`generator - ${generator}`, () => { }); } }, - 'jhipster-blueprint:maven', + { namespace: 'jhipster-blueprint:maven' }, ], ]); }); diff --git a/generators/maven/needles.spec.ts b/generators/maven/needles.spec.ts index 84d73399a601..ec026506edb9 100644 --- a/generators/maven/needles.spec.ts +++ b/generators/maven/needles.spec.ts @@ -13,7 +13,7 @@ class mockBlueprintSubGen extends BaseApplicationGenerator { get [BaseApplicationGenerator.POST_WRITING]() { return this.asPostWritingTaskGroup({ mavenStep({ source }) { - const inProfile = this.options.profile; + const inProfile = (this.options as any).profile; function asItemOrArray(item: T): T | T[] { return inProfile ? [item] : item; } diff --git a/generators/server/options/database-migration.spec.ts b/generators/server/options/database-migration.spec.ts index 42210808ab6b..15e85a9bf949 100644 --- a/generators/server/options/database-migration.spec.ts +++ b/generators/server/options/database-migration.spec.ts @@ -4,7 +4,7 @@ import { DATABASE_MIGRATION as optionName } from './index.js'; import optionDefinition from './database-migration.js'; describe(`generators - server - jdl - ${optionName}`, () => { - optionDefinition.knownChoices.forEach(optionValue => { + optionDefinition.knownChoices!.forEach(optionValue => { describe(`with ${optionValue} value`, () => { let state: ImportState; diff --git a/generators/server/options/message-broker.spec.ts b/generators/server/options/message-broker.spec.ts index 7c9e2b3fb57e..cab5f7370573 100644 --- a/generators/server/options/message-broker.spec.ts +++ b/generators/server/options/message-broker.spec.ts @@ -4,7 +4,7 @@ import { MESSAGE_BROKER } from './index.js'; import optionDefinition from './message-broker.js'; describe('generators - server - jdl - messageBroker', () => { - optionDefinition.knownChoices.forEach(optionValue => { + optionDefinition.knownChoices!.forEach(optionValue => { describe(`with ${optionValue} value`, () => { let state: ImportState; diff --git a/generators/server/support/needles.spec.ts b/generators/server/support/needles.spec.ts index 12e165ffa13e..b8653225d6fd 100644 --- a/generators/server/support/needles.spec.ts +++ b/generators/server/support/needles.spec.ts @@ -17,15 +17,15 @@ * limitations under the License. */ import { before, it, describe, expect } from 'esmocha'; -import { defaultHelpers as helpers } from '../../../testing/index.js'; +import { defaultHelpers as helpers, runResult } from '../../../testing/index.js'; import { GENERATOR_SPRING_BOOT } from '../../generator-list.js'; import { insertContentIntoApplicationProperties } from './needles.js'; +import type { SpringBootApplication } from '../types.js'; describe('generator - server - support - needles', () => { describe('generated project', () => { - let runResult; before(async () => { - runResult = await helpers + await helpers .runJHipster(GENERATOR_SPRING_BOOT) .withMockedGenerators(['jhipster:common', 'jhipster:languages', 'jhipster:liquibase']); }); @@ -36,7 +36,7 @@ describe('generator - server - support - needles', () => { describe('insertContentIntoApplicationProperties needle', () => { it('with a non existing needle', () => { - const application = runResult.generator.sharedData.getApplication(); + const application: SpringBootApplication = runResult.generator.sharedData.getApplication(); expect(() => insertContentIntoApplicationProperties.call(runResult.generator, application, { foo: 'foo' })).toThrow( /Missing required jhipster-needle application-properties-foo not found at/, ); diff --git a/generators/upgrade/upgrade.spec.ts b/generators/upgrade/upgrade.spec.ts index b17717fb25c9..8061a0ed7bc4 100644 --- a/generators/upgrade/upgrade.spec.ts +++ b/generators/upgrade/upgrade.spec.ts @@ -24,7 +24,11 @@ describe('generator - upgrade', function () { baseName: 'upgradeTest', }) .withOptions({ useVersionPlaceholders: false }); - await runResult.create(getGenerator(GENERATOR_UPGRADE)).withSpawnMock().withOptions({ useVersionPlaceholders: false }).run(); + await runResult + .create(getGenerator(GENERATOR_UPGRADE)) + .withSpawnMock() + .withOptions({ useVersionPlaceholders: false } as any) + .run(); }); it('generated git commits to match snapshot', () => { diff --git a/testing/helpers.ts b/testing/helpers.ts index 187f2e6c9d4e..a1f06d385692 100644 --- a/testing/helpers.ts +++ b/testing/helpers.ts @@ -15,12 +15,13 @@ import BaseGenerator from '../generators/base/index.js'; import type { JHipsterGeneratorOptions } from '../generators/base/api.js'; import { getPackageRoot, isDistFolder } from '../lib/index.js'; import type { JSONEntity } from '../jdl/converters/types.js'; +import CoreGenerator from '../generators/base-core/generator.js'; type BaseEntity = { name: string } & JSONEntity; type GeneratorTestType = YeomanGenerator; type GeneratorTestOptions = JHipsterGeneratorOptions; -type JHipsterRunResult = RunResult & { +type JHipsterRunResult = RunResult & { /** * First argument of mocked source calls. */ diff --git a/tsconfig.spec.json b/tsconfig.spec.json index 68e758248cdc..78ff50dcc4f4 100644 --- a/tsconfig.spec.json +++ b/tsconfig.spec.json @@ -1,6 +1,15 @@ { "include": ["cli/**/*", "generators/**/*", "jdl/**/*", "lib/**/*", "testing/**/*"], - "exclude": ["generators/**/*.spec.*"], + "exclude": [ + "generators/base-application/*.spec.*", + "generators/base-core/*.spec.*", + "generators/base/**/*.spec.*", + "generators/base-application/*.spec.*", + "generators/bootstrap-application/*.spec.*", + "generators/bootstrap-application-base/*.spec.*", + "generators/java/generators/domain/*.spec.*", + "generators/server/support/needles.spec.ts" + ], "extends": "./tsconfig.json", "compilerOptions": { "noEmit": true,