Skip to content

Commit

Permalink
test: reproduce the problem by jest
Browse files Browse the repository at this point in the history
  • Loading branch information
KengoTODA committed May 14, 2021
1 parent 12b3fff commit 3e5f126
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
23 changes: 23 additions & 0 deletions __tests__/checksums.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
import * as checksums from '../src/checksums'
import nock from 'nock'

test('fetches wrapper jars checksums', async () => {
const validChecksums = await checksums.fetchValidChecksums(false)
expect(validChecksums.length).toBeGreaterThan(10)
})

describe('retry', () => {
afterEach(() => {
nock.cleanAll()
})

describe('for /versions/all API', () => {
test('retry three times', async () => {
nock('https://services.gradle.org', {allowUnmocked: true})
.get('/versions/all')
.times(3)
.replyWithError({
message: 'connect ECONNREFUSED 104.18.191.9:443',
code: 'ECONNREFUSED'
})

const validChecksums = await checksums.fetchValidChecksums(false)
expect(validChecksums.length).toBeGreaterThan(10)
nock.isDone()
})
})
})
35 changes: 32 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"jest": "26.4.2",
"jest-circus": "26.4.2",
"js-yaml": "3.14.0",
"nock": "^13.0.11",
"prettier": "2.1.2",
"ts-jest": "26.4.0",
"typescript": "4.0.3"
Expand Down

0 comments on commit 3e5f126

Please sign in to comment.