Skip to content

Commit

Permalink
Random port
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Jul 24, 2022
1 parent c82ad67 commit d56596d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/node/__tests__/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1370,21 +1370,28 @@ describe('Browser', () => {
})

it('should return 404 if request path does not match with the defined endpoint', async () => {
const hostname = '127.0.0.1'
const port = 4000 + Math.floor(Math.random() * 1000)
const endpoint = '/mypath'
const yoga = createServer({
endpoint: '/mypath',
endpoint,
hostname,
port,
logging: false,
})
const url = `http://${hostname}:${port}${endpoint}`
try {
await yoga.start()
const response = await fetch(
'http://localhost:4000/yourpath?query=' +
encodeURIComponent('{ __typename }'),
url + '?query=' + encodeURIComponent('{ __typename }'),
)
expect(response.status).toEqual(404)
expect(response.status).toEqual(200)
const response2 = await fetch(
'http://localhost:4000/mypath?query=' +
url.replace('mypath', 'yourpath') +
'?query=' +
encodeURIComponent('{ __typename }'),
)
expect(response2.status).toEqual(200)
expect(response2.status).toEqual(404)
} finally {
await yoga.stop()
}
Expand Down

0 comments on commit d56596d

Please sign in to comment.