Skip to content

coverage: mark ignore statements #2329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/__tests__/version-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ describe('Version', () => {
expect(major).to.be.a('number');
expect(minor).to.be.a('number');
expect(patch).to.be.a('number');

/* istanbul ignore next (Can't be verified on all versions) */
if (preReleaseTag !== null) {
expect(preReleaseTag).to.be.a('string');
}

expect(
`${major}.${minor}.${patch}` +
/* istanbul ignore next (Can't be verified on all versions) */
(preReleaseTag !== null ? '-' + preReleaseTag : ''),
).to.equal(version);
});
Expand Down
6 changes: 5 additions & 1 deletion src/error/GraphQLError.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ export function GraphQLError( // eslint-disable-line no-redeclare
writable: true,
configurable: true,
});
} else if (Error.captureStackTrace) {
return;
}

/* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
if (Error.captureStackTrace) {
Error.captureStackTrace(this, GraphQLError);
} else {
Object.defineProperty(this, 'stack', {
Expand Down
11 changes: 8 additions & 3 deletions src/jsutils/__tests__/inspect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ describe('inspect', () => {
});

it('function', () => {
expect(inspect(() => invariant(false))).to.equal('[function]');
const unnamedFuncStr = inspect(
/* istanbul ignore next */ () => invariant(false),
);
expect(unnamedFuncStr).to.equal('[function]');

function testFunc() {
/* istanbul ignore next */
function namedFunc() {
invariant(false);
}
expect(inspect(testFunc)).to.equal('[function testFunc]');
expect(inspect(namedFunc)).to.equal('[function namedFunc]');
});

it('array', () => {
Expand Down Expand Up @@ -103,6 +107,7 @@ describe('inspect', () => {

it('custom symbol inspect is take precedence', () => {
const object = {
/* istanbul ignore next */
inspect() {
invariant(false);
},
Expand Down
5 changes: 4 additions & 1 deletion src/jsutils/dedent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export default function dedent(
for (let i = 0; i < strings.length; ++i) {
str += strings[i];
if (i < values.length) {
str += values[i]; // interpolation
/* istanbul ignore next (ignore else inside Babel generated code) */
const value = values[i];

str += value; // interpolation
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/jsutils/defineToJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export default function defineToJSON(
): void {
classObject.prototype.toJSON = fn;
classObject.prototype.inspect = fn;

/* istanbul ignore else (See: https://github.com/graphql/graphql-js/issues/2317) */
if (nodejsCustomInspectSymbol) {
classObject.prototype[nodejsCustomInspectSymbol] = fn;
}
Expand Down
1 change: 1 addition & 0 deletions src/jsutils/defineToStringTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* for example.
*/
export default function defineToStringTag(classObject: Class<mixed>): void {
/* istanbul ignore else (See: https://github.com/graphql/graphql-js/issues/2317) */
if (typeof Symbol === 'function' && Symbol.toStringTag) {
Object.defineProperty(classObject.prototype, Symbol.toStringTag, {
get() {
Expand Down
1 change: 1 addition & 0 deletions src/jsutils/devAssert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export default function devAssert(condition: mixed, message: string): void {
const booleanCondition = Boolean(condition);
/* istanbul ignore else (see transformation done in './resources/inlineInvariant.js') */
if (!booleanCondition) {
throw new Error(message);
}
Expand Down
3 changes: 2 additions & 1 deletion src/jsutils/instanceOf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ declare function instanceOf(
// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
// See: https://webpack.js.org/guides/production/
export default process.env.NODE_ENV === 'production'
? // eslint-disable-next-line no-shadow
? /* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
// eslint-disable-next-line no-shadow
function instanceOf(value: mixed, constructor: mixed) {
return value instanceof constructor;
}
Expand Down
1 change: 1 addition & 0 deletions src/jsutils/invariant.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export default function invariant(condition: mixed, message?: string): void {
const booleanCondition = Boolean(condition);
/* istanbul ignore else (see transformation done in './resources/inlineInvariant.js') */
if (!booleanCondition) {
throw new Error(
message != null ? message : 'Unexpected invariant triggered.',
Expand Down
1 change: 1 addition & 0 deletions src/jsutils/nodejsCustomInspectSymbol.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow strict

/* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
const nodejsCustomInspectSymbol =
typeof Symbol === 'function' && typeof Symbol.for === 'function'
? Symbol.for('nodejs.util.inspect.custom')
Expand Down
1 change: 1 addition & 0 deletions src/type/__tests__/introspection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,7 @@ describe('Introspection', () => {
const schema = new GraphQLSchema({ query: QueryRoot });
const source = getIntrospectionQuery();

/* istanbul ignore next */
function fieldResolver(_1, _2, _3, info) {
invariant(false, `Called on ${info.parentType.name}::${info.fieldName}`);
}
Expand Down
1 change: 1 addition & 0 deletions src/type/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export class GraphQLSchema {
abstractType: GraphQLAbstractType,
possibleType: GraphQLObjectType,
): boolean {
/* istanbul ignore next */
return this.isSubType(abstractType, possibleType);
}

Expand Down