From 4e3a240893a8295c7cc6c0bd5b3a2229ad39dd46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20My=C5=9Bliwiec?= Date: Mon, 8 Jan 2024 09:42:02 +0100 Subject: [PATCH] test: update unit tests (devkit breaking change) --- .../application/application.factory.test.ts | 615 ++++++++++-------- src/lib/class/class.factory.test.ts | 49 +- .../configuration.factory.test.ts | 32 +- src/lib/controller/controller.factory.test.ts | 65 +- src/lib/decorator/decorator.factory.test.ts | 35 +- src/lib/filter/filter.factory.test.ts | 56 +- src/lib/gateway/gateway.factory.test.ts | 45 +- src/lib/guard/guard.factory.test.ts | 45 +- .../interceptor/interceptor.factory.test.ts | 72 +- src/lib/interface/interface.factory.test.ts | 30 +- src/lib/library/library.factory.test.ts | 20 +- src/lib/middleware/middleware.factory.test.ts | 45 +- src/lib/module/module.factory.test.ts | 61 +- src/lib/pipe/pipe.factory.test.ts | 45 +- src/lib/provider/provider.factory.test.ts | 73 +-- src/lib/resolver/resolver.factory.test.ts | 45 +- src/lib/resource/resource.factory.test.ts | 90 +-- src/lib/service/service.factory.test.ts | 61 +- src/lib/sub-app/sub-app.factory.test.ts | 163 ++--- 19 files changed, 781 insertions(+), 866 deletions(-) diff --git a/src/lib/application/application.factory.test.ts b/src/lib/application/application.factory.test.ts index 1a99cc891..8ba98eced 100644 --- a/src/lib/application/application.factory.test.ts +++ b/src/lib/application/application.factory.test.ts @@ -15,27 +15,31 @@ describe('Application Factory', () => { const options: ApplicationOptions = { name: 'project', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/project/.eslintrc.js', - '/project/.gitignore', - '/project/.prettierrc', - '/project/README.md', - '/project/nest-cli.json', - '/project/package.json', - '/project/tsconfig.build.json', - '/project/tsconfig.json', - '/project/src/app.controller.spec.ts', - '/project/src/app.controller.ts', - '/project/src/app.module.ts', - '/project/src/app.service.ts', - '/project/src/main.ts', - '/project/test/app.e2e-spec.ts', - '/project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/project/.eslintrc.js', + '/project/.gitignore', + '/project/.prettierrc', + '/project/README.md', + '/project/nest-cli.json', + '/project/package.json', + '/project/tsconfig.build.json', + '/project/tsconfig.json', + '/project/src/app.controller.spec.ts', + '/project/src/app.controller.ts', + '/project/src/app.module.ts', + '/project/src/app.service.ts', + '/project/src/main.ts', + '/project/test/app.e2e-spec.ts', + '/project/test/jest-e2e.json', + ].sort(), + ); expect( JSON.parse(tree.readContent('/project/package.json')), @@ -47,27 +51,30 @@ describe('Application Factory', () => { const options: ApplicationOptions = { name: 'project.foo.bar', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); const files: string[] = tree.files; - expect(files.sort()).toEqual([ - `/project.foo.bar/.eslintrc.js`, - `/project.foo.bar/.gitignore`, - `/project.foo.bar/.prettierrc`, - `/project.foo.bar/README.md`, - `/project.foo.bar/nest-cli.json`, - `/project.foo.bar/package.json`, - `/project.foo.bar/tsconfig.build.json`, - `/project.foo.bar/tsconfig.json`, - `/project.foo.bar/src/app.controller.spec.ts`, - `/project.foo.bar/src/app.controller.ts`, - `/project.foo.bar/src/app.module.ts`, - `/project.foo.bar/src/app.service.ts`, - `/project.foo.bar/src/main.ts`, - `/project.foo.bar/test/app.e2e-spec.ts`, - `/project.foo.bar/test/jest-e2e.json`, - ].sort()); + expect(files.sort()).toEqual( + [ + `/project.foo.bar/.eslintrc.js`, + `/project.foo.bar/.gitignore`, + `/project.foo.bar/.prettierrc`, + `/project.foo.bar/README.md`, + `/project.foo.bar/nest-cli.json`, + `/project.foo.bar/package.json`, + `/project.foo.bar/tsconfig.build.json`, + `/project.foo.bar/tsconfig.json`, + `/project.foo.bar/src/app.controller.spec.ts`, + `/project.foo.bar/src/app.controller.ts`, + `/project.foo.bar/src/app.module.ts`, + `/project.foo.bar/src/app.service.ts`, + `/project.foo.bar/src/main.ts`, + `/project.foo.bar/test/app.e2e-spec.ts`, + `/project.foo.bar/test/jest-e2e.json`, + ].sort(), + ); expect( JSON.parse(tree.readContent('/project.foo.bar/package.json')), @@ -79,27 +86,30 @@ describe('Application Factory', () => { const options: ApplicationOptions = { name: 'awesomeProject', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/awesome-project/.eslintrc.js', - '/awesome-project/.gitignore', - '/awesome-project/.prettierrc', - '/awesome-project/README.md', - '/awesome-project/nest-cli.json', - '/awesome-project/package.json', - '/awesome-project/tsconfig.build.json', - '/awesome-project/tsconfig.json', - '/awesome-project/src/app.controller.spec.ts', - '/awesome-project/src/app.controller.ts', - '/awesome-project/src/app.module.ts', - '/awesome-project/src/app.service.ts', - '/awesome-project/src/main.ts', - '/awesome-project/test/app.e2e-spec.ts', - '/awesome-project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/awesome-project/.eslintrc.js', + '/awesome-project/.gitignore', + '/awesome-project/.prettierrc', + '/awesome-project/README.md', + '/awesome-project/nest-cli.json', + '/awesome-project/package.json', + '/awesome-project/tsconfig.build.json', + '/awesome-project/tsconfig.json', + '/awesome-project/src/app.controller.spec.ts', + '/awesome-project/src/app.controller.ts', + '/awesome-project/src/app.module.ts', + '/awesome-project/src/app.service.ts', + '/awesome-project/src/main.ts', + '/awesome-project/test/app.e2e-spec.ts', + '/awesome-project/test/jest-e2e.json', + ].sort(), + ); expect( JSON.parse(tree.readContent('/awesome-project/package.json')), @@ -111,27 +121,30 @@ describe('Application Factory', () => { const options: ApplicationOptions = { name: '_awesomeProject', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/_awesome-project/.eslintrc.js', - '/_awesome-project/.gitignore', - '/_awesome-project/.prettierrc', - '/_awesome-project/README.md', - '/_awesome-project/nest-cli.json', - '/_awesome-project/package.json', - '/_awesome-project/tsconfig.build.json', - '/_awesome-project/tsconfig.json', - '/_awesome-project/src/app.controller.spec.ts', - '/_awesome-project/src/app.controller.ts', - '/_awesome-project/src/app.module.ts', - '/_awesome-project/src/app.service.ts', - '/_awesome-project/src/main.ts', - '/_awesome-project/test/app.e2e-spec.ts', - '/_awesome-project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/_awesome-project/.eslintrc.js', + '/_awesome-project/.gitignore', + '/_awesome-project/.prettierrc', + '/_awesome-project/README.md', + '/_awesome-project/nest-cli.json', + '/_awesome-project/package.json', + '/_awesome-project/tsconfig.build.json', + '/_awesome-project/tsconfig.json', + '/_awesome-project/src/app.controller.spec.ts', + '/_awesome-project/src/app.controller.ts', + '/_awesome-project/src/app.module.ts', + '/_awesome-project/src/app.service.ts', + '/_awesome-project/src/main.ts', + '/_awesome-project/test/app.e2e-spec.ts', + '/_awesome-project/test/jest-e2e.json', + ].sort(), + ); expect( JSON.parse(tree.readContent('/_awesome-project/package.json')), @@ -143,27 +156,30 @@ describe('Application Factory', () => { const options: ApplicationOptions = { name: '@/package', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/@/package/.eslintrc.js', - '/@/package/.gitignore', - '/@/package/.prettierrc', - '/@/package/README.md', - '/@/package/nest-cli.json', - '/@/package/package.json', - '/@/package/tsconfig.build.json', - '/@/package/tsconfig.json', - '/@/package/src/app.controller.spec.ts', - '/@/package/src/app.controller.ts', - '/@/package/src/app.module.ts', - '/@/package/src/app.service.ts', - '/@/package/src/main.ts', - '/@/package/test/app.e2e-spec.ts', - '/@/package/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/@/package/.eslintrc.js', + '/@/package/.gitignore', + '/@/package/.prettierrc', + '/@/package/README.md', + '/@/package/nest-cli.json', + '/@/package/package.json', + '/@/package/tsconfig.build.json', + '/@/package/tsconfig.json', + '/@/package/src/app.controller.spec.ts', + '/@/package/src/app.controller.ts', + '/@/package/src/app.module.ts', + '/@/package/src/app.service.ts', + '/@/package/src/main.ts', + '/@/package/test/app.e2e-spec.ts', + '/@/package/test/jest-e2e.json', + ].sort(), + ); expect( JSON.parse(tree.readContent('/@/package/package.json')), @@ -175,27 +191,30 @@ describe('Application Factory', () => { const options: ApplicationOptions = { name: '.', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/.eslintrc.js', - '/.gitignore', - '/.prettierrc', - '/README.md', - '/nest-cli.json', - '/package.json', - '/tsconfig.build.json', - '/tsconfig.json', - '/src/app.controller.spec.ts', - '/src/app.controller.ts', - '/src/app.module.ts', - '/src/app.service.ts', - '/src/main.ts', - '/test/app.e2e-spec.ts', - '/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/.eslintrc.js', + '/.gitignore', + '/.prettierrc', + '/README.md', + '/nest-cli.json', + '/package.json', + '/tsconfig.build.json', + '/tsconfig.json', + '/src/app.controller.spec.ts', + '/src/app.controller.ts', + '/src/app.module.ts', + '/src/app.service.ts', + '/src/main.ts', + '/test/app.e2e-spec.ts', + '/test/jest-e2e.json', + ].sort(), + ); expect(JSON.parse(tree.readContent('/package.json'))).toMatchObject({ name: path.basename(process.cwd()), @@ -207,27 +226,30 @@ describe('Application Factory', () => { const options: ApplicationOptions = { name: '@scope/package', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/@scope/package/.eslintrc.js', - '/@scope/package/.gitignore', - '/@scope/package/.prettierrc', - '/@scope/package/README.md', - '/@scope/package/nest-cli.json', - '/@scope/package/package.json', - '/@scope/package/tsconfig.build.json', - '/@scope/package/tsconfig.json', - '/@scope/package/src/app.controller.spec.ts', - '/@scope/package/src/app.controller.ts', - '/@scope/package/src/app.module.ts', - '/@scope/package/src/app.service.ts', - '/@scope/package/src/main.ts', - '/@scope/package/test/app.e2e-spec.ts', - '/@scope/package/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/@scope/package/.eslintrc.js', + '/@scope/package/.gitignore', + '/@scope/package/.prettierrc', + '/@scope/package/README.md', + '/@scope/package/nest-cli.json', + '/@scope/package/package.json', + '/@scope/package/tsconfig.build.json', + '/@scope/package/tsconfig.json', + '/@scope/package/src/app.controller.spec.ts', + '/@scope/package/src/app.controller.ts', + '/@scope/package/src/app.module.ts', + '/@scope/package/src/app.service.ts', + '/@scope/package/src/main.ts', + '/@scope/package/test/app.e2e-spec.ts', + '/@scope/package/test/jest-e2e.json', + ].sort(), + ); expect( JSON.parse(tree.readContent('/@scope/package/package.json')), @@ -239,27 +261,30 @@ describe('Application Factory', () => { const options: ApplicationOptions = { name: '@ /package', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/@-/package/.eslintrc.js', - '/@-/package/.gitignore', - '/@-/package/.prettierrc', - '/@-/package/README.md', - '/@-/package/nest-cli.json', - '/@-/package/package.json', - '/@-/package/tsconfig.build.json', - '/@-/package/tsconfig.json', - '/@-/package/src/app.controller.spec.ts', - '/@-/package/src/app.controller.ts', - '/@-/package/src/app.module.ts', - '/@-/package/src/app.service.ts', - '/@-/package/src/main.ts', - '/@-/package/test/app.e2e-spec.ts', - '/@-/package/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/@-/package/.eslintrc.js', + '/@-/package/.gitignore', + '/@-/package/.prettierrc', + '/@-/package/README.md', + '/@-/package/nest-cli.json', + '/@-/package/package.json', + '/@-/package/tsconfig.build.json', + '/@-/package/tsconfig.json', + '/@-/package/src/app.controller.spec.ts', + '/@-/package/src/app.controller.ts', + '/@-/package/src/app.module.ts', + '/@-/package/src/app.service.ts', + '/@-/package/src/main.ts', + '/@-/package/test/app.e2e-spec.ts', + '/@-/package/test/jest-e2e.json', + ].sort(), + ); expect( JSON.parse(tree.readContent('/@-/package/package.json')), @@ -274,31 +299,33 @@ describe('Application Factory', () => { const options: ApplicationOptions = { name: 123, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/123/.eslintrc.js', - '/123/.gitignore', - '/123/.prettierrc', - '/123/README.md', - '/123/nest-cli.json', - '/123/package.json', - '/123/tsconfig.build.json', - '/123/tsconfig.json', - '/123/src/app.controller.spec.ts', - '/123/src/app.controller.ts', - '/123/src/app.module.ts', - '/123/src/app.service.ts', - '/123/src/main.ts', - '/123/test/app.e2e-spec.ts', - '/123/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/123/.eslintrc.js', + '/123/.gitignore', + '/123/.prettierrc', + '/123/README.md', + '/123/nest-cli.json', + '/123/package.json', + '/123/tsconfig.build.json', + '/123/tsconfig.json', + '/123/src/app.controller.spec.ts', + '/123/src/app.controller.ts', + '/123/src/app.module.ts', + '/123/src/app.service.ts', + '/123/src/main.ts', + '/123/test/app.e2e-spec.ts', + '/123/test/jest-e2e.json', + ].sort(), + ); - expect( - JSON.parse(tree.readContent('/123/package.json')), - ).toMatchObject({ + expect(JSON.parse(tree.readContent('/123/package.json'))).toMatchObject({ name: '123', }); }); @@ -307,28 +334,32 @@ describe('Application Factory', () => { name: 'project', language: 'js', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/project/.babelrc', - '/project/.gitignore', - '/project/.prettierrc', - '/project/README.md', - '/project/index.js', - '/project/jsconfig.json', - '/project/nest-cli.json', - '/project/nodemon.json', - '/project/package.json', - '/project/src/app.controller.js', - '/project/src/app.controller.spec.js', - '/project/src/app.module.js', - '/project/src/app.service.js', - '/project/src/main.js', - '/project/test/app.e2e-spec.js', - '/project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/project/.babelrc', + '/project/.gitignore', + '/project/.prettierrc', + '/project/README.md', + '/project/index.js', + '/project/jsconfig.json', + '/project/nest-cli.json', + '/project/nodemon.json', + '/project/package.json', + '/project/src/app.controller.js', + '/project/src/app.controller.spec.js', + '/project/src/app.module.js', + '/project/src/app.service.js', + '/project/src/main.js', + '/project/test/app.e2e-spec.js', + '/project/test/jest-e2e.json', + ].sort(), + ); expect(JSON.parse(tree.readContent('/project/package.json'))).toMatchObject( { @@ -341,27 +372,31 @@ describe('Application Factory', () => { name: 'project', directory: 'app', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/app/.eslintrc.js', - '/app/.gitignore', - '/app/.prettierrc', - '/app/README.md', - '/app/nest-cli.json', - '/app/package.json', - '/app/tsconfig.build.json', - '/app/tsconfig.json', - '/app/src/app.controller.spec.ts', - '/app/src/app.controller.ts', - '/app/src/app.module.ts', - '/app/src/app.service.ts', - '/app/src/main.ts', - '/app/test/app.e2e-spec.ts', - '/app/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/app/.eslintrc.js', + '/app/.gitignore', + '/app/.prettierrc', + '/app/README.md', + '/app/nest-cli.json', + '/app/package.json', + '/app/tsconfig.build.json', + '/app/tsconfig.json', + '/app/src/app.controller.spec.ts', + '/app/src/app.controller.ts', + '/app/src/app.module.ts', + '/app/src/app.service.ts', + '/app/src/main.ts', + '/app/test/app.e2e-spec.ts', + '/app/test/jest-e2e.json', + ].sort(), + ); expect(JSON.parse(tree.readContent('/app/package.json'))).toMatchObject({ name: 'project', @@ -373,26 +408,30 @@ describe('Application Factory', () => { spec: false, language: 'js', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/project/.babelrc', - '/project/.gitignore', - '/project/.prettierrc', - '/project/README.md', - '/project/index.js', - '/project/jsconfig.json', - '/project/nest-cli.json', - '/project/nodemon.json', - '/project/package.json', - '/project/src/app.controller.js', - '/project/src/app.module.js', - '/project/src/app.service.js', - '/project/src/main.js', - '/project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/project/.babelrc', + '/project/.gitignore', + '/project/.prettierrc', + '/project/README.md', + '/project/index.js', + '/project/jsconfig.json', + '/project/nest-cli.json', + '/project/nodemon.json', + '/project/package.json', + '/project/src/app.controller.js', + '/project/src/app.module.js', + '/project/src/app.service.js', + '/project/src/main.js', + '/project/test/jest-e2e.json', + ].sort(), + ); }); it('should create a spec file', async () => { const options: ApplicationOptions = { @@ -400,28 +439,32 @@ describe('Application Factory', () => { spec: true, language: 'js', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/project/.babelrc', - '/project/.gitignore', - '/project/.prettierrc', - '/project/README.md', - '/project/index.js', - '/project/jsconfig.json', - '/project/nest-cli.json', - '/project/nodemon.json', - '/project/package.json', - '/project/src/app.controller.js', - '/project/src/app.controller.spec.js', - '/project/src/app.module.js', - '/project/src/app.service.js', - '/project/src/main.js', - '/project/test/app.e2e-spec.js', - '/project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/project/.babelrc', + '/project/.gitignore', + '/project/.prettierrc', + '/project/README.md', + '/project/index.js', + '/project/jsconfig.json', + '/project/nest-cli.json', + '/project/nodemon.json', + '/project/package.json', + '/project/src/app.controller.js', + '/project/src/app.controller.spec.js', + '/project/src/app.module.js', + '/project/src/app.service.js', + '/project/src/main.js', + '/project/test/app.e2e-spec.js', + '/project/test/jest-e2e.json', + ].sort(), + ); }); it('should create a spec file with custom file suffix', async () => { const options: ApplicationOptions = { @@ -429,26 +472,30 @@ describe('Application Factory', () => { spec: true, specFileSuffix: 'test', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('application', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'application', + options, + ); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/project/.eslintrc.js', - '/project/.gitignore', - '/project/.prettierrc', - '/project/README.md', - '/project/nest-cli.json', - '/project/package.json', - '/project/tsconfig.build.json', - '/project/tsconfig.json', - '/project/src/app.controller.test.ts', - '/project/src/app.controller.ts', - '/project/src/app.module.ts', - '/project/src/app.service.ts', - '/project/src/main.ts', - '/project/test/app.e2e-test.ts', - '/project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/project/.eslintrc.js', + '/project/.gitignore', + '/project/.prettierrc', + '/project/README.md', + '/project/nest-cli.json', + '/project/package.json', + '/project/tsconfig.build.json', + '/project/tsconfig.json', + '/project/src/app.controller.test.ts', + '/project/src/app.controller.ts', + '/project/src/app.module.ts', + '/project/src/app.service.ts', + '/project/src/main.ts', + '/project/test/app.e2e-test.ts', + '/project/test/jest-e2e.json', + ].sort(), + ); }); }); diff --git a/src/lib/class/class.factory.test.ts b/src/lib/class/class.factory.test.ts index e3c72985b..e2f3985da 100644 --- a/src/lib/class/class.factory.test.ts +++ b/src/lib/class/class.factory.test.ts @@ -16,9 +16,8 @@ describe('Class Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('class', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('class', options); + const files: string[] = tree.files; expect( @@ -32,9 +31,8 @@ describe('Class Factory', () => { flat: false, spec: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('class', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('class', options); + const files: string[] = tree.files; expect( @@ -51,9 +49,8 @@ describe('Class Factory', () => { flat: false, spec: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('class', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('class', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/baz/foo/foo.ts'), @@ -68,9 +65,8 @@ describe('Class Factory', () => { flat: false, spec: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('class', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('class', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_foo-bar/_foo-bar.ts'), @@ -85,9 +81,8 @@ describe('Class Factory', () => { spec: false, flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('class', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('class', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/_foo/_foo.ts'), @@ -103,9 +98,8 @@ describe('Class Factory', () => { flat: false, spec: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('class', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('class', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.js'), @@ -118,9 +112,8 @@ describe('Class Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('class', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('class', options); + const files: string[] = tree.files; expect( @@ -136,9 +129,8 @@ describe('Class Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('class', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('class', options); + const files: string[] = tree.files; expect( @@ -152,16 +144,13 @@ describe('Class Factory', () => { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('class', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('class', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.spec.ts'), ).toBeUndefined(); - expect( - files.find((filename) => filename === '/foo.test.ts'), - ).toBeDefined(); + expect(files.find((filename) => filename === '/foo.test.ts')).toBeDefined(); }); }); diff --git a/src/lib/configuration/configuration.factory.test.ts b/src/lib/configuration/configuration.factory.test.ts index 8cf7be3cf..c92a4ea4c 100644 --- a/src/lib/configuration/configuration.factory.test.ts +++ b/src/lib/configuration/configuration.factory.test.ts @@ -14,10 +14,14 @@ describe('Configuration Factory', () => { const options: ConfigurationOptions = { project: undefined, }; - const tree: UnitTestTree = await runner.runSchematicAsync('configuration', options).toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'configuration', + options, + ); + const files: string[] = tree.files; expect( - files.find(filename => filename === '/nest-cli.json'), + files.find((filename) => filename === '/nest-cli.json'), ).not.toBeUndefined(); expect(JSON.parse(tree.readContent('/nest-cli.json'))).toEqual({ $schema: 'https://json.schemastore.org/nest-cli', @@ -29,10 +33,14 @@ describe('Configuration Factory', () => { const options: ConfigurationOptions = { project: 'project', }; - const tree: UnitTestTree = await runner.runSchematicAsync('configuration', options).toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'configuration', + options, + ); + const files: string[] = tree.files; expect( - files.find(filename => filename === '/project/nest-cli.json'), + files.find((filename) => filename === '/project/nest-cli.json'), ).not.toBeUndefined(); expect(JSON.parse(tree.readContent('/project/nest-cli.json'))).toEqual({ $schema: 'https://json.schemastore.org/nest-cli', @@ -45,10 +53,14 @@ describe('Configuration Factory', () => { project: 'project', language: 'js', }; - const tree: UnitTestTree = await runner.runSchematicAsync('configuration', options).toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'configuration', + options, + ); + const files: string[] = tree.files; expect( - files.find(filename => filename === '/project/nest-cli.json'), + files.find((filename) => filename === '/project/nest-cli.json'), ).not.toBeUndefined(); expect(JSON.parse(tree.readContent('/project/nest-cli.json'))).toEqual({ $schema: 'https://json.schemastore.org/nest-cli', @@ -62,10 +74,14 @@ describe('Configuration Factory', () => { project: 'project', collection: 'foo', }; - const tree: UnitTestTree = await runner.runSchematicAsync('configuration', options).toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'configuration', + options, + ); + const files: string[] = tree.files; expect( - files.find(filename => filename === '/project/nest-cli.json'), + files.find((filename) => filename === '/project/nest-cli.json'), ).not.toBeUndefined(); expect(JSON.parse(tree.readContent('/project/nest-cli.json'))).toEqual({ $schema: 'https://json.schemastore.org/nest-cli', diff --git a/src/lib/controller/controller.factory.test.ts b/src/lib/controller/controller.factory.test.ts index 5e85119d4..31c71c973 100644 --- a/src/lib/controller/controller.factory.test.ts +++ b/src/lib/controller/controller.factory.test.ts @@ -20,9 +20,8 @@ describe('Controller Factory', () => { spec: false, flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('controller', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('controller', options); + const files: string[] = tree.files; expect( @@ -43,9 +42,8 @@ describe('Controller Factory', () => { name: 'bar/foo', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('controller', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('controller', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo/foo.controller.ts'), @@ -66,9 +64,8 @@ describe('Controller Factory', () => { path: 'bar', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('controller', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('controller', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo/foo.controller.ts'), @@ -88,9 +85,8 @@ describe('Controller Factory', () => { name: 'fooBar', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('controller', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('controller', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar/foo-bar.controller.ts'), @@ -112,9 +108,8 @@ describe('Controller Factory', () => { name: '_bar/foo', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('controller', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('controller', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_bar/foo/foo.controller.ts'), @@ -134,9 +129,8 @@ describe('Controller Factory', () => { name: 'barBaz/foo', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('controller', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('controller', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo/foo.controller.ts'), @@ -159,9 +153,8 @@ describe('Controller Factory', () => { language: 'js', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('controller', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('controller', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.controller.js'), @@ -180,15 +173,12 @@ describe('Controller Factory', () => { const app: ApplicationOptions = { name: '', }; - let tree: UnitTestTree = await runner - .runSchematicAsync('application', app) - .toPromise(); + let tree: UnitTestTree = await runner.runSchematic('application', app); + const options: ControllerOptions = { name: 'foo', }; - tree = await runner - .runSchematicAsync('controller', options, tree) - .toPromise(); + tree = await runner.runSchematic('controller', options, tree); expect(tree.readContent(normalize('/src/app.module.ts'))).toEqual( "import { Module } from '@nestjs/common';\n" + "import { AppController } from './app.controller';\n" + @@ -207,19 +197,16 @@ describe('Controller Factory', () => { const app: ApplicationOptions = { name: '', }; - let tree: UnitTestTree = await runner - .runSchematicAsync('application', app) - .toPromise(); + let tree: UnitTestTree = await runner.runSchematic('application', app); + const module: ModuleOptions = { name: 'foo', }; - tree = await runner.runSchematicAsync('module', module, tree).toPromise(); + tree = await runner.runSchematic('module', module, tree); const options: ControllerOptions = { name: 'foo', }; - tree = await runner - .runSchematicAsync('controller', options, tree) - .toPromise(); + tree = await runner.runSchematic('controller', options, tree); expect(tree.readContent(normalize('/src/foo/foo.module.ts'))).toEqual( "import { Module } from '@nestjs/common';\n" + "import { FooController } from './foo.controller';\n" + @@ -236,9 +223,8 @@ describe('Controller Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('controller', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('controller', options); + const files: string[] = tree.files; expect( @@ -252,9 +238,8 @@ describe('Controller Factory', () => { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('controller', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('controller', options); + const files: string[] = tree.files; expect( diff --git a/src/lib/decorator/decorator.factory.test.ts b/src/lib/decorator/decorator.factory.test.ts index 6462ee345..503110b68 100644 --- a/src/lib/decorator/decorator.factory.test.ts +++ b/src/lib/decorator/decorator.factory.test.ts @@ -15,9 +15,8 @@ describe('Decorator Factory', () => { name: 'foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('decorator', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('decorator', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.decorator.ts'), @@ -33,9 +32,8 @@ describe('Decorator Factory', () => { name: 'bar/foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('decorator', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('decorator', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo/foo.decorator.ts'), @@ -52,9 +50,8 @@ describe('Decorator Factory', () => { path: 'baz', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('decorator', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('decorator', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/baz/foo/foo.decorator.ts'), @@ -70,9 +67,8 @@ describe('Decorator Factory', () => { name: 'fooBar', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('decorator', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('decorator', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar/foo-bar.decorator.ts'), @@ -88,9 +84,8 @@ describe('Decorator Factory', () => { name: 'barBaz/foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('decorator', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('decorator', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo/foo.decorator.ts'), @@ -106,9 +101,8 @@ describe('Decorator Factory', () => { name: '_bar/_foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('decorator', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('decorator', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_bar/_foo/_foo.decorator.ts'), @@ -125,9 +119,8 @@ describe('Decorator Factory', () => { language: 'js', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('decorator', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('decorator', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.decorator.js'), diff --git a/src/lib/filter/filter.factory.test.ts b/src/lib/filter/filter.factory.test.ts index cf50534c5..d62b1de9b 100644 --- a/src/lib/filter/filter.factory.test.ts +++ b/src/lib/filter/filter.factory.test.ts @@ -15,9 +15,8 @@ describe('Filter Factory', () => { const options: FilterOptions = { name: 'foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('filter', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('filter', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.filter.ts'), @@ -36,9 +35,8 @@ describe('Filter Factory', () => { const options: FilterOptions = { name: 'bar/foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('filter', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('filter', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo.filter.ts'), @@ -58,9 +56,8 @@ describe('Filter Factory', () => { name: 'foo', path: 'baz', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('filter', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('filter', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/baz/foo.filter.ts'), @@ -79,9 +76,8 @@ describe('Filter Factory', () => { const options: FilterOptions = { name: 'fooBar', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('filter', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('filter', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar.filter.ts'), @@ -100,9 +96,8 @@ describe('Filter Factory', () => { const options: FilterOptions = { name: '_foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('filter', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('filter', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_foo.filter.ts'), @@ -121,9 +116,8 @@ describe('Filter Factory', () => { const options: FilterOptions = { name: 'barBaz/foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('filter', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('filter', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo.filter.ts'), @@ -143,9 +137,8 @@ describe('Filter Factory', () => { name: 'foo', language: 'js', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('filter', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('filter', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.filter.js'), @@ -165,10 +158,11 @@ describe('Filter Factory', () => { name: 'foo', language: 'js', }; - let tree: UnitTestTree = await runner - .runSchematicAsync('application', { name: '' }) - .toPromise(); - tree = await runner.runSchematicAsync('filter', options, tree).toPromise(); + let tree: UnitTestTree = await runner.runSchematic('application', { + name: '', + }); + + tree = await runner.runSchematic('filter', options, tree); const files: string[] = tree.files; expect( @@ -183,15 +177,14 @@ describe('Filter Factory', () => { '}\n', ); }); - it('should create a spec file', async () => { + it('should create a spec file', async () => { const options: FilterOptions = { name: 'foo', spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('filter', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('filter', options); + const files: string[] = tree.files; expect( @@ -205,9 +198,8 @@ describe('Filter Factory', () => { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('filter', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('filter', options); + const files: string[] = tree.files; expect( diff --git a/src/lib/gateway/gateway.factory.test.ts b/src/lib/gateway/gateway.factory.test.ts index b9b525121..a1d43d9f2 100644 --- a/src/lib/gateway/gateway.factory.test.ts +++ b/src/lib/gateway/gateway.factory.test.ts @@ -15,9 +15,8 @@ describe('Gateway Factory', () => { name: 'foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('gateway', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('gateway', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.gateway.ts'), @@ -39,9 +38,8 @@ describe('Gateway Factory', () => { name: 'bar/foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('gateway', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('gateway', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo/foo.gateway.ts'), @@ -64,9 +62,8 @@ describe('Gateway Factory', () => { path: 'baz', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('gateway', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('gateway', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/baz/foo/foo.gateway.ts'), @@ -88,9 +85,8 @@ describe('Gateway Factory', () => { name: 'fooBar', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('gateway', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('gateway', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar/foo-bar.gateway.ts'), @@ -112,9 +108,8 @@ describe('Gateway Factory', () => { name: '_foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('gateway', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('gateway', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_foo/_foo.gateway.ts'), @@ -136,9 +131,8 @@ describe('Gateway Factory', () => { name: 'barBaz/foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('gateway', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('gateway', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo/foo.gateway.ts'), @@ -161,9 +155,8 @@ describe('Gateway Factory', () => { language: 'js', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('gateway', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('gateway', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.gateway.js'), @@ -186,9 +179,8 @@ describe('Gateway Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('gateway', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('gateway', options); + const files: string[] = tree.files; expect( @@ -202,9 +194,8 @@ describe('Gateway Factory', () => { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('gateway', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('gateway', options); + const files: string[] = tree.files; expect( diff --git a/src/lib/guard/guard.factory.test.ts b/src/lib/guard/guard.factory.test.ts index ec15c4981..a6bbb6b56 100644 --- a/src/lib/guard/guard.factory.test.ts +++ b/src/lib/guard/guard.factory.test.ts @@ -15,9 +15,8 @@ describe('Guard Factory', () => { const options: GuardOptions = { name: 'foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('guard', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('guard', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.guard.ts'), @@ -41,9 +40,8 @@ describe('Guard Factory', () => { const options: GuardOptions = { name: 'bar/foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('guard', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('guard', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo.guard.ts'), @@ -68,9 +66,8 @@ describe('Guard Factory', () => { name: 'foo', path: 'baz', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('guard', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('guard', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/baz/foo.guard.ts'), @@ -94,9 +91,8 @@ describe('Guard Factory', () => { const options: GuardOptions = { name: 'fooBar', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('guard', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('guard', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar.guard.ts'), @@ -120,9 +116,8 @@ describe('Guard Factory', () => { const options: GuardOptions = { name: 'barBaz/foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('guard', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('guard', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo.guard.ts'), @@ -146,9 +141,8 @@ describe('Guard Factory', () => { const options: GuardOptions = { name: '_foo/_bar', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('guard', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('guard', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_foo/_bar.guard.ts'), @@ -173,9 +167,8 @@ describe('Guard Factory', () => { name: 'foo', language: 'js', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('guard', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('guard', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.guard.js'), @@ -197,9 +190,8 @@ describe('Guard Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('guard', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('guard', options); + const files: string[] = tree.files; expect( @@ -213,9 +205,8 @@ describe('Guard Factory', () => { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('guard', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('guard', options); + const files: string[] = tree.files; expect( diff --git a/src/lib/interceptor/interceptor.factory.test.ts b/src/lib/interceptor/interceptor.factory.test.ts index 58694d77a..56b9b3b64 100644 --- a/src/lib/interceptor/interceptor.factory.test.ts +++ b/src/lib/interceptor/interceptor.factory.test.ts @@ -15,9 +15,11 @@ describe('Interceptor Factory', () => { const options: InterceptorOptions = { name: 'foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interceptor', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'interceptor', + options, + ); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.interceptor.ts'), @@ -39,9 +41,11 @@ describe('Interceptor Factory', () => { const options: InterceptorOptions = { name: 'bar/foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interceptor', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'interceptor', + options, + ); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo.interceptor.ts'), @@ -64,9 +68,11 @@ describe('Interceptor Factory', () => { name: 'foo', path: 'baz', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interceptor', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'interceptor', + options, + ); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/baz/foo.interceptor.ts'), @@ -88,9 +94,11 @@ describe('Interceptor Factory', () => { const options: InterceptorOptions = { name: 'fooBar', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interceptor', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'interceptor', + options, + ); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar.interceptor.ts'), @@ -112,9 +120,11 @@ describe('Interceptor Factory', () => { const options: InterceptorOptions = { name: '_bar/_foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interceptor', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'interceptor', + options, + ); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_bar/_foo.interceptor.ts'), @@ -136,9 +146,11 @@ describe('Interceptor Factory', () => { const options: InterceptorOptions = { name: 'barBaz/foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interceptor', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'interceptor', + options, + ); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo.interceptor.ts'), @@ -161,9 +173,11 @@ describe('Interceptor Factory', () => { name: 'foo', language: 'js', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interceptor', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'interceptor', + options, + ); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.interceptor.js'), @@ -185,9 +199,11 @@ describe('Interceptor Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interceptor', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'interceptor', + options, + ); + const files: string[] = tree.files; expect( @@ -201,9 +217,11 @@ describe('Interceptor Factory', () => { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interceptor', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic( + 'interceptor', + options, + ); + const files: string[] = tree.files; expect( diff --git a/src/lib/interface/interface.factory.test.ts b/src/lib/interface/interface.factory.test.ts index 9e6da6039..d9bb536db 100644 --- a/src/lib/interface/interface.factory.test.ts +++ b/src/lib/interface/interface.factory.test.ts @@ -15,9 +15,8 @@ describe('Interface Factory', () => { const options: InterfaceOptions = { name: 'foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interface', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('interface', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.interface.ts'), @@ -31,9 +30,8 @@ describe('Interface Factory', () => { const options: InterfaceOptions = { name: 'bar/foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interface', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('interface', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo.interface.ts'), @@ -48,9 +46,8 @@ describe('Interface Factory', () => { name: 'foo', path: 'baz', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interface', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('interface', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/baz/foo.interface.ts'), @@ -64,9 +61,8 @@ describe('Interface Factory', () => { const options: InterfaceOptions = { name: 'fooBar', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interface', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('interface', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar.interface.ts'), @@ -80,9 +76,8 @@ describe('Interface Factory', () => { const options: InterfaceOptions = { name: 'barBaz/foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interface', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('interface', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo.interface.ts'), @@ -96,9 +91,8 @@ describe('Interface Factory', () => { const options: InterfaceOptions = { name: '_bar/_foo', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('interface', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('interface', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_bar/_foo.interface.ts'), diff --git a/src/lib/library/library.factory.test.ts b/src/lib/library/library.factory.test.ts index dab85e406..9f1257fe7 100644 --- a/src/lib/library/library.factory.test.ts +++ b/src/lib/library/library.factory.test.ts @@ -15,9 +15,8 @@ describe('Library Factory', () => { name: 'project', prefix: 'app', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('library', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('library', options); + const files: string[] = tree.files; expect(files).toEqual([ '/nest-cli.json', @@ -33,9 +32,8 @@ describe('Library Factory', () => { name: 'awesomeProject', prefix: 'app', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('library', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('library', options); + const files: string[] = tree.files; expect(files).toEqual([ '/nest-cli.json', @@ -51,9 +49,8 @@ describe('Library Factory', () => { name: '_project', prefix: 'app', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('library', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('library', options); + const files: string[] = tree.files; expect(files).toEqual([ '/nest-cli.json', @@ -70,9 +67,8 @@ describe('Library Factory', () => { language: 'js', prefix: 'app', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('library', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('library', options); + const files: string[] = tree.files; expect(files).toEqual([ '/nest-cli.json', diff --git a/src/lib/middleware/middleware.factory.test.ts b/src/lib/middleware/middleware.factory.test.ts index 812200bcf..acd2600fc 100644 --- a/src/lib/middleware/middleware.factory.test.ts +++ b/src/lib/middleware/middleware.factory.test.ts @@ -15,9 +15,8 @@ describe('Middleware Factory', () => { name: 'foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('middleware', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('middleware', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.middleware.ts'), @@ -38,9 +37,8 @@ describe('Middleware Factory', () => { name: 'bar/foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('middleware', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('middleware', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo/foo.middleware.ts'), @@ -62,9 +60,8 @@ describe('Middleware Factory', () => { path: 'baz', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('middleware', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('middleware', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/baz/foo/foo.middleware.ts'), @@ -85,9 +82,8 @@ describe('Middleware Factory', () => { name: 'fooBar', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('middleware', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('middleware', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar/foo-bar.middleware.ts'), @@ -108,9 +104,8 @@ describe('Middleware Factory', () => { name: 'barBaz/foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('middleware', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('middleware', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo/foo.middleware.ts'), @@ -131,9 +126,8 @@ describe('Middleware Factory', () => { name: '_bar/_foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('middleware', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('middleware', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_bar/_foo/_foo.middleware.ts'), @@ -155,9 +149,8 @@ describe('Middleware Factory', () => { language: 'js', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('middleware', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('middleware', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.middleware.js'), @@ -179,9 +172,8 @@ describe('Middleware Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('middleware', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('middleware', options); + const files: string[] = tree.files; expect( @@ -195,9 +187,8 @@ describe('Middleware Factory', () => { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('middleware', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('middleware', options); + const files: string[] = tree.files; expect( diff --git a/src/lib/module/module.factory.test.ts b/src/lib/module/module.factory.test.ts index de256261e..7c6214861 100644 --- a/src/lib/module/module.factory.test.ts +++ b/src/lib/module/module.factory.test.ts @@ -17,9 +17,8 @@ describe('Module Factory', () => { name: 'foo', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('module', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('module', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.module.ts'), @@ -36,9 +35,8 @@ describe('Module Factory', () => { name: 'bar/foo', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('module', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('module', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo/foo.module.ts'), @@ -56,9 +54,8 @@ describe('Module Factory', () => { path: 'bar', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('module', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('module', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo/foo.module.ts'), @@ -75,9 +72,8 @@ describe('Module Factory', () => { name: 'fooBar', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('module', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('module', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar/foo-bar.module.ts'), @@ -95,9 +91,8 @@ describe('Module Factory', () => { path: 'bar', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('module', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('module', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo/foo.module.ts'), @@ -115,9 +110,8 @@ describe('Module Factory', () => { skipImport: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('module', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('module', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar.module.ts'), @@ -134,9 +128,8 @@ describe('Module Factory', () => { name: 'barBaz/foo', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('module', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('module', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo/foo.module.ts'), @@ -153,9 +146,8 @@ describe('Module Factory', () => { name: '_bar/_foo', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('module', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('module', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_bar/_foo/_foo.module.ts'), @@ -173,9 +165,8 @@ describe('Module Factory', () => { skipImport: true, language: 'js', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('module', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('module', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.module.js'), @@ -191,13 +182,12 @@ describe('Module Factory', () => { const app: ApplicationOptions = { name: '', }; - let tree: UnitTestTree = await runner - .runSchematicAsync('application', app) - .toPromise(); + let tree: UnitTestTree = await runner.runSchematic('application', app); + const options: ModuleOptions = { name: 'foo', }; - tree = await runner.runSchematicAsync('module', options, tree).toPromise(); + tree = await runner.runSchematic('module', options, tree); expect(tree.readContent(normalize('/src/app.module.ts'))).toEqual( "import { Module } from '@nestjs/common';\n" + "import { AppController } from './app.controller';\n" + @@ -216,17 +206,16 @@ describe('Module Factory', () => { const app: ApplicationOptions = { name: '', }; - let tree: UnitTestTree = await runner - .runSchematicAsync('application', app) - .toPromise(); + let tree: UnitTestTree = await runner.runSchematic('application', app); + const module: ModuleOptions = { name: 'bar', }; - tree = await runner.runSchematicAsync('module', module, tree).toPromise(); + tree = await runner.runSchematic('module', module, tree); const options: ModuleOptions = { name: 'bar/foo', }; - tree = await runner.runSchematicAsync('module', options, tree).toPromise(); + tree = await runner.runSchematic('module', options, tree); expect(tree.readContent(normalize('/src/bar/bar.module.ts'))).toEqual( "import { Module } from '@nestjs/common';\n" + "import { FooModule } from './foo/foo.module';\n" + diff --git a/src/lib/pipe/pipe.factory.test.ts b/src/lib/pipe/pipe.factory.test.ts index f50d3a929..36a5404c3 100644 --- a/src/lib/pipe/pipe.factory.test.ts +++ b/src/lib/pipe/pipe.factory.test.ts @@ -15,9 +15,8 @@ describe('Pipe Factory', () => { name: 'foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('pipe', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('pipe', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.pipe.ts'), @@ -38,9 +37,8 @@ describe('Pipe Factory', () => { name: 'bar/foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('pipe', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('pipe', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo/foo.pipe.ts'), @@ -62,9 +60,8 @@ describe('Pipe Factory', () => { path: 'baz', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('pipe', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('pipe', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/baz/foo/foo.pipe.ts'), @@ -85,9 +82,8 @@ describe('Pipe Factory', () => { name: 'fooBar', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('pipe', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('pipe', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar/foo-bar.pipe.ts'), @@ -108,9 +104,8 @@ describe('Pipe Factory', () => { name: 'barBaz/foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('pipe', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('pipe', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo/foo.pipe.ts'), @@ -132,9 +127,8 @@ describe('Pipe Factory', () => { name: '_bar/_foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('pipe', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('pipe', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_bar/_foo/_foo.pipe.ts'), @@ -157,9 +151,8 @@ describe('Pipe Factory', () => { language: 'js', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('pipe', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('pipe', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.pipe.js'), @@ -181,9 +174,8 @@ describe('Pipe Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('pipe', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('pipe', options); + const files: string[] = tree.files; expect( @@ -197,9 +189,8 @@ describe('Pipe Factory', () => { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('pipe', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('pipe', options); + const files: string[] = tree.files; expect( diff --git a/src/lib/provider/provider.factory.test.ts b/src/lib/provider/provider.factory.test.ts index 4af861155..3fc50d383 100644 --- a/src/lib/provider/provider.factory.test.ts +++ b/src/lib/provider/provider.factory.test.ts @@ -18,9 +18,8 @@ describe('Provider Factory', () => { name: 'foo', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('provider', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('provider', options); + const files: string[] = tree.files; expect(files.find((filename) => filename === '/foo.ts')).toBeDefined(); expect(files.find((filename) => filename === '/foo.spec.ts')).toBeDefined(); @@ -36,9 +35,8 @@ describe('Provider Factory', () => { name: 'bar/foo', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('provider', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('provider', options); + const files: string[] = tree.files; expect(files.find((filename) => filename === '/bar/foo.ts')).toBeDefined(); expect( @@ -57,9 +55,8 @@ describe('Provider Factory', () => { path: 'bar', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('provider', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('provider', options); + const files: string[] = tree.files; expect(files.find((filename) => filename === '/bar/foo.ts')).toBeDefined(); expect( @@ -77,9 +74,8 @@ describe('Provider Factory', () => { name: 'bar-foo', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('provider', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('provider', options); + const files: string[] = tree.files; expect(files.find((filename) => filename === '/bar-foo.ts')).toBeDefined(); expect( @@ -97,9 +93,8 @@ describe('Provider Factory', () => { name: '_bar', skipImport: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('provider', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('provider', options); + const files: string[] = tree.files; expect(files.find((filename) => filename === '/_bar.ts')).toBeDefined(); expect( @@ -118,9 +113,8 @@ describe('Provider Factory', () => { skipImport: true, language: 'js', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('provider', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('provider', options); + const files: string[] = tree.files; expect(files.find((filename) => filename === '/foo.js')).toBeDefined(); expect(files.find((filename) => filename === '/foo.spec.js')).toBeDefined(); @@ -135,15 +129,12 @@ describe('Provider Factory', () => { const app: ApplicationOptions = { name: '', }; - let tree: UnitTestTree = await runner - .runSchematicAsync('application', app) - .toPromise(); + let tree: UnitTestTree = await runner.runSchematic('application', app); + const options: ProviderOptions = { name: 'foo', }; - tree = await runner - .runSchematicAsync('provider', options, tree) - .toPromise(); + tree = await runner.runSchematic('provider', options, tree); expect(tree.readContent(normalize('/src/app.module.ts'))).toEqual( "import { Module } from '@nestjs/common';\n" + "import { AppController } from './app.controller';\n" + @@ -162,20 +153,17 @@ describe('Provider Factory', () => { const app: ApplicationOptions = { name: '', }; - let tree: UnitTestTree = await runner - .runSchematicAsync('application', app) - .toPromise(); + let tree: UnitTestTree = await runner.runSchematic('application', app); + const module: ModuleOptions = { name: 'foo', }; - tree = await runner.runSchematicAsync('module', module, tree).toPromise(); + tree = await runner.runSchematic('module', module, tree); const options: ProviderOptions = { name: 'foo', path: 'foo', }; - tree = await runner - .runSchematicAsync('provider', options, tree) - .toPromise(); + tree = await runner.runSchematic('provider', options, tree); expect(tree.readContent(normalize('/src/foo/foo.module.ts'))).toEqual( "import { Module } from '@nestjs/common';\n" + "import { Foo } from './foo';\n" + @@ -192,9 +180,8 @@ describe('Provider Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('provider', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('provider', options); + const files: string[] = tree.files; expect( @@ -212,14 +199,11 @@ export class FooEntity {}\n`); spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('provider', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('provider', options); + const files: string[] = tree.files; - expect( - files.find((filename) => filename === '/foo.spec.ts'), - ).toBeDefined(); + expect(files.find((filename) => filename === '/foo.spec.ts')).toBeDefined(); }); it('should create a spec file with custom file suffix', async () => { const options: ProviderOptions = { @@ -228,16 +212,13 @@ export class FooEntity {}\n`); specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('provider', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('provider', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.spec.ts'), ).toBeUndefined(); - expect( - files.find((filename) => filename === '/foo.test.ts'), - ).toBeDefined(); + expect(files.find((filename) => filename === '/foo.test.ts')).toBeDefined(); }); }); diff --git a/src/lib/resolver/resolver.factory.test.ts b/src/lib/resolver/resolver.factory.test.ts index 59dc55aa1..29beb5b26 100644 --- a/src/lib/resolver/resolver.factory.test.ts +++ b/src/lib/resolver/resolver.factory.test.ts @@ -15,9 +15,8 @@ describe('Resolver Factory', () => { name: 'foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resolver', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resolver', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.resolver.ts'), @@ -34,9 +33,8 @@ describe('Resolver Factory', () => { name: 'bar/foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resolver', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resolver', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo/foo.resolver.ts'), @@ -54,9 +52,8 @@ describe('Resolver Factory', () => { path: 'baz', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resolver', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resolver', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/baz/foo/foo.resolver.ts'), @@ -73,9 +70,8 @@ describe('Resolver Factory', () => { name: 'fooBar', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resolver', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resolver', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar/foo-bar.resolver.ts'), @@ -92,9 +88,8 @@ describe('Resolver Factory', () => { name: 'barBaz/foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resolver', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resolver', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo/foo.resolver.ts'), @@ -111,9 +106,8 @@ describe('Resolver Factory', () => { name: '_bar/_foo', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resolver', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resolver', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_bar/_foo/_foo.resolver.ts'), @@ -131,9 +125,8 @@ describe('Resolver Factory', () => { language: 'js', flat: false, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resolver', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resolver', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo/foo.resolver.js'), @@ -151,9 +144,8 @@ describe('Resolver Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resolver', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resolver', options); + const files: string[] = tree.files; expect( @@ -167,9 +159,8 @@ describe('Resolver Factory', () => { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resolver', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resolver', options); + const files: string[] = tree.files; expect( diff --git a/src/lib/resource/resource.factory.test.ts b/src/lib/resource/resource.factory.test.ts index 6e13cb7f4..11d9e4786 100644 --- a/src/lib/resource/resource.factory.test.ts +++ b/src/lib/resource/resource.factory.test.ts @@ -16,9 +16,7 @@ describe('Resource Factory', () => { const options: ResourceOptions = { name: 'users', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.controller.spec.ts', @@ -35,9 +33,7 @@ describe('Resource Factory', () => { const options: ResourceOptions = { name: '_users', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/_users/_users.controller.spec.ts', @@ -56,9 +52,7 @@ describe('Resource Factory', () => { name: 'users', crud: false, }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.controller.spec.ts', @@ -76,9 +70,7 @@ describe('Resource Factory', () => { spec: false, crud: false, }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.controller.ts', @@ -98,7 +90,7 @@ describe('Resource Factory', () => { let tree: UnitTestTree; beforeAll(async () => { - tree = await runner.runSchematicAsync('resource', options).toPromise(); + tree = await runner.runSchematic('resource', options); }); it('should generate "UsersController" class', () => { @@ -266,7 +258,7 @@ describe('UsersService', () => { let tree: UnitTestTree; beforeAll(async () => { - tree = await runner.runSchematicAsync('resource', options).toPromise(); + tree = await runner.runSchematic('resource', options); }); it('should generate "UsersController" class', () => { @@ -323,9 +315,7 @@ export class UsersModule {} name: 'users', type: 'microservice', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.controller.spec.ts', @@ -345,9 +335,7 @@ export class UsersModule {} crud: false, type: 'microservice', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.controller.spec.ts', @@ -366,9 +354,7 @@ export class UsersModule {} crud: false, type: 'microservice', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.controller.ts', @@ -388,7 +374,7 @@ export class UsersModule {} let tree: UnitTestTree; beforeAll(async () => { - tree = await runner.runSchematicAsync('resource', options).toPromise(); + tree = await runner.runSchematic('resource', options); }); it('should generate "UsersController" class', () => { @@ -560,7 +546,7 @@ describe('UsersService', () => { let tree: UnitTestTree; beforeAll(async () => { - tree = await runner.runSchematicAsync('resource', options).toPromise(); + tree = await runner.runSchematic('resource', options); }); it('should generate "UsersController" class', () => { @@ -617,9 +603,7 @@ export class UsersModule {} name: 'users', type: 'ws', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.gateway.spec.ts', @@ -639,9 +623,7 @@ export class UsersModule {} crud: false, type: 'ws', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.gateway.spec.ts', @@ -660,9 +642,7 @@ export class UsersModule {} crud: false, type: 'ws', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.gateway.ts', @@ -683,7 +663,7 @@ export class UsersModule {} let tree: UnitTestTree; beforeAll(async () => { - tree = await runner.runSchematicAsync('resource', options).toPromise(); + tree = await runner.runSchematic('resource', options); }); it('should generate "UsersGateway" class', () => { @@ -851,7 +831,7 @@ describe('UsersService', () => { let tree: UnitTestTree; beforeAll(async () => { - tree = await runner.runSchematicAsync('resource', options).toPromise(); + tree = await runner.runSchematic('resource', options); }); it('should generate "UsersGateway" class', () => { @@ -907,9 +887,7 @@ export class UsersModule {} crud: true, type: 'graphql-code-first', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.module.ts', @@ -929,9 +907,7 @@ export class UsersModule {} crud: false, type: 'graphql-code-first', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.module.ts', @@ -950,9 +926,7 @@ export class UsersModule {} crud: false, type: 'graphql-code-first', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.module.ts', @@ -972,7 +946,7 @@ export class UsersModule {} let tree: UnitTestTree; beforeAll(async () => { - tree = await runner.runSchematicAsync('resource', options).toPromise(); + tree = await runner.runSchematic('resource', options); }); it('should generate "UsersResolver" class', () => { @@ -1150,9 +1124,7 @@ describe('UsersService', () => { name: 'users', type: 'graphql-schema-first', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.graphql', @@ -1173,9 +1145,7 @@ describe('UsersService', () => { crud: false, type: 'graphql-schema-first', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.module.ts', @@ -1194,9 +1164,7 @@ describe('UsersService', () => { crud: false, type: 'graphql-schema-first', }; - const tree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree = await runner.runSchematic('resource', options); const files = tree.files; expect(files).toEqual([ '/users/users.module.ts', @@ -1215,7 +1183,7 @@ describe('UsersService', () => { let tree: UnitTestTree; beforeAll(async () => { - tree = await runner.runSchematicAsync('resource', options).toPromise(); + tree = await runner.runSchematic('resource', options); }); it('should generate "UsersResolver" class', () => { @@ -1405,9 +1373,8 @@ type Mutation { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resource', options); + const files: string[] = tree.files; expect( @@ -1424,9 +1391,8 @@ type Mutation { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('resource', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('resource', options); + const files: string[] = tree.files; expect( diff --git a/src/lib/service/service.factory.test.ts b/src/lib/service/service.factory.test.ts index 40911667a..d6f8f74c8 100644 --- a/src/lib/service/service.factory.test.ts +++ b/src/lib/service/service.factory.test.ts @@ -19,9 +19,8 @@ describe('Service Factory', () => { skipImport: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('service', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('service', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.service.ts'), @@ -42,9 +41,8 @@ describe('Service Factory', () => { skipImport: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('service', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('service', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo.service.ts'), @@ -66,9 +64,8 @@ describe('Service Factory', () => { skipImport: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('service', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('service', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar/foo.service.ts'), @@ -89,9 +86,8 @@ describe('Service Factory', () => { skipImport: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('service', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('service', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo-bar.service.ts'), @@ -109,9 +105,8 @@ describe('Service Factory', () => { skipImport: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('service', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('service', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/bar-baz/foo.service.ts'), @@ -132,9 +127,8 @@ describe('Service Factory', () => { skipImport: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('service', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('service', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/_bar/_foo.service.ts'), @@ -156,9 +150,8 @@ describe('Service Factory', () => { language: 'js', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('service', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('service', options); + const files: string[] = tree.files; expect( files.find((filename) => filename === '/foo.service.js'), @@ -177,14 +170,13 @@ describe('Service Factory', () => { const app: ApplicationOptions = { name: '', }; - let tree: UnitTestTree = await runner - .runSchematicAsync('application', app) - .toPromise(); + let tree: UnitTestTree = await runner.runSchematic('application', app); + const options: ServiceOptions = { name: 'foo', flat: true, }; - tree = await runner.runSchematicAsync('service', options, tree).toPromise(); + tree = await runner.runSchematic('service', options, tree); expect(tree.readContent(normalize('/src/app.module.ts'))).toEqual( "import { Module } from '@nestjs/common';\n" + "import { AppController } from './app.controller';\n" + @@ -203,19 +195,18 @@ describe('Service Factory', () => { const app: ApplicationOptions = { name: '', }; - let tree: UnitTestTree = await runner - .runSchematicAsync('application', app) - .toPromise(); + let tree: UnitTestTree = await runner.runSchematic('application', app); + const module: ModuleOptions = { name: 'foo', }; - tree = await runner.runSchematicAsync('module', module, tree).toPromise(); + tree = await runner.runSchematic('module', module, tree); const options: ServiceOptions = { name: 'foo', path: 'foo', flat: true, }; - tree = await runner.runSchematicAsync('service', options, tree).toPromise(); + tree = await runner.runSchematic('service', options, tree); expect(tree.readContent(normalize('/src/foo/foo.module.ts'))).toEqual( "import { Module } from '@nestjs/common';\n" + "import { FooService } from './foo.service';\n" + @@ -232,9 +223,8 @@ describe('Service Factory', () => { spec: true, flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('service', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('service', options); + const files: string[] = tree.files; expect( @@ -248,9 +238,8 @@ describe('Service Factory', () => { specFileSuffix: 'test', flat: true, }; - const tree: UnitTestTree = await runner - .runSchematicAsync('service', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('service', options); + const files: string[] = tree.files; expect( diff --git a/src/lib/sub-app/sub-app.factory.test.ts b/src/lib/sub-app/sub-app.factory.test.ts index f8d016e24..ad974d672 100644 --- a/src/lib/sub-app/sub-app.factory.test.ts +++ b/src/lib/sub-app/sub-app.factory.test.ts @@ -14,111 +14,116 @@ describe('SubApp Factory', () => { const options: SubAppOptions = { name: 'project', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('sub-app', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('sub-app', options); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/nest-cli.json', - '/apps/nestjs-schematics/tsconfig.app.json', - '/apps/project/tsconfig.app.json', - '/apps/project/src/main.ts', - '/apps/project/src/project.controller.spec.ts', - '/apps/project/src/project.controller.ts', - '/apps/project/src/project.module.ts', - '/apps/project/src/project.service.ts', - '/apps/project/test/app.e2e-spec.ts', - '/apps/project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/nest-cli.json', + '/apps/nestjs-schematics/tsconfig.app.json', + '/apps/project/tsconfig.app.json', + '/apps/project/src/main.ts', + '/apps/project/src/project.controller.spec.ts', + '/apps/project/src/project.controller.ts', + '/apps/project/src/project.module.ts', + '/apps/project/src/project.service.ts', + '/apps/project/test/app.e2e-spec.ts', + '/apps/project/test/jest-e2e.json', + ].sort(), + ); }); it('should manage name to normalize', async () => { const options: SubAppOptions = { name: 'awesomeProject', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('sub-app', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('sub-app', options); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/nest-cli.json', - '/apps/nestjs-schematics/tsconfig.app.json', - '/apps/awesome-project/tsconfig.app.json', - '/apps/awesome-project/src/main.ts', - '/apps/awesome-project/src/awesome-project.controller.spec.ts', - '/apps/awesome-project/src/awesome-project.controller.ts', - '/apps/awesome-project/src/awesome-project.module.ts', - '/apps/awesome-project/src/awesome-project.service.ts', - '/apps/awesome-project/test/app.e2e-spec.ts', - '/apps/awesome-project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/nest-cli.json', + '/apps/nestjs-schematics/tsconfig.app.json', + '/apps/awesome-project/tsconfig.app.json', + '/apps/awesome-project/src/main.ts', + '/apps/awesome-project/src/awesome-project.controller.spec.ts', + '/apps/awesome-project/src/awesome-project.controller.ts', + '/apps/awesome-project/src/awesome-project.module.ts', + '/apps/awesome-project/src/awesome-project.service.ts', + '/apps/awesome-project/test/app.e2e-spec.ts', + '/apps/awesome-project/test/jest-e2e.json', + ].sort(), + ); }); it("should keep underscores in sub-app's path and file name", async () => { const options: SubAppOptions = { name: '_project', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('sub-app', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('sub-app', options); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/nest-cli.json', - '/apps/nestjs-schematics/tsconfig.app.json', - '/apps/_project/tsconfig.app.json', - '/apps/_project/src/main.ts', - '/apps/_project/src/_project.controller.spec.ts', - '/apps/_project/src/_project.controller.ts', - '/apps/_project/src/_project.module.ts', - '/apps/_project/src/_project.service.ts', - '/apps/_project/test/app.e2e-spec.ts', - '/apps/_project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/nest-cli.json', + '/apps/nestjs-schematics/tsconfig.app.json', + '/apps/_project/tsconfig.app.json', + '/apps/_project/src/main.ts', + '/apps/_project/src/_project.controller.spec.ts', + '/apps/_project/src/_project.controller.ts', + '/apps/_project/src/_project.module.ts', + '/apps/_project/src/_project.service.ts', + '/apps/_project/test/app.e2e-spec.ts', + '/apps/_project/test/jest-e2e.json', + ].sort(), + ); }); it('should manage javascript files', async () => { const options: SubAppOptions = { name: 'project', language: 'js', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('sub-app', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('sub-app', options); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/nest-cli.json', - '/apps/nestjs-schematics/.babelrc', - '/apps/nestjs-schematics/index.js', - '/apps/nestjs-schematics/jsconfig.json', - '/apps/project/.babelrc', - '/apps/project/index.js', - '/apps/project/jsconfig.json', - '/apps/project/src/app.controller.js', - '/apps/project/src/app.controller.spec.js', - '/apps/project/src/app.module.js', - '/apps/project/src/app.service.js', - '/apps/project/src/main.js', - '/apps/project/test/app.e2e-spec.js', - '/apps/project/test/jest-e2e.json', - ].sort()); + expect(files.sort()).toEqual( + [ + '/nest-cli.json', + '/apps/nestjs-schematics/.babelrc', + '/apps/nestjs-schematics/index.js', + '/apps/nestjs-schematics/jsconfig.json', + '/apps/project/.babelrc', + '/apps/project/index.js', + '/apps/project/jsconfig.json', + '/apps/project/src/app.controller.js', + '/apps/project/src/app.controller.spec.js', + '/apps/project/src/app.module.js', + '/apps/project/src/app.service.js', + '/apps/project/src/main.js', + '/apps/project/test/app.e2e-spec.js', + '/apps/project/test/jest-e2e.json', + ].sort(), + ); }); it('should generate spec files with custom suffix', async () => { const options: SubAppOptions = { name: 'project', specFileSuffix: 'test', }; - const tree: UnitTestTree = await runner - .runSchematicAsync('sub-app', options) - .toPromise(); + const tree: UnitTestTree = await runner.runSchematic('sub-app', options); + const files: string[] = tree.files; - expect(files.sort()).toEqual([ - '/nest-cli.json', - '/apps/nestjs-schematics/tsconfig.app.json', - '/apps/project/tsconfig.app.json', - '/apps/project/src/main.ts', - '/apps/project/src/project.controller.test.ts', - '/apps/project/src/project.controller.ts', - '/apps/project/src/project.module.ts', - '/apps/project/src/project.service.ts', - '/apps/project/test/jest-e2e.json', - '/apps/project/test/app.e2e-test.ts', - ].sort()); + expect(files.sort()).toEqual( + [ + '/nest-cli.json', + '/apps/nestjs-schematics/tsconfig.app.json', + '/apps/project/tsconfig.app.json', + '/apps/project/src/main.ts', + '/apps/project/src/project.controller.test.ts', + '/apps/project/src/project.controller.ts', + '/apps/project/src/project.module.ts', + '/apps/project/src/project.service.ts', + '/apps/project/test/jest-e2e.json', + '/apps/project/test/app.e2e-test.ts', + ].sort(), + ); }); });