From 534514f57dcdfca7f16cda2fbd0cc962eeb7e503 Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Sat, 14 Dec 2024 21:04:16 -0600 Subject: [PATCH] test: build signals library and use output for schematics/migrations tests --- modules/signals/jest.config.ts | 22 ------------------- .../18_0_0-rc_3-protected-state/index.spec.ts | 5 ++++- .../index.spec.ts | 5 ++++- .../19_0_0-rc_0-props/index.spec.ts | 5 ++++- modules/signals/project.json | 19 ++-------------- .../signals/schematics/ng-add/index.spec.ts | 2 +- modules/signals/tsconfig.spec.json | 2 +- modules/signals/vite.config.mts | 1 - 8 files changed, 16 insertions(+), 45 deletions(-) delete mode 100644 modules/signals/jest.config.ts diff --git a/modules/signals/jest.config.ts b/modules/signals/jest.config.ts deleted file mode 100644 index dcc5d616d6..0000000000 --- a/modules/signals/jest.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'Signals', - preset: '../../jest.preset.js', - coverageDirectory: '../../coverage/modules/signals', - setupFilesAfterEnv: ['/test-setup.ts'], - transform: { - '^.+\\.(ts|mjs|js|html)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - }, - ], - }, - transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], - snapshotSerializers: [ - 'jest-preset-angular/build/serializers/no-ng-attributes', - 'jest-preset-angular/build/serializers/ng-snapshot', - 'jest-preset-angular/build/serializers/html-comment', - ], -}; diff --git a/modules/signals/migrations/18_0_0-rc_3-protected-state/index.spec.ts b/modules/signals/migrations/18_0_0-rc_3-protected-state/index.spec.ts index a7b84d3d3f..d5c722babb 100644 --- a/modules/signals/migrations/18_0_0-rc_3-protected-state/index.spec.ts +++ b/modules/signals/migrations/18_0_0-rc_3-protected-state/index.spec.ts @@ -7,7 +7,10 @@ import { createWorkspace } from '@ngrx/schematics-core/testing'; import { tags } from '@angular-devkit/core'; describe('migrate protectedState', () => { - const collectionPath = path.join(__dirname, '../migration.json'); + const collectionPath = path.join( + process.cwd(), + 'dist/modules/signals/migrations/migration.json' + ); const schematicRunner = new SchematicTestRunner('schematics', collectionPath); let appTree: UnitTestTree; diff --git a/modules/signals/migrations/18_0_0-rc_3-writablestatesource/index.spec.ts b/modules/signals/migrations/18_0_0-rc_3-writablestatesource/index.spec.ts index bb6239dbf3..87408446ab 100644 --- a/modules/signals/migrations/18_0_0-rc_3-writablestatesource/index.spec.ts +++ b/modules/signals/migrations/18_0_0-rc_3-writablestatesource/index.spec.ts @@ -8,7 +8,10 @@ import * as path from 'path'; import { LogEntry } from '@angular-devkit/core/src/logger'; describe('18_0_0-rc_3-writablestatesource', () => { - const collectionPath = path.join(__dirname, '../migration.json'); + const collectionPath = path.join( + process.cwd(), + 'dist/modules/signals/migrations/migration.json' + ); const schematicRunner = new SchematicTestRunner('schematics', collectionPath); let appTree: UnitTestTree; diff --git a/modules/signals/migrations/19_0_0-rc_0-props/index.spec.ts b/modules/signals/migrations/19_0_0-rc_0-props/index.spec.ts index 7822157f59..cad4a921dd 100644 --- a/modules/signals/migrations/19_0_0-rc_0-props/index.spec.ts +++ b/modules/signals/migrations/19_0_0-rc_0-props/index.spec.ts @@ -7,7 +7,10 @@ import { createWorkspace } from '@ngrx/schematics-core/testing'; import { tags } from '@angular-devkit/core'; describe('migrate to props', () => { - const collectionPath = path.join(__dirname, '../migration.json'); + const collectionPath = path.join( + process.cwd(), + 'dist/modules/signals/migrations/migration.json' + ); const schematicRunner = new SchematicTestRunner('schematics', collectionPath); let appTree: UnitTestTree; diff --git a/modules/signals/project.json b/modules/signals/project.json index 13dfd29e69..f30e63e41f 100644 --- a/modules/signals/project.json +++ b/modules/signals/project.json @@ -47,23 +47,8 @@ "outputs": ["{options.outputFile}"] }, "test": { - "executor": "nx:run-commands", - "options": { - "commands": ["nx test-source signals", "nx test-schematics signals"] - } - }, - "test-source": { - "executor": "@analogjs/vitest-angular:test" - }, - "test-schematics": { - "executor": "@nx/jest:jest", - "options": { - "jestConfig": "modules/signals/jest.config.ts", - "runInBand": true, - "passWithNoTests": false, - "testPathPattern": ["schematics", "migrations"] - }, - "outputs": ["{workspaceRoot}/coverage/modules/signals"] + "executor": "@analogjs/vitest-angular:test", + "dependsOn": ["build"] } } } diff --git a/modules/signals/schematics/ng-add/index.spec.ts b/modules/signals/schematics/ng-add/index.spec.ts index be0eb8003c..b0608561f2 100644 --- a/modules/signals/schematics/ng-add/index.spec.ts +++ b/modules/signals/schematics/ng-add/index.spec.ts @@ -9,7 +9,7 @@ import { createWorkspace } from '@ngrx/schematics-core/testing'; describe('Signals ng-add Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/signals', - path.join(__dirname, '../collection.json') + path.join(process.cwd(), 'dist/modules/signals/schematics/collection.json') ); const defaultOptions: SchemaOptions = { skipPackageJson: false, diff --git a/modules/signals/tsconfig.spec.json b/modules/signals/tsconfig.spec.json index 292422b6f6..8488d80d97 100644 --- a/modules/signals/tsconfig.spec.json +++ b/modules/signals/tsconfig.spec.json @@ -7,5 +7,5 @@ "target": "es2016" }, "files": ["test-setup.ts"], - "include": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"] + "include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"] } diff --git a/modules/signals/vite.config.mts b/modules/signals/vite.config.mts index 0fbd963799..fa49854dbf 100644 --- a/modules/signals/vite.config.mts +++ b/modules/signals/vite.config.mts @@ -20,7 +20,6 @@ export default defineConfig(({ mode }) => { environment: 'jsdom', setupFiles: ['test-setup.ts'], include: ['**/*.spec.ts'], - exclude: ['migrations/**', 'schematics/**'], reporters: ['default'] }, define: {