From 5e38c2ec3707df691c950ae550a85825392c7226 Mon Sep 17 00:00:00 2001 From: Michel Diz Date: Thu, 12 Oct 2023 00:16:03 -0300 Subject: [PATCH] Fix issue with the update of the schema --- jest.config.js | 2 +- src/__tests__/query.test.ts | 3 --- src/__tests__/setup.ts | 21 +++++++++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/jest.config.js b/jest.config.js index 06ef88a..e11432c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,7 +5,7 @@ module.exports = { transform: { '^.+\\.tsx?$': 'ts-jest', }, - // globalSetup: '/src/__tests__/setup.ts', + globalSetup: '/src/__tests__/setup.ts', // globalTeardown: '/src/__tests__/teardown.ts', testPathIgnorePatterns: ["/src/__tests__/setup.ts", "/src/__tests__/teardown.ts"], }; diff --git a/src/__tests__/query.test.ts b/src/__tests__/query.test.ts index b3d87cf..1e9c2f2 100644 --- a/src/__tests__/query.test.ts +++ b/src/__tests__/query.test.ts @@ -18,7 +18,6 @@ const client = new ApolloClient({ describe('Mutations', () => { it('should add User', async () => { - console.log('uri', uri); const { data } = await client.mutate({ mutation: gql` mutation MT1 { @@ -42,9 +41,7 @@ describe('Mutations', () => { }); describe('Queries', () => { - console.log('uri', uri); it('should queryUsers', async () => { - console.log('uri', uri); const { data } = await client.query({ query: gql` { diff --git a/src/__tests__/setup.ts b/src/__tests__/setup.ts index 1f705e6..31cd9c6 100644 --- a/src/__tests__/setup.ts +++ b/src/__tests__/setup.ts @@ -1,7 +1,16 @@ module.exports = async () => { - fetch('http://localhost:4001/update-schema', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ }), - }); - }; + let uri: string; + + if (process.env.RUNNING_JEST === 'true' || process.env.NODE_ENV === 'test') { + uri = 'http://app:4001/update-schema'; + } else { + uri = 'http://localhost:4001/update-schema'; + } + + await fetch(uri, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ schema: 'type Query { hello: String }' }) + }); + +};