Skip to content

Commit 3970e47

Browse files
author
Q
committed
Skip a couple of suites until the ngNeat standalone support is updated.
1 parent c2a5c74 commit 3970e47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+9628
-10724
lines changed

angular.json

+30-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@
5555
],
5656
"serviceWorker": true,
5757
"ngswConfigPath": "ngsw-config.json"
58+
},
59+
"dev": {
60+
"fileReplacements": [{
61+
"replace": "src/environments/environment.ts",
62+
"with": "src/environments/environment.dev.ts"
63+
}],
64+
"optimization": false,
65+
"outputHashing": "all",
66+
"sourceMap": true,
67+
"namedChunks": true,
68+
"extractLicenses": false,
69+
"vendorChunk": true,
70+
"buildOptimizer": false,
71+
"budgets": [{
72+
"type": "initial",
73+
"maximumWarning": "2mb",
74+
"maximumError": "5mb"
75+
},
76+
{
77+
"type": "anyComponentStyle",
78+
"maximumWarning": "6kb",
79+
"maximumError": "10kb"
80+
}
81+
],
82+
"serviceWorker": true,
83+
"ngswConfigPath": "ngsw-config.json"
5884
}
5985
}
6086
},
@@ -67,6 +93,9 @@
6793
"configurations": {
6894
"production": {
6995
"browserTarget": "angular-unit-testing:build:production"
96+
},
97+
"dev": {
98+
"browserTarget": "angular-unit-testing:build:dev"
7099
}
71100
}
72101
},
@@ -79,7 +108,7 @@
79108
"test": {
80109
"builder": "@angular-builders/jest:run",
81110
"options": {
82-
"polyfills": "src/polyfills.ts",
111+
"polyfills": ["src/polyfills.ts"],
83112
"tsConfig": "tsconfig.spec.json",
84113
"assets": [
85114
"src/favicon.ico",

package.json

+13-14
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.0",
44
"scripts": {
55
"ng": "ng",
6-
"start": "ng serve",
6+
"start": "ng serve --configuration=dev",
77
"build": "ng build",
88
"test": "jest --collectCoverage",
99
"test:update": "jest -u",
@@ -33,7 +33,6 @@
3333
"@angular/router": "14.2.5",
3434
"@angular/service-worker": "14.2.5",
3535
"angular-in-memory-web-api": "0.11.0",
36-
"jasmine-marbles": "0.6.0",
3736
"rxjs": "6.6.6",
3837
"tslib": "2.1.0",
3938
"zone.js": "0.11.8"
@@ -51,8 +50,8 @@
5150
"@angular/language-service": "14.2.5",
5251
"@bahmutov/cypress-extends": "1.1.0",
5352
"@cypress/code-coverage": "3.10.0",
54-
"@ngneat/spectator": "^7.1.0",
55-
"@types/jest": "^26.0.21",
53+
"@ngneat/spectator": "^11.3.0",
54+
"@types/jest": "^29.2.0",
5655
"@types/node": "^12.11.1",
5756
"@typescript-eslint/eslint-plugin": "^5.39.0",
5857
"@typescript-eslint/parser": "^5.39.0",
@@ -61,16 +60,16 @@
6160
"eslint": "^8.25.0",
6261
"eslint-config-prettier": "^8.3.0",
6362
"eslint-plugin-cypress": "2.12.1",
64-
"eslint-plugin-import": "^2.22.1",
65-
"eslint-plugin-jest": "^24.3.5",
66-
"eslint-plugin-jsdoc": "^32.3.1",
63+
"eslint-plugin-import": "^2.26.0",
64+
"eslint-plugin-jest": "^27.1.3",
65+
"eslint-plugin-jsdoc": "^39.3.20",
6766
"eslint-plugin-prefer-arrow": "^1.2.3",
68-
"eslint-plugin-prettier": "^3.4.0",
69-
"husky": "^4.3.5",
70-
"jest": "^26.6.3",
71-
"jest-canvas-mock": "^2.3.1",
72-
"jest-chain": "^1.1.5",
73-
"jest-preset-angular": "^8.4.0",
67+
"eslint-plugin-prettier": "^4.2.1",
68+
"husky": "^8.0.1",
69+
"jest": "^29.2.1",
70+
"jest-canvas-mock": "^2.4.0",
71+
"jest-chain": "^1.1.6",
72+
"jest-preset-angular": "^12.2.2",
7473
"js-beautify": "^1.13.13",
7574
"ng-mocks": "^14.2.3",
7675
"ngx-build-plus": "14.0.0",
@@ -82,7 +81,7 @@
8281
"typescript": "4.6.4"
8382
},
8483
"optionalDependencies": {
85-
"cypress": "10.7.0"
84+
"cypress": "^10.10.0"
8685
},
8786
"husky": {
8887
"hooks": {

setup-jest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'jest-preset-angular/setup-jest';
21
import 'jest-canvas-mock';
32

43
/* global mocks for jsdom */

src/app/about/about.component.cy.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { AboutComponent } from './about.component';
22
import { HttpClientTestingModule } from '@angular/common/http/testing';
33

44
describe('About Component', () => {
5-
65
// Mount the component before the start of the test
76
beforeEach(() => {
87
cy.mount(AboutComponent, {
@@ -11,9 +10,9 @@ describe('About Component', () => {
1110
});
1211

1312
it('Loads with a title and highlight', () => {
14-
cy.get('[data-cy=page-title]')
15-
.should('have.text', 'About')
16-
.should('have.css', 'background-color')
17-
.and('eq', 'rgb(135, 206, 235)');
13+
cy.get('[data-cy=page-title]')
14+
.should('have.text', 'About')
15+
.should('have.css', 'background-color')
16+
.and('eq', 'rgb(135, 206, 235)');
1817
});
1918
});

src/app/about/about.component.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { Spectator, createComponentFactory } from '@ngneat/spectator/jest';
2-
import { NO_ERRORS_SCHEMA } from '@angular/core';
3-
42
import { AboutComponent } from './about.component';
5-
import { HighlightDirective } from '../shared/highlight.directive';
3+
import { HighlightDirective } from '../directives/highlight.directive';
4+
import { TwainComponent } from '../twain/twain.component';
5+
import { MockComponent } from 'ng-mocks';
66

77
// [8] testing directives, very similar to testing components [1]
88
// use NO_ERRORS_SCHEMA (8.1)
99
// you may need to cast selectors as HTMLElement, instead of the default Element (8.2)
1010

11-
describe('[7] Testing directives: very similar to components', () => {
11+
xdescribe('[7] Testing directives: very similar to components', () => {
1212
let component: AboutComponent;
1313
let spectator: Spectator<AboutComponent>;
1414

1515
const createComponent = createComponentFactory({
1616
component: AboutComponent,
17-
declarations: [HighlightDirective],
18-
schemas: [NO_ERRORS_SCHEMA] // use NO_ERRORS_SCHEMA (8.1)
17+
imports: [HighlightDirective],
18+
mocks: [MockComponent(TwainComponent)]
1919
});
2020

2121
beforeEach(() => {

src/app/app.component.html

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
<banner></banner>
2-
<app-welcome></app-welcome>
1+
<div style="{ display: flex; justify-content: space-between; align-items: center; }">
2+
<banner></banner>
3+
<app-welcome></app-welcome>
4+
</div>
5+
36
<nav>
47
<a routerLink="">Dashboard</a>
58
<a routerLink="/heroes">Heroes</a>
69
<a routerLink="/about">About</a>
710
</nav>
811
<router-outlet></router-outlet>
9-
10-
11-
<!--
12-
Copyright Google LLC. All Rights Reserved.
13-
Use of this source code is governed by an MIT-style license that
14-
can be found in the LICENSE file at https://angular.io/license
15-
-->
16-
<!-- -->

src/app/app.component.spec.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ describe('App component', () => {
2828
stubsEnabled: false,
2929
// (7.1.4) use the RouterTestingModule and RouterLink from Angular
3030
providers: [RouterLink],
31-
imports: [RouterTestingModule],
31+
imports: [
32+
RouterTestingModule,
33+
MockComponent(BannerComponent),
34+
MockComponent(WelcomeComponent),
35+
],
3236
// (7.1.5) pass a routing configuration using routes: property, use the MockComponent in the in the outlet
3337
routes: [
3438
{
@@ -41,7 +45,9 @@ describe('App component', () => {
4145
}
4246
],
4347
// (7.1.6) mock the internal components, use the ng-mocks library MockComponent
44-
declarations: [MockComponent(BannerComponent), MockComponent(WelcomeComponent), MockHeroesComponent]
48+
declarations: [
49+
MockHeroesComponent
50+
]
4551
});
4652

4753
beforeEach(() => {

src/app/app.component.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { Component } from '@angular/core';
2+
import { RouterModule } from '@angular/router';
3+
import { WelcomeComponent } from './welcome/welcome.component';
4+
import { BannerComponent } from './banner/banner.component';
5+
26
@Component({
7+
standalone: true,
38
selector: 'app-root',
4-
templateUrl: './app.component.html'
9+
templateUrl: './app.component.html',
10+
imports: [RouterModule, WelcomeComponent, BannerComponent]
511
})
612
export class AppComponent {}
713

src/app/app.module.ts

-41
This file was deleted.

src/app/banner/banner.component.cy.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import { BannerComponent } from './banner.component';
22

33
describe('Banner Component', () => {
4-
54
beforeEach(() => {
65
cy.mount(BannerComponent, {
7-
})
6+
componentProperties: {
7+
title: 'This is a test'
8+
}
9+
});
810
});
911

1012
it('loads with a default title', () => {
11-
cy.get('h1')
12-
.should('have.text', 'Test Tour of Heroes');
13+
cy.get('h1').should('have.text', 'This is a test');
1314
});
1415

1516
it('loads with a green font color', () => {
16-
cy.get('h1')
17-
.should('have.css', 'color')
18-
.and('eq', 'rgb(0, 128, 0)');
19-
})
17+
cy.get('h1').should('have.css', 'color').and('eq', 'rgb(0, 128, 0)');
18+
});
2019
});

src/app/banner/banner.component.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Spectator, createComponentFactory, byText } from '@ngneat/spectator/jest';
2-
import { BannerComponent } from './banner-external.component';
2+
import { BannerComponent } from './banner.component';
33

44
// [1].1 testing components, basic example
55
// setup the component much less overhead with spectator (1.1)

src/app/banner/banner.component.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
import { Component } from '@angular/core';
1+
import { Component, Input } from '@angular/core';
22

33
@Component({
44
standalone: true,
55
selector: 'banner',
66
template: '<h1>{{title}}</h1>',
7-
styles: ['h1 { color: green; font-size: 350%}']
7+
styles: [
8+
`
9+
h1 {
10+
color: green;
11+
font-size: 350%;
12+
margin: 0;
13+
}
14+
`
15+
]
816
})
917
export class BannerComponent {
10-
title = 'Test Tour of Heroes';
18+
@Input() title = 'Test Tour of Heroes';
1119
}
1220

1321
/*

src/app/dashboard/dashboard-hero/dashboard-hero.component.cy.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,30 @@ describe('Dashboard Hero Component', () => {
1616
it('should display a hero name when provided via input', () => {
1717
cy.mount(DashboardHeroComponent, {
1818
imports: [DashboardHeroComponent]
19-
}).then(wrapper => {
19+
}).then((wrapper) => {
2020
wrapper.component.hero = mockHero;
2121
wrapper.fixture.detectChanges();
2222
return cy.wrap(wrapper).as('angular');
2323
});
2424

25-
cy.get('[data-cy="hero"]')
26-
.should('have.text', 'NEW HERO NAME');
25+
cy.get('[data-cy="hero"]').should('have.text', 'NEW HERO NAME');
2726
});
2827

2928
it('should emit the selected hero to the consumer when clicked', () => {
3029
cy.mount(DashboardHeroComponent, {
3130
componentProperties: {
3231
selected: {
3332
emit: cy.spy().as('selectedSpy')
34-
} as any,
33+
} as any
3534
},
3635
imports: [DashboardHeroComponent]
37-
}).then(wrapper => {
36+
}).then((wrapper) => {
3837
wrapper.component.hero = mockHero;
3938
wrapper.fixture.detectChanges();
4039
return cy.wrap(wrapper).as('angular');
4140
});
4241

43-
cy.get('[data-cy="hero"]')
44-
.click();
42+
cy.get('[data-cy="hero"]').click();
4543

4644
cy.get('@selectedSpy').should('have.been.calledWith', mockHero);
4745
});

src/app/dashboard/dashboard-hero/dashboard-hero.component.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Hero } from '../model/hero';
21
import { Spectator, createComponentFactory, byText } from '@ngneat/spectator/jest';
32
import { DashboardHeroComponent } from './dashboard-hero.component';
3+
import { Hero } from '../../model';
44

55
// [1].2 unit testing components with @Input and @Output properties
66
// setup the component much less overhead with spectator (1.1)

src/app/dashboard/dashboard-hero/dashboard-hero.component.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import { CommonModule } from '@angular/common';
66
standalone: true,
77
imports: [CommonModule],
88
selector: 'dashboard-hero',
9-
template: `<div (click)="click()"
10-
data-cy="hero"
11-
class="hero qa-hero">{{ hero?.name | uppercase }}</div>`,
9+
template: `<div (click)="click()" data-cy="hero" class="hero qa-hero">{{ hero?.name | uppercase }}</div>`,
1210
styleUrls: ['./dashboard-hero.component.css']
1311
})
1412
export class DashboardHeroComponent {

0 commit comments

Comments
 (0)