diff --git a/modules/schematics/jest.config.ts b/modules/schematics/jest.config.ts deleted file mode 100644 index 484cb41105..0000000000 --- a/modules/schematics/jest.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'Schematics', - preset: '../../jest.preset.js', - coverageDirectory: '../../coverage/modules/schematics', - 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/schematics/project.json b/modules/schematics/project.json index b8fe1b730b..671649ed3d 100644 --- a/modules/schematics/project.json +++ b/modules/schematics/project.json @@ -16,15 +16,6 @@ }, "outputs": ["{options.outputFile}"] }, - "test": { - "executor": "@nx/jest:jest", - "options": { - "jestConfig": "modules/schematics/jest.config.ts", - "runInBand": true, - "passWithNoTests": false - }, - "outputs": ["{workspaceRoot}/coverage/modules/schematics"] - }, "build-package": { "executor": "@nx/js:tsc", "options": { @@ -83,6 +74,11 @@ ] }, "outputs": ["{workspaceRoot}/dist/modules/schematics"] + }, + "test": { + "executor": "@analogjs/vitest-angular:test", + "dependsOn": ["build"], + "outputs": ["{workspaceRoot}/coverage/modules/schematics"] } } } diff --git a/modules/schematics/src/action/__snapshots__/index.spec.ts.snap b/modules/schematics/src/action/__snapshots__/index.spec.ts.snap index bf4868151a..990f26de60 100644 --- a/modules/schematics/src/action/__snapshots__/index.spec.ts.snap +++ b/modules/schematics/src/action/__snapshots__/index.spec.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Action Schematic api should create api actions 1`] = ` +exports[`Action Schematic > api > should create api actions 1`] = ` "import { createActionGroup, emptyProps, props } from '@ngrx/store'; export const FooActions = createActionGroup({ @@ -14,7 +14,7 @@ export const FooActions = createActionGroup({ " `; -exports[`Action Schematic should create an action with the defined prefix 1`] = ` +exports[`Action Schematic > should create an action with the defined prefix 1`] = ` "import { createActionGroup, emptyProps, props } from '@ngrx/store'; export const FooActions = createActionGroup({ @@ -28,7 +28,7 @@ export const FooActions = createActionGroup({ " `; -exports[`Action Schematic should create api actions (load, success, error) when the api flag is set 1`] = ` +exports[`Action Schematic > should create api actions (load, success, error) when the api flag is set 1`] = ` "import { createActionGroup, emptyProps, props } from '@ngrx/store'; export const FooActions = createActionGroup({ @@ -42,7 +42,7 @@ export const FooActions = createActionGroup({ " `; -exports[`Action Schematic should define actions using createActionGroup 1`] = ` +exports[`Action Schematic > should define actions using createActionGroup 1`] = ` "import { createActionGroup, emptyProps, props } from '@ngrx/store'; export const FooActions = createActionGroup({ diff --git a/modules/schematics/src/action/index.spec.ts b/modules/schematics/src/action/index.spec.ts index 298bb1c34b..a0bce6c5a2 100644 --- a/modules/schematics/src/action/index.spec.ts +++ b/modules/schematics/src/action/index.spec.ts @@ -10,12 +10,11 @@ import { defaultWorkspaceOptions, defaultAppOptions, } from '@ngrx/schematics-core/testing'; -import { capitalize } from '../../schematics-core/utility/strings'; describe('Action Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultOptions: ActionOptions = { name: 'foo', diff --git a/modules/schematics/src/component-store/__snapshots__/index.spec.ts.snap b/modules/schematics/src/component-store/__snapshots__/index.spec.ts.snap index 2576d76bca..c002b30e03 100644 --- a/modules/schematics/src/component-store/__snapshots__/index.spec.ts.snap +++ b/modules/schematics/src/component-store/__snapshots__/index.spec.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`component-store should import into a specified module when the module provided 1`] = ` +exports[`component-store > should import into a specified module when the module provided 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -24,7 +24,7 @@ export class AppModule { } " `; -exports[`component-store should inject the component store correctly into the spec 1`] = ` +exports[`component-store > should inject the component store correctly into the spec 1`] = ` "import { FooStore } from './foo.store'; describe('FooStore', () => { @@ -37,7 +37,7 @@ describe('FooStore', () => { " `; -exports[`component-store should not be provided into the module by default 1`] = ` +exports[`component-store > should not be provided into the module by default 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -59,7 +59,7 @@ export class AppModule { } " `; -exports[`component-store should register the component store in the provided component 1`] = ` +exports[`component-store > should register the component store in the provided component 1`] = ` "import { Component, signal } from '@angular/core'; import { FooStore } from './foo/foo.store'; diff --git a/modules/schematics/src/component-store/index.spec.ts b/modules/schematics/src/component-store/index.spec.ts index da0339bf2d..a3d20e92f1 100644 --- a/modules/schematics/src/component-store/index.spec.ts +++ b/modules/schematics/src/component-store/index.spec.ts @@ -14,7 +14,7 @@ import { describe('component-store', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultOptions: ComponentStoreOptions = { diff --git a/modules/schematics/src/container/__snapshots__/index.spec.ts.snap b/modules/schematics/src/container/__snapshots__/index.spec.ts.snap index 4110e6b055..12b48304e0 100644 --- a/modules/schematics/src/container/__snapshots__/index.spec.ts.snap +++ b/modules/schematics/src/container/__snapshots__/index.spec.ts.snap @@ -1,15 +1,15 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Container Schematic display-block should be disabled by default 1`] = `""`; +exports[`Container Schematic > display-block > should be disabled by default 1`] = `""`; -exports[`Container Schematic display-block should create add style if true 1`] = ` +exports[`Container Schematic > display-block > should create add style if true 1`] = ` ":host { display: block; } " `; -exports[`Container Schematic should import Store into the component 1`] = ` +exports[`Container Schematic > should import Store into the component 1`] = ` "import { Component } from '@angular/core'; import { Store } from '@ngrx/store'; import * as fromStore from '../reducers'; @@ -26,7 +26,7 @@ export class Foo { " `; -exports[`Container Schematic should respect the state option if not provided 1`] = ` +exports[`Container Schematic > should respect the state option if not provided 1`] = ` "import { Component } from '@angular/core'; import { Store } from '@ngrx/store'; @@ -42,7 +42,7 @@ export class Foo { " `; -exports[`Container Schematic should update the component spec 1`] = ` +exports[`Container Schematic > should update the component spec 1`] = ` "import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FooComponent } from './foo.component'; @@ -77,7 +77,7 @@ describe('FooComponent', () => { " `; -exports[`Container Schematic should use StoreModule if integration test 1`] = ` +exports[`Container Schematic > should use StoreModule if integration test 1`] = ` "import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FooComponent } from './foo.component'; @@ -113,7 +113,7 @@ describe('FooComponent', () => { " `; -exports[`Container Schematic standalone should be standalone by default 1`] = ` +exports[`Container Schematic > standalone > should be standalone by default 1`] = ` "import { Component } from '@angular/core'; import { Store } from '@ngrx/store'; @@ -129,7 +129,7 @@ export class Foo { " `; -exports[`Container Schematic standalone should create a non-standalone component if false 1`] = ` +exports[`Container Schematic > standalone > should create a non-standalone component if false 1`] = ` "import { Component } from '@angular/core'; import { Store } from '@ngrx/store'; diff --git a/modules/schematics/src/container/index.spec.ts b/modules/schematics/src/container/index.spec.ts index 4aee99cd96..3cdcb3981d 100644 --- a/modules/schematics/src/container/index.spec.ts +++ b/modules/schematics/src/container/index.spec.ts @@ -12,7 +12,7 @@ import { describe('Container Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultOptions: ContainerOptions = { diff --git a/modules/schematics/src/data/__snapshots__/index.spec.ts.snap b/modules/schematics/src/data/__snapshots__/index.spec.ts.snap index f1baad6314..af85bc2746 100644 --- a/modules/schematics/src/data/__snapshots__/index.spec.ts.snap +++ b/modules/schematics/src/data/__snapshots__/index.spec.ts.snap @@ -1,13 +1,13 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Data Schematic should create a model interface 1`] = ` +exports[`Data Schematic > should create a model interface 1`] = ` "export interface Foo { id?: unknown; } " `; -exports[`Data Schematic should create a service class 1`] = ` +exports[`Data Schematic > should create a service class 1`] = ` "import { Injectable, inject } from '@angular/core'; import { EntityCollectionServiceBase, @@ -24,7 +24,7 @@ export class FooService extends EntityCollectionServiceBase { " `; -exports[`Data Schematic should create a spec class 1`] = ` +exports[`Data Schematic > should create a spec class 1`] = ` "import { TestBed } from '@angular/core/testing'; import { EntityCollectionServiceElementsFactory diff --git a/modules/schematics/src/data/index.spec.ts b/modules/schematics/src/data/index.spec.ts index a96fde4334..2b29cab228 100644 --- a/modules/schematics/src/data/index.spec.ts +++ b/modules/schematics/src/data/index.spec.ts @@ -14,7 +14,7 @@ import { describe('Data Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultOptions: DataOptions = { name: 'foo', diff --git a/modules/schematics/src/effect/__snapshots__/index.spec.ts.snap b/modules/schematics/src/effect/__snapshots__/index.spec.ts.snap index cb80d9397c..de6a62afb9 100644 --- a/modules/schematics/src/effect/__snapshots__/index.spec.ts.snap +++ b/modules/schematics/src/effect/__snapshots__/index.spec.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Effect Schematic feature effects should add an effect to the existing registered feature effects 1`] = ` +exports[`Effect Schematic > feature effects > should add an effect to the existing registered feature effects 1`] = ` " import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; @@ -24,7 +24,7 @@ import { FooEffects } from './foo/foo.effects'; " `; -exports[`Effect Schematic feature effects should create an effect that describes a source of actions within a feature 1`] = ` +exports[`Effect Schematic > feature effects > should create an effect that describes a source of actions within a feature 1`] = ` "import { Injectable, inject } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; @@ -50,7 +50,7 @@ export class FooEffects { " `; -exports[`Effect Schematic feature effects should not add an effect to registered effects defined with a variable 1`] = ` +exports[`Effect Schematic > feature effects > should not add an effect to registered effects defined with a variable 1`] = ` " import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; @@ -74,7 +74,7 @@ import { FooEffects } from './foo/foo.effects'; " `; -exports[`Effect Schematic feature effects should still register the feature effect module with an effect with the minimal flag 1`] = ` +exports[`Effect Schematic > feature effects > should still register the feature effect module with an effect with the minimal flag 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -99,7 +99,7 @@ export class AppModule { } " `; -exports[`Effect Schematic root effects should add an effect to the empty array of registered effects 1`] = ` +exports[`Effect Schematic > root effects > should add an effect to the empty array of registered effects 1`] = ` " import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; @@ -122,7 +122,7 @@ import { FooEffects } from './foo/foo.effects'; " `; -exports[`Effect Schematic root effects should add an effect to the existing registered root effects 1`] = ` +exports[`Effect Schematic > root effects > should add an effect to the existing registered root effects 1`] = ` " import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; @@ -145,7 +145,7 @@ import { FooEffects } from './foo/foo.effects'; " `; -exports[`Effect Schematic root effects should create an effect that does not define a source of actions within the root 1`] = ` +exports[`Effect Schematic > root effects > should create an effect that does not define a source of actions within the root 1`] = ` "import { Injectable, inject } from '@angular/core'; import { Actions, createEffect } from '@ngrx/effects'; @@ -160,7 +160,7 @@ export class FooEffects { " `; -exports[`Effect Schematic root effects should register the root effect in the provided module 1`] = ` +exports[`Effect Schematic > root effects > should register the root effect in the provided module 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -185,7 +185,7 @@ export class AppModule { } " `; -exports[`Effect Schematic root effects should register the root effect module without effect with the minimal flag 1`] = ` +exports[`Effect Schematic > root effects > should register the root effect module without effect with the minimal flag 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -209,7 +209,7 @@ export class AppModule { } " `; -exports[`Effect Schematic should add prefix to the effect 1`] = ` +exports[`Effect Schematic > should add prefix to the effect 1`] = ` "import { Injectable, inject } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { catchError, map, concatMap } from 'rxjs/operators'; @@ -239,7 +239,7 @@ export class FooEffects { " `; -exports[`Effect Schematic should create an api effect that describes a source of actions within a feature 1`] = ` +exports[`Effect Schematic > should create an api effect that describes a source of actions within a feature 1`] = ` "import { Injectable, inject } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { catchError, map, concatMap } from 'rxjs/operators'; @@ -269,7 +269,7 @@ export class FooEffects { " `; -exports[`Effect Schematic should group and nest the effect within a feature 1`] = ` +exports[`Effect Schematic > should group and nest the effect within a feature 1`] = ` "import { Injectable, inject } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; @@ -295,7 +295,7 @@ export class FooEffects { " `; -exports[`Effect Schematic should import into a specified module when provided 1`] = ` +exports[`Effect Schematic > should import into a specified module when provided 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -320,7 +320,7 @@ export class AppModule { } " `; -exports[`Effect Schematic should inject the effect service correctly within the spec 1`] = ` +exports[`Effect Schematic > should inject the effect service correctly within the spec 1`] = ` "import { TestBed } from '@angular/core/testing'; import { provideMockActions } from '@ngrx/effects/testing'; import { Observable } from 'rxjs'; @@ -349,7 +349,7 @@ describe('FooEffects', () => { " `; -exports[`Effect Schematic should not be provided by default 1`] = ` +exports[`Effect Schematic > should not be provided by default 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; diff --git a/modules/schematics/src/effect/index.spec.ts b/modules/schematics/src/effect/index.spec.ts index 006d776623..562c2e1f69 100644 --- a/modules/schematics/src/effect/index.spec.ts +++ b/modules/schematics/src/effect/index.spec.ts @@ -15,7 +15,7 @@ import { describe('Effect Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultOptions: EffectOptions = { diff --git a/modules/schematics/src/entity/__snapshots__/index.spec.ts.snap b/modules/schematics/src/entity/__snapshots__/index.spec.ts.snap index 5cc8949450..a6ab3f5dd8 100644 --- a/modules/schematics/src/entity/__snapshots__/index.spec.ts.snap +++ b/modules/schematics/src/entity/__snapshots__/index.spec.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Entity Schematic should create 3 files 1`] = ` +exports[`Entity Schematic > should create 3 files 1`] = ` "import { createActionGroup, emptyProps, props } from '@ngrx/store'; import { Update } from '@ngrx/entity'; @@ -24,14 +24,14 @@ export const FooActions = createActionGroup({ " `; -exports[`Entity Schematic should create 3 files 2`] = ` +exports[`Entity Schematic > should create 3 files 2`] = ` "export interface Foo { id: string; } " `; -exports[`Entity Schematic should create 3 files 3`] = ` +exports[`Entity Schematic > should create 3 files 3`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity'; import { Foo } from './foo.model'; @@ -100,13 +100,13 @@ export const { " `; -exports[`Entity Schematic should create 3 files of an entity to specified project if provided 1`] = `""`; +exports[`Entity Schematic > should create 3 files of an entity to specified project if provided 1`] = `""`; -exports[`Entity Schematic should create 3 files of an entity to specified project if provided 2`] = `""`; +exports[`Entity Schematic > should create 3 files of an entity to specified project if provided 2`] = `""`; -exports[`Entity Schematic should create 3 files of an entity to specified project if provided 3`] = `""`; +exports[`Entity Schematic > should create 3 files of an entity to specified project if provided 3`] = `""`; -exports[`Entity Schematic should create all files of an entity within grouped and nested folders 1`] = ` +exports[`Entity Schematic > should create all files of an entity within grouped and nested folders 1`] = ` "import { createActionGroup, emptyProps, props } from '@ngrx/store'; import { Update } from '@ngrx/entity'; @@ -130,14 +130,14 @@ export const FooActions = createActionGroup({ " `; -exports[`Entity Schematic should create all files of an entity within grouped and nested folders 2`] = ` +exports[`Entity Schematic > should create all files of an entity within grouped and nested folders 2`] = ` "export interface Foo { id: string; } " `; -exports[`Entity Schematic should create all files of an entity within grouped and nested folders 3`] = ` +exports[`Entity Schematic > should create all files of an entity within grouped and nested folders 3`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity'; import { Foo } from '../../models/foo/foo.model'; @@ -206,7 +206,7 @@ export const { " `; -exports[`Entity Schematic should create all files of an entity within grouped and nested folders 4`] = ` +exports[`Entity Schematic > should create all files of an entity within grouped and nested folders 4`] = ` "import { reducer, initialState } from '../../reducers/foo/foo.reducer'; describe('Foo Reducer', () => { @@ -223,7 +223,7 @@ describe('Foo Reducer', () => { " `; -exports[`Entity Schematic should create all files of an entity within grouped folders if group is set 1`] = ` +exports[`Entity Schematic > should create all files of an entity within grouped folders if group is set 1`] = ` "import { createActionGroup, emptyProps, props } from '@ngrx/store'; import { Update } from '@ngrx/entity'; @@ -247,14 +247,14 @@ export const FooActions = createActionGroup({ " `; -exports[`Entity Schematic should create all files of an entity within grouped folders if group is set 2`] = ` +exports[`Entity Schematic > should create all files of an entity within grouped folders if group is set 2`] = ` "export interface Foo { id: string; } " `; -exports[`Entity Schematic should create all files of an entity within grouped folders if group is set 3`] = ` +exports[`Entity Schematic > should create all files of an entity within grouped folders if group is set 3`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity'; import { Foo } from '../models/foo.model'; @@ -323,7 +323,7 @@ export const { " `; -exports[`Entity Schematic should create all files of an entity within grouped folders if group is set 4`] = ` +exports[`Entity Schematic > should create all files of an entity within grouped folders if group is set 4`] = ` "import { reducer, initialState } from '../reducers/foo.reducer'; describe('Foo Reducer', () => { @@ -340,7 +340,7 @@ describe('Foo Reducer', () => { " `; -exports[`Entity Schematic should import into a specified module 1`] = ` +exports[`Entity Schematic > should import into a specified module 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -365,7 +365,7 @@ export class AppModule { } " `; -exports[`Entity Schematic should update the state to plural 1`] = ` +exports[`Entity Schematic > should update the state to plural 1`] = ` "import { createActionGroup, emptyProps, props } from '@ngrx/store'; import { Update } from '@ngrx/entity'; @@ -389,14 +389,14 @@ export const UserActions = createActionGroup({ " `; -exports[`Entity Schematic should update the state to plural 2`] = ` +exports[`Entity Schematic > should update the state to plural 2`] = ` "export interface User { id: string; } " `; -exports[`Entity Schematic should update the state to plural 3`] = ` +exports[`Entity Schematic > should update the state to plural 3`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity'; import { User } from './user.model'; @@ -465,7 +465,7 @@ export const { " `; -exports[`Entity Schematic should update the state to plural 4`] = ` +exports[`Entity Schematic > should update the state to plural 4`] = ` "import { reducer, initialState } from './user.reducer'; describe('User Reducer', () => { @@ -482,7 +482,7 @@ describe('User Reducer', () => { " `; -exports[`Entity Schematic should update the state to plural 5`] = ` +exports[`Entity Schematic > should update the state to plural 5`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, diff --git a/modules/schematics/src/entity/index.spec.ts b/modules/schematics/src/entity/index.spec.ts index 79fd5df605..91942dd3ef 100644 --- a/modules/schematics/src/entity/index.spec.ts +++ b/modules/schematics/src/entity/index.spec.ts @@ -14,7 +14,7 @@ import { describe('Entity Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultOptions: EntityOptions = { name: 'foo', diff --git a/modules/schematics/src/feature/__snapshots__/index.spec.ts.snap b/modules/schematics/src/feature/__snapshots__/index.spec.ts.snap index ecb302fe02..9b1a049321 100644 --- a/modules/schematics/src/feature/__snapshots__/index.spec.ts.snap +++ b/modules/schematics/src/feature/__snapshots__/index.spec.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Feature Schematic should create all files of a feature with an entity 1`] = ` +exports[`Feature Schematic > should create all files of a feature with an entity 1`] = ` "import { createActionGroup, emptyProps, props } from '@ngrx/store'; import { Update } from '@ngrx/entity'; @@ -24,7 +24,7 @@ export const FooActions = createActionGroup({ " `; -exports[`Feature Schematic should create all files of a feature with an entity 2`] = ` +exports[`Feature Schematic > should create all files of a feature with an entity 2`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity'; import { Foo } from './foo.model'; @@ -93,7 +93,7 @@ export const { " `; -exports[`Feature Schematic should create all files of a feature with an entity 3`] = ` +exports[`Feature Schematic > should create all files of a feature with an entity 3`] = ` "import { reducer, initialState } from './foo.reducer'; describe('Foo Reducer', () => { @@ -110,7 +110,7 @@ describe('Foo Reducer', () => { " `; -exports[`Feature Schematic should create all files of a feature with an entity 4`] = ` +exports[`Feature Schematic > should create all files of a feature with an entity 4`] = ` "import { Injectable, inject } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; @@ -136,7 +136,7 @@ export class FooEffects { " `; -exports[`Feature Schematic should create all files of a feature with an entity 5`] = ` +exports[`Feature Schematic > should create all files of a feature with an entity 5`] = ` "import { TestBed } from '@angular/core/testing'; import { provideMockActions } from '@ngrx/effects/testing'; import { Observable } from 'rxjs'; @@ -165,14 +165,14 @@ describe('FooEffects', () => { " `; -exports[`Feature Schematic should create all files of a feature with an entity 6`] = ` +exports[`Feature Schematic > should create all files of a feature with an entity 6`] = ` "export interface Foo { id: string; } " `; -exports[`Feature Schematic should have all api actions in reducer if api flag enabled 1`] = ` +exports[`Feature Schematic > should have all api actions in reducer if api flag enabled 1`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { FooActions } from './foo.actions'; @@ -201,7 +201,7 @@ export const fooFeature = createFeature({ " `; -exports[`Feature Schematic should have all api actions with prefix in reducer if api flag enabled 1`] = ` +exports[`Feature Schematic > should have all api actions with prefix in reducer if api flag enabled 1`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { FooActions } from './foo.actions'; @@ -230,7 +230,7 @@ export const fooFeature = createFeature({ " `; -exports[`Feature Schematic should have all api effect if api flag enabled 1`] = ` +exports[`Feature Schematic > should have all api effect if api flag enabled 1`] = ` "import { Injectable, inject } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { catchError, map, concatMap } from 'rxjs/operators'; @@ -260,7 +260,7 @@ export class FooEffects { " `; -exports[`Feature Schematic should have all api effect with prefix if api flag enabled 1`] = ` +exports[`Feature Schematic > should have all api effect with prefix if api flag enabled 1`] = ` "import { Injectable, inject } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { catchError, map, concatMap } from 'rxjs/operators'; @@ -290,7 +290,7 @@ export class FooEffects { " `; -exports[`Feature Schematic should respect the path provided for the feature name 1`] = ` +exports[`Feature Schematic > should respect the path provided for the feature name 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; diff --git a/modules/schematics/src/feature/index.spec.ts b/modules/schematics/src/feature/index.spec.ts index d9ef18f4d4..c4ec5ff1e6 100644 --- a/modules/schematics/src/feature/index.spec.ts +++ b/modules/schematics/src/feature/index.spec.ts @@ -14,7 +14,7 @@ import { describe('Feature Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultOptions: FeatureOptions = { name: 'foo', diff --git a/modules/schematics/src/ng-add/index.spec.ts b/modules/schematics/src/ng-add/index.spec.ts index d78019bfe2..f49cbcf327 100644 --- a/modules/schematics/src/ng-add/index.spec.ts +++ b/modules/schematics/src/ng-add/index.spec.ts @@ -8,7 +8,7 @@ import { createWorkspace } from '@ngrx/schematics-core/testing'; describe('ng-add Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultWorkspace = { diff --git a/modules/schematics/src/ngrx-push-migration/index.spec.ts b/modules/schematics/src/ngrx-push-migration/index.spec.ts index 11178ce729..e170728733 100644 --- a/modules/schematics/src/ngrx-push-migration/index.spec.ts +++ b/modules/schematics/src/ngrx-push-migration/index.spec.ts @@ -8,7 +8,7 @@ import { createWorkspace } from '@ngrx/schematics-core/testing'; describe('NgrxPush migration', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); let appTree: UnitTestTree; diff --git a/modules/schematics/src/reducer/__snapshots__/index.spec.ts.snap b/modules/schematics/src/reducer/__snapshots__/index.spec.ts.snap index 700832de10..eb39da307f 100644 --- a/modules/schematics/src/reducer/__snapshots__/index.spec.ts.snap +++ b/modules/schematics/src/reducer/__snapshots__/index.spec.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Reducer Schematic should create a reducer 1`] = ` +exports[`Reducer Schematic > should create a reducer 1`] = ` "import { createReducer, on } from '@ngrx/store'; import { FooActions } from './foo.actions'; @@ -21,7 +21,7 @@ export const reducer = createReducer( " `; -exports[`Reducer Schematic should create a reducer with prefix in an api feature 1`] = ` +exports[`Reducer Schematic > should create a reducer with prefix in an api feature 1`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { FooActions } from './foo.actions'; @@ -50,7 +50,7 @@ export const fooFeature = createFeature({ " `; -exports[`Reducer Schematic should create a reducers barrel file 1`] = ` +exports[`Reducer Schematic > should create a reducers barrel file 1`] = ` " import { isDevMode } from '@angular/core'; import { @@ -77,7 +77,7 @@ import * as fromFoo from '../foo.reducer'; " `; -exports[`Reducer Schematic should create and export a reducer in a feature 1`] = ` +exports[`Reducer Schematic > should create and export a reducer in a feature 1`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { FooActions } from './foo.actions'; @@ -105,7 +105,7 @@ export const fooFeature = createFeature({ " `; -exports[`Reducer Schematic should create and export a reducer in an api feature 1`] = ` +exports[`Reducer Schematic > should create and export a reducer in an api feature 1`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { FooActions } from './foo.actions'; @@ -134,7 +134,7 @@ export const fooFeature = createFeature({ " `; -exports[`Reducer Schematic should group and nest the reducer within a feature 1`] = ` +exports[`Reducer Schematic > should group and nest the reducer within a feature 1`] = ` "import { createFeature, createReducer, on } from '@ngrx/store'; import { FooActions } from '../../actions/foo/foo.actions'; @@ -162,7 +162,7 @@ export const fooFeature = createFeature({ " `; -exports[`Reducer Schematic should group within a "reducers" folder if group is set 1`] = ` +exports[`Reducer Schematic > should group within a "reducers" folder if group is set 1`] = ` "import { createReducer, on } from '@ngrx/store'; import { FooActions } from '../actions/foo.actions'; @@ -183,7 +183,7 @@ export const reducer = createReducer( " `; -exports[`Reducer Schematic should import into a specified module 1`] = ` +exports[`Reducer Schematic > should import into a specified module 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; diff --git a/modules/schematics/src/reducer/index.spec.ts b/modules/schematics/src/reducer/index.spec.ts index 12a813107e..ad202ff1a3 100644 --- a/modules/schematics/src/reducer/index.spec.ts +++ b/modules/schematics/src/reducer/index.spec.ts @@ -15,7 +15,7 @@ import { describe('Reducer Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultOptions: ReducerOptions = { name: 'foo', diff --git a/modules/schematics/src/selector/__snapshots__/index.spec.ts.snap b/modules/schematics/src/selector/__snapshots__/index.spec.ts.snap index 7b41a362ae..ec64f0cb8c 100644 --- a/modules/schematics/src/selector/__snapshots__/index.spec.ts.snap +++ b/modules/schematics/src/selector/__snapshots__/index.spec.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Selector Schematic With feature flag should create a selector 1`] = ` +exports[`Selector Schematic > With feature flag > should create a selector 1`] = ` "import { createFeatureSelector, createSelector } from '@ngrx/store'; import * as fromFoo from './foo.reducer'; @@ -10,7 +10,7 @@ export const selectFooState = createFeatureSelector( " `; -exports[`Selector Schematic With feature flag should create a selector 2`] = ` +exports[`Selector Schematic > With feature flag > should create a selector 2`] = ` "import * as fromFoo from './foo.reducer'; import { selectFooState } from './foo.selectors'; @@ -26,7 +26,7 @@ describe('Foo Selectors', () => { " `; -exports[`Selector Schematic With feature flag should group and nest the selectors within a feature 1`] = ` +exports[`Selector Schematic > With feature flag > should group and nest the selectors within a feature 1`] = ` "import { createFeatureSelector, createSelector } from '@ngrx/store'; import * as fromFoo from '../../reducers/foo/foo.reducer'; @@ -36,7 +36,7 @@ export const selectFooState = createFeatureSelector( " `; -exports[`Selector Schematic With feature flag should group and nest the selectors within a feature 2`] = ` +exports[`Selector Schematic > With feature flag > should group and nest the selectors within a feature 2`] = ` "import * as fromFoo from '../../reducers/foo/foo.reducer'; import { selectFooState } from './foo.selectors'; @@ -52,13 +52,13 @@ describe('Foo Selectors', () => { " `; -exports[`Selector Schematic should create selector files 1`] = ` +exports[`Selector Schematic > should create selector files 1`] = ` "import { createFeatureSelector, createSelector } from '@ngrx/store'; " `; -exports[`Selector Schematic should create selector files 2`] = ` +exports[`Selector Schematic > should create selector files 2`] = ` " describe('Foo Selectors', () => { @@ -69,13 +69,13 @@ describe('Foo Selectors', () => { " `; -exports[`Selector Schematic should group selectors if group is true 1`] = ` +exports[`Selector Schematic > should group selectors if group is true 1`] = ` "import { createFeatureSelector, createSelector } from '@ngrx/store'; " `; -exports[`Selector Schematic should group selectors if group is true 2`] = ` +exports[`Selector Schematic > should group selectors if group is true 2`] = ` " describe('Foo Selectors', () => { @@ -86,13 +86,13 @@ describe('Foo Selectors', () => { " `; -exports[`Selector Schematic should not flatten selectors if flat is false 1`] = ` +exports[`Selector Schematic > should not flatten selectors if flat is false 1`] = ` "import { createFeatureSelector, createSelector } from '@ngrx/store'; " `; -exports[`Selector Schematic should not flatten selectors if flat is false 2`] = ` +exports[`Selector Schematic > should not flatten selectors if flat is false 2`] = ` " describe('Foo Selectors', () => { diff --git a/modules/schematics/src/selector/index.spec.ts b/modules/schematics/src/selector/index.spec.ts index 7c91150ee2..5ae6851a4f 100644 --- a/modules/schematics/src/selector/index.spec.ts +++ b/modules/schematics/src/selector/index.spec.ts @@ -12,7 +12,7 @@ import { describe('Selector Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultOptions: SelectorOptions = { name: 'foo', diff --git a/modules/schematics/src/store/__snapshots__/index.spec.ts.snap b/modules/schematics/src/store/__snapshots__/index.spec.ts.snap index db1ea0818d..bfbd301865 100644 --- a/modules/schematics/src/store/__snapshots__/index.spec.ts.snap +++ b/modules/schematics/src/store/__snapshots__/index.spec.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Store Schematic should add a feature key if not root 1`] = ` +exports[`Store Schematic > should add a feature key if not root 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -22,7 +22,7 @@ export class AppModule { } " `; -exports[`Store Schematic should add a feature key if not root 2`] = ` +exports[`Store Schematic > should add a feature key if not root 2`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, @@ -47,7 +47,7 @@ export const metaReducers: MetaReducer[] = isDevMode() ? [] : []; " `; -exports[`Store Schematic should add the initial config correctly into an empty module 1`] = ` +exports[`Store Schematic > should add the initial config correctly into an empty module 1`] = ` " import { NgModule, isDevMode } from '@angular/core'; import { StoreModule } from '@ngrx/store'; @@ -62,7 +62,7 @@ import { StoreDevtoolsModule } from '@ngrx/store-devtools'; " `; -exports[`Store Schematic should create the initial store setup 1`] = ` +exports[`Store Schematic > should create the initial store setup 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -84,7 +84,7 @@ export class AppModule { } " `; -exports[`Store Schematic should create the initial store setup 2`] = ` +exports[`Store Schematic > should create the initial store setup 2`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, @@ -108,7 +108,7 @@ export const metaReducers: MetaReducer[] = isDevMode() ? [] : []; " `; -exports[`Store Schematic should import a feature a specified module 1`] = ` +exports[`Store Schematic > should import a feature a specified module 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -133,7 +133,7 @@ export class AppModule { } " `; -exports[`Store Schematic should import a feature a specified module 2`] = ` +exports[`Store Schematic > should import a feature a specified module 2`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, @@ -158,7 +158,7 @@ export const metaReducers: MetaReducer[] = isDevMode() ? [] : []; " `; -exports[`Store Schematic should import into a specified module 1`] = ` +exports[`Store Schematic > should import into a specified module 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners, isDevMode } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -185,7 +185,7 @@ export class AppModule { } " `; -exports[`Store Schematic should import into a specified module 2`] = ` +exports[`Store Schematic > should import into a specified module 2`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, @@ -209,7 +209,7 @@ export const metaReducers: MetaReducer[] = isDevMode() ? [] : []; " `; -exports[`Store Schematic should not add a feature key if root 1`] = ` +exports[`Store Schematic > should not add a feature key if root 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -231,7 +231,7 @@ export class AppModule { } " `; -exports[`Store Schematic should not add a feature key if root 2`] = ` +exports[`Store Schematic > should not add a feature key if root 2`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, @@ -255,7 +255,7 @@ export const metaReducers: MetaReducer[] = isDevMode() ? [] : []; " `; -exports[`Store Schematic should not skip the initial store setup files if the minimal flag is provided with a feature 1`] = ` +exports[`Store Schematic > should not skip the initial store setup files if the minimal flag is provided with a feature 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -280,7 +280,7 @@ export class AppModule { } " `; -exports[`Store Schematic should not skip the initial store setup files if the minimal flag is provided with a feature 2`] = ` +exports[`Store Schematic > should not skip the initial store setup files if the minimal flag is provided with a feature 2`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, @@ -305,7 +305,7 @@ export const metaReducers: MetaReducer[] = isDevMode() ? [] : []; " `; -exports[`Store Schematic should skip the initial store setup files if the minimal flag is provided 1`] = ` +exports[`Store Schematic > should skip the initial store setup files if the minimal flag is provided 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners, isDevMode } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -331,7 +331,7 @@ export class AppModule { } " `; -exports[`Store Schematic should support a custom feature state interface name 1`] = ` +exports[`Store Schematic > should support a custom feature state interface name 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -353,7 +353,7 @@ export class AppModule { } " `; -exports[`Store Schematic should support a custom feature state interface name 2`] = ` +exports[`Store Schematic > should support a custom feature state interface name 2`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, @@ -378,7 +378,7 @@ export const metaReducers: MetaReducer[] = isDevMode() ? [] : []; " `; -exports[`Store Schematic should support a custom root state interface name 1`] = ` +exports[`Store Schematic > should support a custom root state interface name 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -400,7 +400,7 @@ export class AppModule { } " `; -exports[`Store Schematic should support a custom root state interface name 2`] = ` +exports[`Store Schematic > should support a custom root state interface name 2`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, @@ -424,7 +424,7 @@ export const metaReducers: MetaReducer[] = isDevMode() ? [] : []; " `; -exports[`Store Schematic should support a default feature state interface name 1`] = ` +exports[`Store Schematic > should support a default feature state interface name 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -446,7 +446,7 @@ export class AppModule { } " `; -exports[`Store Schematic should support a default feature state interface name 2`] = ` +exports[`Store Schematic > should support a default feature state interface name 2`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, @@ -471,7 +471,7 @@ export const metaReducers: MetaReducer[] = isDevMode() ? [] : []; " `; -exports[`Store Schematic should support a default root state interface name 1`] = ` +exports[`Store Schematic > should support a default root state interface name 1`] = ` "import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; @@ -493,7 +493,7 @@ export class AppModule { } " `; -exports[`Store Schematic should support a default root state interface name 2`] = ` +exports[`Store Schematic > should support a default root state interface name 2`] = ` "import { isDevMode } from '@angular/core'; import { ActionReducer, diff --git a/modules/schematics/src/store/index.spec.ts b/modules/schematics/src/store/index.spec.ts index f221b405a1..d65bd56d67 100644 --- a/modules/schematics/src/store/index.spec.ts +++ b/modules/schematics/src/store/index.spec.ts @@ -14,7 +14,7 @@ import { describe('Store Schematic', () => { const schematicRunner = new SchematicTestRunner( '@ngrx/schematics', - path.join(__dirname, '../../collection.json') + path.join(process.cwd(), 'dist/modules/schematics/collection.json') ); const defaultOptions: StoreOptions = { name: 'foo', diff --git a/modules/schematics/test-setup.ts b/modules/schematics/test-setup.ts index 04187448f9..3512059d4b 100644 --- a/modules/schematics/test-setup.ts +++ b/modules/schematics/test-setup.ts @@ -1,4 +1,33 @@ -import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone'; +import { + TextEncoder as NodeTextEncoder, + TextDecoder as NodeTextDecoder, +} from 'util'; -setupZoneTestEnv(); -Object.assign(global, { TextDecoder, TextEncoder }); +// Only assign if not already defined, using type assertion to satisfy TypeScript +if (typeof globalThis.TextEncoder === 'undefined') { + globalThis.TextEncoder = NodeTextEncoder as unknown as { + new (): TextEncoder; + prototype: TextEncoder; + }; +} + +if (typeof globalThis.TextDecoder === 'undefined') { + globalThis.TextDecoder = NodeTextDecoder as unknown as { + new (): TextDecoder; + prototype: TextDecoder; + }; +} + +import '@angular/compiler'; +import '@analogjs/vitest-angular/setup-zone'; + +import { + BrowserTestingModule, + platformBrowserTesting, +} from '@angular/platform-browser/testing'; +import { getTestBed } from '@angular/core/testing'; + +getTestBed().initTestEnvironment( + BrowserTestingModule, + platformBrowserTesting() +); diff --git a/modules/schematics/tsconfig.schematics.json b/modules/schematics/tsconfig.schematics.json index bf10406f79..324de466f4 100644 --- a/modules/schematics/tsconfig.schematics.json +++ b/modules/schematics/tsconfig.schematics.json @@ -5,6 +5,7 @@ "stripInternal": true, "experimentalDecorators": true, "module": "nodenext", + "target": "es2022", "moduleResolution": "nodenext", "downlevelIteration": true, "outDir": "../../dist/modules/schematics", diff --git a/modules/schematics/tsconfig.spec.json b/modules/schematics/tsconfig.spec.json index dcb4681eef..707b7d198b 100644 --- a/modules/schematics/tsconfig.spec.json +++ b/modules/schematics/tsconfig.spec.json @@ -2,10 +2,10 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"], + "module": "es2022", + "types": ["vitest/globals", "node"], "target": "es2016" }, "files": ["test-setup.ts"], - "include": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"] + "include": ["vitest.config.ts", "**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"] } diff --git a/modules/schematics/vitest.config.mts b/modules/schematics/vitest.config.mts new file mode 100644 index 0000000000..8efa608bcf --- /dev/null +++ b/modules/schematics/vitest.config.mts @@ -0,0 +1,26 @@ +/// + +import angular from '@analogjs/vite-plugin-angular'; + +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; + +import { defineConfig } from 'vite'; + +// https://vitejs.dev/config/ +export default defineConfig(({ mode }) => { + return { + root: __dirname, + plugins: [angular(), nxViteTsPaths()], + test: { + globals: true, + pool: 'forks', + environment: 'jsdom', + setupFiles: ['test-setup.ts'], + include: ['src/**/*.spec.ts'], + reporters: ['default'], + }, + define: { + 'import.meta.vitest': mode !== 'production', + }, + }; +});