-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add integration test for component benchmark rule
Adds a test for the component benchmark rule.
- Loading branch information
1 parent
98b0de7
commit f57a99a
Showing
5 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
load("//bazel/benchmark/component_benchmark:component_benchmark.bzl", "component_benchmark") | ||
|
||
component_benchmark( | ||
name = "perf_test", | ||
driver = "app.perf.spec.ts", | ||
driver_deps = [ | ||
"//bazel/benchmark/driver-utilities", | ||
"@npm//protractor", | ||
"@npm//@types/jasmine", | ||
"@npm//@types/node", | ||
], | ||
ng_deps = [ | ||
"@npm//@angular/core", | ||
"@npm//@angular/platform-browser", | ||
], | ||
ng_srcs = ["app.module.ts"], | ||
prefix = "", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {Component, NgModule} from '@angular/core'; | ||
import {BrowserModule} from '@angular/platform-browser'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
template: `<button (click)="updateText()">{{ text }}</button>`, | ||
}) | ||
class AppComponent { | ||
text = 'Hello'; | ||
|
||
updateText() { | ||
this.text = 'New'; | ||
} | ||
} | ||
|
||
@NgModule({ | ||
imports: [BrowserModule], | ||
bootstrap: [AppComponent], | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {element, By, browser} from 'protractor'; | ||
import {runBenchmark} from '../../driver-utilities/index'; | ||
|
||
describe('app performance', () => { | ||
it('should change text when pressing the button', async () => { | ||
await browser.get('/'); | ||
|
||
const button = element(By.css('button')); | ||
expect(await button.getText()).toBe('Hello'); | ||
|
||
await button.click(); | ||
expect(await button.getText()).toBe('New'); | ||
}); | ||
|
||
it('should measure pressing on the button', async () => { | ||
await runBenchmark({ | ||
id: 'button-press', | ||
work: () => element(By.css('button')).click(), | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters