From 20293c2ff477ddaca47e57ac78a14856c90d62b4 Mon Sep 17 00:00:00 2001 From: Mason Date: Tue, 12 May 2020 10:40:01 -0500 Subject: [PATCH] remove the last of the istanbul ignores (#20) * remove the last of the istanbul ignores * remove comments from final bundle --- .github/workflows/CI.yml | 2 +- src/getContextInfo.ts | 1 - src/givenError.ts | 1 - src/isValid.ts | 6 +----- test/manual-tests/test/getContextInfo.test.js | 7 ++++++- test/manual-tests/test/givenError.test.js | 7 +++++++ tsconfig.json | 1 + 7 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 test/manual-tests/test/givenError.test.js diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1db1ea7..aee289f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,6 +1,6 @@ name: CI -on: [push] +on: [push, pull_request] jobs: build: diff --git a/src/getContextInfo.ts b/src/getContextInfo.ts index d59b484..95d89a2 100644 --- a/src/getContextInfo.ts +++ b/src/getContextInfo.ts @@ -62,7 +62,6 @@ export default function getContextInfo(ssf: Function): ContextInfo { let rawStack: string; try { const err = new Error(); - /* istanbul ignore else */ if ((Error as any).captureStackTrace) { (Error as any).captureStackTrace(err, ssf); } diff --git a/src/givenError.ts b/src/givenError.ts index d930954..73c32be 100644 --- a/src/givenError.ts +++ b/src/givenError.ts @@ -16,7 +16,6 @@ export default class GivenError extends Error { // If a start stack function (ssf) was provided we capture the current stack trace and pass // it to the `captureStackTrace` function so we can remove frames that come after it - /* istanbul ignore else */ if ((Error as any).captureStackTrace) { (Error as any).captureStackTrace(this, ssf); } diff --git a/src/isValid.ts b/src/isValid.ts index d75ee8b..5949e9a 100644 --- a/src/isValid.ts +++ b/src/isValid.ts @@ -12,11 +12,7 @@ const disallowedProps = [ '__cache__', '__trace__', // prototype props - ...allProps( - // this is a noop function so the contents do not need to be covered - /* istanbul ignore next */ - () => undefined, - ), + ...allProps(Function.prototype), ]; const isValid = (key: string): boolean => !disallowedProps.includes(key); diff --git a/test/manual-tests/test/getContextInfo.test.js b/test/manual-tests/test/getContextInfo.test.js index 7a98960..baa0f38 100644 --- a/test/manual-tests/test/getContextInfo.test.js +++ b/test/manual-tests/test/getContextInfo.test.js @@ -5,5 +5,10 @@ function exampleFn() { return getContextInfo(exampleFn); } -console.log('getContextInfo with no matching test framework'); +console.log('getContextInfo works with no matching test framework'); assert.deepStrictEqual(exampleFn(), { allowed: true }); + +delete Error.captureStackTrace + +console.log('getContextInfo works with missing captureStackTrace function'); +assert.deepStrictEqual(exampleFn(), { allowed: true }); \ No newline at end of file diff --git a/test/manual-tests/test/givenError.test.js b/test/manual-tests/test/givenError.test.js new file mode 100644 index 0000000..a4d5c97 --- /dev/null +++ b/test/manual-tests/test/givenError.test.js @@ -0,0 +1,7 @@ +const givenError = require('givens/dist/givenError.js').default +const assert = require('assert'); + +delete Error.captureStackTrace + +console.log('givenError works when captureStackTrace is missing') +assert.equal(new givenError('error').message, 'givens: error'); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index b6c9fd9..90af460 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "declaration": false, "sourceMap": true, + "removeComments": true, "outDir": "./build/tsc", "strict": true },