Skip to content

Commit 6541f92

Browse files
Update jest snapshot format to future v29 default (#6910)
Ref: #6850 (comment) <!-- First, 🌠 thank you 🌠 for taking the time to consider a contribution to Apollo! Here are some important details to follow: * ⏰ Your time is important To save your precious time, if the contribution you are making will take more than an hour, please make sure it has been discussed in an issue first. This is especially true for feature requests! * 💡 Features Feature requests can be created and discussed within a GitHub Issue. Be sure to search for existing feature requests (and related issues!) prior to opening a new request. If an existing issue covers the need, please upvote that issue by using the 👍 emote, rather than opening a new issue. * 🔌 Integrations Apollo Server has many web-framework integrations including Express, Koa, Hapi and more. When adding a new feature, or fixing a bug, please take a peak and see if other integrations are also affected. In most cases, the fix can be applied to the other frameworks as well. Please note that, since new web-frameworks have a high maintenance cost, pull-requests for new web-frameworks should be discussed with a project maintainer first. * 🕷 Bug fixes These can be created and discussed in this repository. When fixing a bug, please _try_ to add a test which verifies the fix. If you cannot, you should still submit the PR but we may still ask you (and help you!) to create a test. * 📖 Contribution guidelines Follow https://github.com/apollographql/apollo-server/blob/main/CONTRIBUTING.md when submitting a pull request. Make sure existing tests still pass, and add tests for all new behavior. * ✏️ Explain your pull request Describe the big picture of your changes here to communicate to what your pull request is meant to accomplish. Provide 🔗 links 🔗 to associated issues! We hope you will find this to be a positive experience! Open source contribution can be intimidating and we hope to alleviate that pain as much as possible. Without following these guidelines, you may be missing context that can help you succeed with your contribution, which is why we encourage discussion first. Ultimately, there is no guarantee that we will be able to merge your pull-request, but by following these guidelines we can try to avoid disappointment. -->
1 parent faac15a commit 6541f92

8 files changed

Lines changed: 278 additions & 271 deletions

File tree

.changeset/stale-goats-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@apollo/server-integration-testsuite': patch
3+
---
4+
5+
Update snapshot format to future jest v29 default

jest.config.base.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ export default {
2121
// Ignore '.js' at the end of imports; part of ESM support.
2222
'^(\\.{1,2}/.*)\\.js$': '$1',
2323
},
24+
// this can be removed with jest v29
25+
snapshotFormat: { escapeString: false, printBasicPrototype: false },
2426
};

