Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): add entry component example with Ivy #663

Merged
merged 1 commit into from
Dec 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

This is a part of the article: [Testing Angular faster with Jest](https://www.xfive.co/blog/testing-angular-faster-jest/).

_Note: This preset does not support AngularJS (1.x). If you want to set up Jest with AngularJS, please see [this blog post](https://medium.com/aya-experience/testing-an-angularjs-app-with-jest-3029a613251)._


## Table of Contents

Expand Down
3 changes: 1 addition & 2 deletions e2e/test-app-v10-zone-v11/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"start": "ng serve",
"build": "ng build",
"test": "jest --no-cache",
"lint": "ng lint",
"postinstall": "ngcc"
"lint": "ng lint"
},
"private": true,
"dependencies": {
Expand Down
5 changes: 2 additions & 3 deletions e2e/test-app-v10/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"start": "ng serve",
"build": "ng build",
"test": "jest --no-cache",
"lint": "ng lint",
"postinstall": "ngcc"
"lint": "ng lint"
},
"private": true,
"dependencies": {
Expand Down Expand Up @@ -36,4 +35,4 @@
"tslint": "~6.1.3",
"typescript": "~4.0.5"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-dynamic-button',
template: `
<button (click)="onClick()">
Hello
</button>
`,
})
export class DynamicButtonComponent {
onClick() {
console.log('Click!');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DynamicHostComponent } from './dynamic-host.component';
import { DynamicHostModule } from './dynamic-host.module';

describe('Dynamic components', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [ DynamicHostModule ],
});
});

it('dynamically renders a button', async () => {
const fixture = TestBed.createComponent(DynamicHostComponent);
fixture.detectChanges();
const button = fixture.debugElement.query(By.css('button')).nativeElement as HTMLButtonElement;
expect(button.textContent).toContain('Hello');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';
import { DynamicButtonComponent } from './dynamic-button.component';

@Component({
selector: 'app-dynamic-host',
template: `
<ng-container [ngComponentOutlet]="dynamicComponentType"></ng-container>
`,
})
export class DynamicHostComponent {
dynamicComponentType = DynamicButtonComponent;
}
10 changes: 10 additions & 0 deletions e2e/test-app-v10/src/app/dynamic-component/dynamic-host.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { DynamicHostComponent } from './dynamic-host.component';

@NgModule({
declarations: [DynamicHostComponent],
exports: [DynamicHostComponent],
imports: [CommonModule],
})
export class DynamicHostModule {}
5 changes: 2 additions & 3 deletions e2e/test-app-v9/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"start": "ng serve",
"build": "ng build",
"test": "jest --no-cache",
"lint": "ng lint",
"postinstall": "ngcc"
"lint": "ng lint"
},
"private": true,
"dependencies": {
Expand All @@ -34,4 +33,4 @@
"ts-node": "^9.0.0",
"typescript": "~3.8.3"
}
}
}
2 changes: 1 addition & 1 deletion e2e/test-app-v9/src/app/on-push/on-push.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { async, ComponentFixture } from '@angular/core/testing';
import { ChangeDetectionStrategy } from '@angular/core';

import { ConfigureFn, configureTests } from '@lib/testing';
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"ts-jest": "^26.2.0"
},
"peerDependencies": {
"@angular-devkit/build-angular": ">=0.901.12",
"@angular/core": ">=9.0.0",
"@angular/platform-browser-dynamic": ">=9.0.0",
"jest": "^26.0.0"
Expand All @@ -42,9 +43,9 @@
"webpack": "^4.0.0"
},
"devDependencies": {
"@angular/compiler": "^10.1.4",
"@angular/compiler-cli": "^10.1.4",
"@angular/core": "^11.0.0",
"@angular/compiler": "^10.2.3",
"@angular/compiler-cli": "^10.2.3",
"@angular/core": "^10.2.3",
"@commitlint/cli": "11.x",
"@commitlint/config-angular": "11.x",
"@jest/transform": "26.x",
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
rxjs "6.6.2"
source-map "0.7.3"

"@angular/compiler-cli@^10.1.4":
version "10.1.4"
resolved "https://registry.yarnpkg.com/@angular/compiler-cli/-/compiler-cli-10.1.4.tgz#b5aaa7de6173b83ce3ba066232b8c088f2428642"
integrity sha512-5jRL9TKSGQLlP+C3gdJmSjYv7BfzN69SuYir/o0OtBblqzsGeaA21ClPMXl/HOxjFSjnIyGgjN7Caf7VjeMJww==
"@angular/compiler-cli@^10.2.3":
version "10.2.3"
resolved "https://registry.yarnpkg.com/@angular/compiler-cli/-/compiler-cli-10.2.3.tgz#b43cf9e6ed163645959010c6421fb88819a5943c"
integrity sha512-29RL/lIbHpjoWMUz23cyRcyG50PXqvxlLk0IpyCUWDVtPp6Hc8S/JayxeSwxNST79miDobGaeiGmS0JHuCouVQ==
dependencies:
canonical-path "1.0.0"
chokidar "^3.0.0"
Expand All @@ -32,17 +32,17 @@
tslib "^2.0.0"
yargs "15.3.0"

"@angular/compiler@^10.1.4":
version "10.1.4"
resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-10.1.4.tgz#76268332edb289b282296560e41478a2e323a39c"
integrity sha512-3vkaLE1kfyfkNoU/sf982UBMtB1bvFgBKHdP+YG7qlxVL1nLlQQvzIHKV8YGgtWnK2PMoJMI51In/64M71T0hg==
"@angular/compiler@^10.2.3":
version "10.2.3"
resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-10.2.3.tgz#4f2a42d1b479d323118fe33e1e62594d029ed5f9"
integrity sha512-Bg+QbyvJVlfGQpJCagEMkkqoRi2LMQc8iuu+cVYVqQOETLO0LxmkPpMQ/7pRLTNWl36PoYEB7IjUkp+qng8xKg==
dependencies:
tslib "^2.0.0"

"@angular/core@^11.0.0":
version "11.0.4"
resolved "https://registry.yarnpkg.com/@angular/core/-/core-11.0.4.tgz#8eebb6a550dc24e4d53f642c8a78a0da2830cd5b"
integrity sha512-860cTMjdCHcvEsHOsTzpg5rThxwVgtnY4yT0SgboWiphrlzX+aNoyN/cCJHxWhmOTRlrl6/+hkeRq95E2BZkKw==
"@angular/core@^10.2.3":
version "10.2.3"
resolved "https://registry.yarnpkg.com/@angular/core/-/core-10.2.3.tgz#89469c537b304532d6aa8dbb2ea4e1e2ed90e7a6"
integrity sha512-mE6nLpul/IJllk0VYrlrP69n0P7JPz+BHYAVobwO5+0EGO65ieTD18DxzfEt4eQgthnM3VQwSZxjW4n9Y1p/dQ==
dependencies:
tslib "^2.0.0"

Expand Down