Skip to content

Commit

Permalink
remove the last of the istanbul ignores (#20)
Browse files Browse the repository at this point in the history
* remove the last of the istanbul ignores

* remove comments from final bundle
  • Loading branch information
maboesanman authored May 12, 2020
1 parent 40cf6f8 commit 20293c2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push]
on: [push, pull_request]

jobs:
build:
Expand Down
1 change: 0 additions & 1 deletion src/getContextInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/givenError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 1 addition & 5 deletions src/isValid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion test/manual-tests/test/getContextInfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
7 changes: 7 additions & 0 deletions test/manual-tests/test/givenError.test.js
Original file line number Diff line number Diff line change
@@ -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');
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"module": "commonjs",
"declaration": false,
"sourceMap": true,
"removeComments": true,
"outDir": "./build/tsc",
"strict": true
},
Expand Down

0 comments on commit 20293c2

Please sign in to comment.