packages/integration-testsuite/src/apolloServerTests.ts

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,10 @@ export function defineIntegrationTestSuiteApolloServerTests(
733733
.send({ query: INTROSPECTION_QUERY });
734734
expect(res.status).toBe(500);
735735
expect(res.body).toMatchInlineSnapshot(`
736-
Object {
737-
"errors": Array [
738-
Object {
739-
"extensions": Object {
736+
{
737+
"errors": [
738+
{
739+
"extensions": {
740740
"code": "INTERNAL_SERVER_ERROR",
741741
},
742742
"message": "Internal server error",
@@ -758,10 +758,10 @@ export function defineIntegrationTestSuiteApolloServerTests(
758758
.send({ query: TEST_STRING_QUERY });
759759
expect(res.status).toBe(500);
760760
expect(res.body).toMatchInlineSnapshot(`
761-
Object {
762-
"errors": Array [
763-
Object {
764-
"extensions": Object {
761+
{
762+
"errors": [
763+
{
764+
"extensions": {
765765
"code": "INTERNAL_SERVER_ERROR",
766766
},
767767
"message": "Internal server error",
@@ -1347,11 +1347,11 @@ export function defineIntegrationTestSuiteApolloServerTests(
13471347

13481348
// The child should maintain the path and message
13491349
expect(trace.root!.child![0].error).toMatchInlineSnapshot(`
1350-
Array [
1351-
Object {
1352-
"json": "{\\"message\\":\\"should be unmodified\\",\\"locations\\":[{\\"line\\":1,\\"column\\":2}],\\"path\\":[\\"fieldWhichWillError\\"],\\"extensions\\":{\\"custom\\":\\"extension\\"}}",
1353-
"location": Array [
1354-
Object {
1350+
[
1351+
{
1352+
"json": "{"message":"should be unmodified","locations":[{"line":1,"column":2}],"path":["fieldWhichWillError"],"extensions":{"custom":"extension"}}",
1353+
"location": [
1354+
{
13551355
"column": 2,
13561356
"line": 1,
13571357
},
@@ -1398,11 +1398,11 @@ export function defineIntegrationTestSuiteApolloServerTests(
13981398

13991399
// The child should maintain the path, but have its message masked
14001400
expect(trace.root!.child![0].error).toMatchInlineSnapshot(`
1401-
Array [
1402-
Object {
1403-
"json": "{\\"message\\":\\"<masked>\\",\\"locations\\":[{\\"line\\":1,\\"column\\":2}],\\"path\\":[\\"fieldWhichWillError\\"],\\"extensions\\":{\\"maskedBy\\":\\"ApolloServerPluginUsageReporting\\"}}",
1404-
"location": Array [
1405-
Object {
1401+
[
1402+
{
1403+
"json": "{"message":"<masked>","locations":[{"line":1,"column":2}],"path":["fieldWhichWillError"],"extensions":{"maskedBy":"ApolloServerPluginUsageReporting"}}",
1404+
"location": [
1405+
{
14061406
"column": 2,
14071407
"line": 1,
14081408
},
@@ -1721,18 +1721,18 @@ export function defineIntegrationTestSuiteApolloServerTests(
17211721
}),
17221722
),
17231723
).toMatchInlineSnapshot(`
1724-
Object {
1725-
"contextCreationDidFailMockCalls": Array [
1726-
Array [
1727-
Object {
1724+
{
1725+
"contextCreationDidFailMockCalls": [
1726+
[
1727+
{
17281728
"error": [GraphQLError: valid result],
17291729
},
17301730
],
17311731
],
1732-
"result": Object {
1733-
"errors": Array [
1734-
Object {
1735-
"extensions": Object {
1732+
"result": {
1733+
"errors": [
1734+
{
1735+
"extensions": {
17361736
"code": "SOME_CODE",
17371737
"formatErrorCalled": true,
17381738
},
@@ -1749,18 +1749,18 @@ export function defineIntegrationTestSuiteApolloServerTests(
17491749
it('GraphQLErrors are formatted, defaulting to INTERNAL_SERVER_ERROR', async () => {
17501750
expect(await run(new GraphQLError('some error')))
17511751
.toMatchInlineSnapshot(`
1752-
Object {
1753-
"contextCreationDidFailMockCalls": Array [
1754-
Array [
1755-
Object {
1752+
{
1753+
"contextCreationDidFailMockCalls": [
1754+
[
1755+
{
17561756
"error": [GraphQLError: some error],
17571757
},
17581758
],
17591759
],
1760-
"result": Object {
1761-
"errors": Array [
1762-
Object {
1763-
"extensions": Object {
1760+
"result": {
1761+
"errors": [
1762+
{
1763+
"extensions": {
17641764
"code": "INTERNAL_SERVER_ERROR",
17651765
"formatErrorCalled": true,
17661766
},
@@ -1787,18 +1787,18 @@ export function defineIntegrationTestSuiteApolloServerTests(
17871787
}),
17881788
),
17891789
).toMatchInlineSnapshot(`
1790-
Object {
1791-
"contextCreationDidFailMockCalls": Array [
1792-
Array [
1793-
Object {
1790+
{
1791+
"contextCreationDidFailMockCalls": [
1792+
[
1793+
{
17941794
"error": [GraphQLError: some error],
17951795
},
17961796
],
17971797
],
1798-
"result": Object {
1799-
"errors": Array [
1800-
Object {
1801-
"extensions": Object {
1798+
"result": {
1799+
"errors": [
1800+
{
1801+
"extensions": {
18021802
"code": "INTERNAL_SERVER_ERROR",
18031803
"formatErrorCalled": true,
18041804
},
@@ -1815,18 +1815,18 @@ export function defineIntegrationTestSuiteApolloServerTests(
18151815
it('non-GraphQLErrors are formatted', async () => {
18161816
expect(await run(new Error('random error')))
18171817
.toMatchInlineSnapshot(`
1818-
Object {
1819-
"contextCreationDidFailMockCalls": Array [
1820-
Array [
1821-
Object {
1818+
{
1819+
"contextCreationDidFailMockCalls": [
1820+
[
1821+
{
18221822
"error": [Error: random error],
18231823
},
18241824
],
18251825
],
1826-
"result": Object {
1827-
"errors": Array [
1828-
Object {
1829-
"extensions": Object {
1826+
"result": {
1827+
"errors": [
1828+
{
1829+
"extensions": {
18301830
"code": "INTERNAL_SERVER_ERROR",
18311831
"formatErrorCalled": true,
18321832
},

0 commit comments

Comments
 (0)