From e2107159586ea2a4c4d84cd2872e4370e093376f Mon Sep 17 00:00:00 2001 From: Wagner Maciel Date: Mon, 3 Feb 2020 10:59:39 -0800 Subject: [PATCH] refactor(benchpress): added tsconfig and fixed ts errors (#35127) PR Close #35127 --- modules/benchmarks/src/largeform/BUILD.bazel | 1 - .../src/largeform/largeform.e2e-spec.ts | 10 +++--- modules/benchmarks/src/styling/BUILD.bazel | 1 - .../src/styling/styling_perf.spec.ts | 16 ++++----- modules/benchmarks/tsconfig-e2e.json | 2 +- modules/benchmarks/tsconfig.json | 35 +++++++++++++++++++ 6 files changed, 49 insertions(+), 16 deletions(-) create mode 100644 modules/benchmarks/tsconfig.json diff --git a/modules/benchmarks/src/largeform/BUILD.bazel b/modules/benchmarks/src/largeform/BUILD.bazel index 4c6b8332a4..a6eb8b4679 100644 --- a/modules/benchmarks/src/largeform/BUILD.bazel +++ b/modules/benchmarks/src/largeform/BUILD.bazel @@ -20,7 +20,6 @@ ts_library( tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ "//modules/e2e_util", - "@npm//@types/jasminewd2", "@npm//protractor", ], ) diff --git a/modules/benchmarks/src/largeform/largeform.e2e-spec.ts b/modules/benchmarks/src/largeform/largeform.e2e-spec.ts index a91f4fde2e..cd2d96e177 100644 --- a/modules/benchmarks/src/largeform/largeform.e2e-spec.ts +++ b/modules/benchmarks/src/largeform/largeform.e2e-spec.ts @@ -14,16 +14,16 @@ describe('largeform benchmark', () => { afterEach(verifyNoBrowserErrors); - it('should work for ng2', () => { + it('should work for ng2', async () => { openBrowser({ url: '/', params: [{name: 'copies', value: 1}], ignoreBrowserSynchronization: true, }); - $('#createDom').click(); - expect(element.all(By.css('input[name=value0]')).get(0).getAttribute('value')) + await $('#createDom').click(); + expect(await element.all(By.css('input[name=value0]')).get(0).getAttribute('value')) .toBe('someValue0'); - $('#destroyDom').click(); - expect(element.all(By.css('input[name=value0]')).count()).toBe(0); + await $('#destroyDom').click(); + expect(await element.all(By.css('input[name=value0]')).count()).toBe(0); }); }); diff --git a/modules/benchmarks/src/styling/BUILD.bazel b/modules/benchmarks/src/styling/BUILD.bazel index 430bfa99fb..4a77b559f2 100644 --- a/modules/benchmarks/src/styling/BUILD.bazel +++ b/modules/benchmarks/src/styling/BUILD.bazel @@ -9,7 +9,6 @@ ts_library( tsconfig = "//modules/benchmarks:tsconfig-e2e.json", deps = [ "//modules/e2e_util", - "@npm//@types/jasminewd2", "@npm//protractor", ], ) diff --git a/modules/benchmarks/src/styling/styling_perf.spec.ts b/modules/benchmarks/src/styling/styling_perf.spec.ts index f0aaa31a73..e5640b9743 100644 --- a/modules/benchmarks/src/styling/styling_perf.spec.ts +++ b/modules/benchmarks/src/styling/styling_perf.spec.ts @@ -28,24 +28,24 @@ const SCENARIOS = [ describe('styling benchmark spec', () => { afterEach(verifyNoBrowserErrors); - it('should render and interact to update and detect changes', () => { + it('should render and interact to update and detect changes', async () => { openBrowser({url: '/', ignoreBrowserSynchronization: true}); create(); const items = element.all(by.css('styling-bindings button')); - expect(items.count()).toBe(2000); - expect(items.first().getAttribute('title')).toBe('bar'); + expect(await items.count()).toBe(2000); + expect(await items.first().getAttribute('title')).toBe('bar'); update(); - expect(items.first().getAttribute('title')).toBe('baz'); + expect(await items.first().getAttribute('title')).toBe('baz'); }); - it('should render and run noop change detection', () => { + it('should render and run noop change detection', async () => { openBrowser({url: '/', ignoreBrowserSynchronization: true}); create(); const items = element.all(by.css('styling-bindings button')); - expect(items.count()).toBe(2000); - expect(items.first().getAttribute('title')).toBe('bar'); + expect(await items.count()).toBe(2000); + expect(await items.first().getAttribute('title')).toBe('bar'); detectChanges(); - expect(items.first().getAttribute('title')).toBe('bar'); + expect(await items.first().getAttribute('title')).toBe('bar'); }); // Create benchmarks for each possible test scenario. diff --git a/modules/benchmarks/tsconfig-e2e.json b/modules/benchmarks/tsconfig-e2e.json index ed38112bb4..aa1068feae 100644 --- a/modules/benchmarks/tsconfig-e2e.json +++ b/modules/benchmarks/tsconfig-e2e.json @@ -1,6 +1,6 @@ { "compilerOptions": { "lib": ["es2015"], - "types": ["node", "jasminewd2"] + "types": ["node", "jasmine"] } } diff --git a/modules/benchmarks/tsconfig.json b/modules/benchmarks/tsconfig.json new file mode 100644 index 0000000000..2a5b97245d --- /dev/null +++ b/modules/benchmarks/tsconfig.json @@ -0,0 +1,35 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "declaration": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "module": "commonjs", + "moduleResolution": "node", + "outDir": "../../dist/all/", + "noImplicitAny": true, + "noFallthroughCasesInSwitch": true, + "paths": { + "selenium-webdriver": ["../../node_modules/@types/selenium-webdriver/index.d.ts"], + "rxjs/*": ["../../node_modules/rxjs/*"], + "@angular/*": ["../../packages/*"], + "zone.js/*": ["../../packages/zone.js/*"], + "e2e_util/*": ["../e2e_util/*"] + }, + "rootDir": ".", + "inlineSourceMap": true, + "lib": ["es5", "DOM", "ScriptHost"], + "skipDefaultLibCheck": true, + "skipLibCheck": true, + "target": "es5", + "types": ["angular", "jasmine"] + }, + "angularCompilerOptions": { + "skipTemplateCodegen": true + }, + "rules": { + "no-floating-promises": true, + "no-unused-expression": true, + "no-unused-variable": true + } +}