From 8cd64e47dc5a65b76e55e5a8c5d8d9cd9186c6cb Mon Sep 17 00:00:00 2001 From: Saqib Date: Fri, 3 Apr 2020 18:52:45 +0530 Subject: [PATCH 1/2] Fix istanbul bug https://github.com/aurelia/testing/issues/94# --- src/property-accessor-parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/property-accessor-parser.ts b/src/property-accessor-parser.ts index ed60a7b6..764d6340 100644 --- a/src/property-accessor-parser.ts +++ b/src/property-accessor-parser.ts @@ -28,7 +28,7 @@ export class PropertyAccessorParser { export function getAccessorExpression(fn: string): string { /* tslint:disable:max-line-length */ - const classic = /^function\s*\([$_\w\d]+\)\s*\{(?:\s*"use strict";)?\s*(?:[$_\w\d.['"\]+;]+)?\s*return\s+[$_\w\d]+\.([$_\w\d]+)\s*;?\s*\}$/; + const classic = /^function\s*\([$_\w\d]+\)\s*\{(?:\s*"use strict";)?(?:[$_\s\w\d\/\*.['"\]+;]+)?\s*return\s+[$_\w\d]+\.([$_\w\d]+)\s*;?\s*\}$/; /* tslint:enable:max-line-length */ const arrow = /^\(?[$_\w\d]+\)?\s*=>\s*[$_\w\d]+\.([$_\w\d]+)$/; const match = classic.exec(fn) || arrow.exec(fn); From b59d63dae6c5be72529103013de10bdb8d21dd35 Mon Sep 17 00:00:00 2001 From: Saqib Date: Fri, 3 Apr 2020 21:42:27 +0530 Subject: [PATCH 2/2] include the test cases to test regex functionality of getAccessorExpression The old classic regex expression fails when istanbul coverage is set to true. I have updated the classic regex expression with the new one . The test cases wont fails when generating code coverage through istanbul --- test/property-accessor-parser.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/property-accessor-parser.ts b/test/property-accessor-parser.ts index b8c3f860..c97636e2 100644 --- a/test/property-accessor-parser.ts +++ b/test/property-accessor-parser.ts @@ -49,5 +49,8 @@ describe('PropertyAccessorParser', () => { // tslint:disable-next-line:max-line-length expect(parse('function(a){"use strict";_gen$field.f[\'10\']++;_aGen$field.g[\'10\']++;return a.b;}')) .toEqual('b'); + // tslint:disable-next-line:max-line-length + expect(parse('function(a){/* istanbul ignore next */ cov_1wjh4ld5ut.f[9]++;cov_1wjh4ld5ut.s[50]++;return a.b;}')) + .toEqual('b'); }); });