diff --git a/src/error/__tests__/printError-test.js b/src/error/__tests__/printError-test.js index e5dd0af894..e252229d23 100644 --- a/src/error/__tests__/printError-test.js +++ b/src/error/__tests__/printError-test.js @@ -32,7 +32,7 @@ describe('printError', () => { new Source('*', 'Test', { line: 9, column: 1 }), [0], ); - expect(printError(singleDigit)).to.equal(dedent` + expect(printError(singleDigit) + '\n').to.equal(dedent` Single digit line number with no padding Test:9:1 @@ -46,7 +46,7 @@ describe('printError', () => { new Source('*\n', 'Test', { line: 9, column: 1 }), [0], ); - expect(printError(doubleDigit)).to.equal(dedent` + expect(printError(doubleDigit) + '\n').to.equal(dedent` Left padded first line number Test:9:1 @@ -90,7 +90,7 @@ describe('printError', () => { fieldB.type, ]); - expect(printError(error)).to.equal(dedent` + expect(printError(error) + '\n').to.equal(dedent` Example error with two nodes SourceA:2:10 diff --git a/src/error/printError.js b/src/error/printError.js index f83a4fe775..0c9ddbab75 100644 --- a/src/error/printError.js +++ b/src/error/printError.js @@ -29,7 +29,7 @@ export function printError(error: GraphQLError): string { } return printedLocations.length === 0 ? error.message - : [error.message, ...printedLocations].join('\n\n') + '\n'; + : [error.message, ...printedLocations].join('\n\n'); } /** diff --git a/src/language/__tests__/lexer-test.js b/src/language/__tests__/lexer-test.js index 55e88dd6ed..c59057a8db 100644 --- a/src/language/__tests__/lexer-test.js +++ b/src/language/__tests__/lexer-test.js @@ -118,7 +118,7 @@ describe('Lexer', () => { } catch (error) { caughtError = error; } - expect(String(caughtError)).to.equal(dedent` + expect(String(caughtError) + '\n').to.equal(dedent` Syntax Error: Cannot parse the unexpected character "?". GraphQL request:3:5 @@ -138,7 +138,7 @@ describe('Lexer', () => { } catch (error) { caughtError = error; } - expect(String(caughtError)).to.equal(dedent` + expect(String(caughtError) + '\n').to.equal(dedent` Syntax Error: Cannot parse the unexpected character "?". foo.js:13:6 @@ -157,7 +157,7 @@ describe('Lexer', () => { } catch (error) { caughtError = error; } - expect(String(caughtError)).to.equal(dedent` + expect(String(caughtError) + '\n').to.equal(dedent` Syntax Error: Cannot parse the unexpected character "?". foo.js:1:5 diff --git a/src/language/__tests__/parser-test.js b/src/language/__tests__/parser-test.js index 535712d340..5eb2f26685 100644 --- a/src/language/__tests__/parser-test.js +++ b/src/language/__tests__/parser-test.js @@ -44,7 +44,7 @@ describe('Parser', () => { locations: [{ line: 1, column: 2 }], }); - expect(String(caughtError)).to.equal(dedent` + expect(String(caughtError) + '\n').to.equal(dedent` Syntax Error: Expected Name, found GraphQL request:1:2 @@ -81,7 +81,7 @@ describe('Parser', () => { } catch (error) { caughtError = error; } - expect(String(caughtError)).to.equal(dedent` + expect(String(caughtError) + '\n').to.equal(dedent` Syntax Error: Expected {, found MyQuery.graphql:1:6 diff --git a/src/utilities/__tests__/stripIgnoredCharacters-test.js b/src/utilities/__tests__/stripIgnoredCharacters-test.js index 44f7868fa4..2b072efc20 100644 --- a/src/utilities/__tests__/stripIgnoredCharacters-test.js +++ b/src/utilities/__tests__/stripIgnoredCharacters-test.js @@ -82,16 +82,6 @@ function expectStripped(docString) { toStayTheSame() { this.toEqual(docString); }, - toThrow(expectedStringifyError) { - let catchedError; - - try { - stripIgnoredCharacters(docString); - } catch (e) { - catchedError = e; - } - expect(String(catchedError)).to.equal(expectedStringifyError); - }, }; function inspectStr(str) { @@ -155,7 +145,15 @@ describe('stripIgnoredCharacters', () => { }); it('report document with invalid token', () => { - expectStripped('{ foo(arg: "\n"').toThrow(dedent` + let catchedError; + + try { + stripIgnoredCharacters('{ foo(arg: "\n"'); + } catch (e) { + catchedError = e; + } + + expect(String(catchedError) + '\n').to.equal(dedent` Syntax Error: Unterminated string. GraphQL request:1:13