Skip to content

Commit 346da2d

Browse files
refactor(schematics): migrate schematics tests to Vitest (#5134)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent eaac970 commit 346da2d

28 files changed

Lines changed: 194 additions & 165 deletions

File tree

modules/schematics/jest.config.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

modules/schematics/project.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@
1616
},
1717
"outputs": ["{options.outputFile}"]
1818
},
19-
"test": {
20-
"executor": "@nx/jest:jest",
21-
"options": {
22-
"jestConfig": "modules/schematics/jest.config.ts",
23-
"runInBand": true,
24-
"passWithNoTests": false
25-
},
26-
"outputs": ["{workspaceRoot}/coverage/modules/schematics"]
27-
},
2819
"build-package": {
2920
"executor": "@nx/js:tsc",
3021
"options": {
@@ -83,6 +74,11 @@
8374
]
8475
},
8576
"outputs": ["{workspaceRoot}/dist/modules/schematics"]
77+
},
78+
"test": {
79+
"executor": "@analogjs/vitest-angular:test",
80+
"dependsOn": ["build"],
81+
"outputs": ["{workspaceRoot}/coverage/modules/schematics"]
8682
}
8783
}
8884
}

modules/schematics/src/action/__snapshots__/index.spec.ts.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`Action Schematic api should create api actions 1`] = `
3+
exports[`Action Schematic > api > should create api actions 1`] = `
44
"import { createActionGroup, emptyProps, props } from '@ngrx/store';
55
66
export const FooActions = createActionGroup({
@@ -14,7 +14,7 @@ export const FooActions = createActionGroup({
1414
"
1515
`;
1616

17-
exports[`Action Schematic should create an action with the defined prefix 1`] = `
17+
exports[`Action Schematic > should create an action with the defined prefix 1`] = `
1818
"import { createActionGroup, emptyProps, props } from '@ngrx/store';
1919
2020
export const FooActions = createActionGroup({
@@ -28,7 +28,7 @@ export const FooActions = createActionGroup({
2828
"
2929
`;
3030

31-
exports[`Action Schematic should create api actions (load, success, error) when the api flag is set 1`] = `
31+
exports[`Action Schematic > should create api actions (load, success, error) when the api flag is set 1`] = `
3232
"import { createActionGroup, emptyProps, props } from '@ngrx/store';
3333
3434
export const FooActions = createActionGroup({
@@ -42,7 +42,7 @@ export const FooActions = createActionGroup({
4242
"
4343
`;
4444

45-
exports[`Action Schematic should define actions using createActionGroup 1`] = `
45+
exports[`Action Schematic > should define actions using createActionGroup 1`] = `
4646
"import { createActionGroup, emptyProps, props } from '@ngrx/store';
4747
4848
export const FooActions = createActionGroup({

modules/schematics/src/action/index.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ import {
1010
defaultWorkspaceOptions,
1111
defaultAppOptions,
1212
} from '@ngrx/schematics-core/testing';
13-
import { capitalize } from '../../schematics-core/utility/strings';
1413

1514
describe('Action Schematic', () => {
1615
const schematicRunner = new SchematicTestRunner(
1716
'@ngrx/schematics',
18-
path.join(__dirname, '../../collection.json')
17+
path.join(process.cwd(), 'dist/modules/schematics/collection.json')
1918
);
2019
const defaultOptions: ActionOptions = {
2120
name: 'foo',

modules/schematics/src/component-store/__snapshots__/index.spec.ts.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`component-store should import into a specified module when the module provided 1`] = `
3+
exports[`component-store > should import into a specified module when the module provided 1`] = `
44
"import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core';
55
import { BrowserModule } from '@angular/platform-browser';
66
@@ -24,7 +24,7 @@ export class AppModule { }
2424
"
2525
`;
2626

27-
exports[`component-store should inject the component store correctly into the spec 1`] = `
27+
exports[`component-store > should inject the component store correctly into the spec 1`] = `
2828
"import { FooStore } from './foo.store';
2929
3030
describe('FooStore', () => {
@@ -37,7 +37,7 @@ describe('FooStore', () => {
3737
"
3838
`;
3939

40-
exports[`component-store should not be provided into the module by default 1`] = `
40+
exports[`component-store > should not be provided into the module by default 1`] = `
4141
"import { NgModule, provideBrowserGlobalErrorListeners } from '@angular/core';
4242
import { BrowserModule } from '@angular/platform-browser';
4343
@@ -59,7 +59,7 @@ export class AppModule { }
5959
"
6060
`;
6161

62-
exports[`component-store should register the component store in the provided component 1`] = `
62+
exports[`component-store > should register the component store in the provided component 1`] = `
6363
"import { Component, signal } from '@angular/core';
6464
import { FooStore } from './foo/foo.store';
6565

modules/schematics/src/component-store/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
describe('component-store', () => {
1515
const schematicRunner = new SchematicTestRunner(
1616
'@ngrx/schematics',
17-
path.join(__dirname, '../../collection.json')
17+
path.join(process.cwd(), 'dist/modules/schematics/collection.json')
1818
);
1919

2020
const defaultOptions: ComponentStoreOptions = {

modules/schematics/src/container/__snapshots__/index.spec.ts.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`Container Schematic display-block should be disabled by default 1`] = `""`;
3+
exports[`Container Schematic > display-block > should be disabled by default 1`] = `""`;
44

5-
exports[`Container Schematic display-block should create add style if true 1`] = `
5+
exports[`Container Schematic > display-block > should create add style if true 1`] = `
66
":host {
77
display: block;
88
}
99
"
1010
`;
1111

12-
exports[`Container Schematic should import Store into the component 1`] = `
12+
exports[`Container Schematic > should import Store into the component 1`] = `
1313
"import { Component } from '@angular/core';
1414
import { Store } from '@ngrx/store';
1515
import * as fromStore from '../reducers';
@@ -26,7 +26,7 @@ export class Foo {
2626
"
2727
`;
2828

29-
exports[`Container Schematic should respect the state option if not provided 1`] = `
29+
exports[`Container Schematic > should respect the state option if not provided 1`] = `
3030
"import { Component } from '@angular/core';
3131
import { Store } from '@ngrx/store';
3232
@@ -42,7 +42,7 @@ export class Foo {
4242
"
4343
`;
4444

45-
exports[`Container Schematic should update the component spec 1`] = `
45+
exports[`Container Schematic > should update the component spec 1`] = `
4646
"import { ComponentFixture, TestBed } from '@angular/core/testing';
4747
4848
import { FooComponent } from './foo.component';
@@ -77,7 +77,7 @@ describe('FooComponent', () => {
7777
"
7878
`;
7979
80-
exports[`Container Schematic should use StoreModule if integration test 1`] = `
80+
exports[`Container Schematic > should use StoreModule if integration test 1`] = `
8181
"import { ComponentFixture, TestBed } from '@angular/core/testing';
8282
8383
import { FooComponent } from './foo.component';
@@ -113,7 +113,7 @@ describe('FooComponent', () => {
113113
"
114114
`;
115115
116-
exports[`Container Schematic standalone should be standalone by default 1`] = `
116+
exports[`Container Schematic > standalone > should be standalone by default 1`] = `
117117
"import { Component } from '@angular/core';
118118
import { Store } from '@ngrx/store';
119119
@@ -129,7 +129,7 @@ export class Foo {
129129
"
130130
`;
131131
132-
exports[`Container Schematic standalone should create a non-standalone component if false 1`] = `
132+
exports[`Container Schematic > standalone > should create a non-standalone component if false 1`] = `
133133
"import { Component } from '@angular/core';
134134
import { Store } from '@ngrx/store';
135135

modules/schematics/src/container/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
describe('Container Schematic', () => {
1313
const schematicRunner = new SchematicTestRunner(
1414
'@ngrx/schematics',
15-
path.join(__dirname, '../../collection.json')
15+
path.join(process.cwd(), 'dist/modules/schematics/collection.json')
1616
);
1717

1818
const defaultOptions: ContainerOptions = {

modules/schematics/src/data/__snapshots__/index.spec.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`Data Schematic should create a model interface 1`] = `
3+
exports[`Data Schematic > should create a model interface 1`] = `
44
"export interface Foo {
55
id?: unknown;
66
}
77
"
88
`;
99

10-
exports[`Data Schematic should create a service class 1`] = `
10+
exports[`Data Schematic > should create a service class 1`] = `
1111
"import { Injectable, inject } from '@angular/core';
1212
import {
1313
EntityCollectionServiceBase,
@@ -24,7 +24,7 @@ export class FooService extends EntityCollectionServiceBase<Foo> {
2424
"
2525
`;
2626
27-
exports[`Data Schematic should create a spec class 1`] = `
27+
exports[`Data Schematic > should create a spec class 1`] = `
2828
"import { TestBed } from '@angular/core/testing';
2929
import {
3030
EntityCollectionServiceElementsFactory

modules/schematics/src/data/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
describe('Data Schematic', () => {
1515
const schematicRunner = new SchematicTestRunner(
1616
'@ngrx/schematics',
17-
path.join(__dirname, '../../collection.json')
17+
path.join(process.cwd(), 'dist/modules/schematics/collection.json')
1818
);
1919
const defaultOptions: DataOptions = {
2020
name: 'foo',

0 commit comments

Comments
 (0)