Giter Site home page Giter Site logo

axios-retryable's People

Contributors

flyingsquirrel-dev avatar semantic-release-bot avatar

Watchers

 avatar

axios-retryable's Issues

const 로 선언된 literal 의 경우(array, object 제외) as const 가 필요 없습니다.

export const ECONNABORTED = 'ECONNABORTED' as const

const는 재할당이 안되서 이것은 의미가 없는 소스인 것 같아요. object, array 같은 경우는 freeze 한 역할을 할 수 있을 것 같습니다. 저도 이렇게 쓸 수 있는 것을 처음 알았네요~
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions

테스트 중복 소스 처리

test('axiosInstance.request function should be called', async () => {
const axios = require('axios')
const mockURL = 'https://mock.url.com/'
const axiosConfig = {
url: mockURL,
}
initializeRetryStorage({
errorConfig: {
url: mockURL,
},
})
const axiosInstance = axios.create()
await retryRequest({
axiosInstance,
axiosConfig,
mode: 'multiple',
delayMilliseconds: 5000,
})
expect(axiosInstance.request).toHaveBeenCalled()
})

중복 소스는 하나로 합치는 것이 좋습니다. 더 줄일 수 있을 것 같은데 좀 더 연구해시면 될 것 같아요.
자세한 것은 아래 링크를 참고
https://jestjs.io/docs/setup-teardown
description-test도 많이 쓰지만 description-it 방식도 있으니 아래 링크를 한번 참고해보세요~
https://stackoverflow.com/questions/45778192/what-is-the-difference-between-it-and-test-in-jest#comment78514071_45778192

api는 모통 mock을 직접 만들던가(이게 가장 귀찮은 작업이죠;;)
https://jestjs.io/docs/mock-functions

아래 사이트에서 구조만 잡으면 데이터는 알아서 넣어주니 이런 사이트를 활용하는 방법도 있어요.
https://mockapi.io/projects

let axiosInstance;
const mockURL = 'https://mock.url.com/';

beforeAll() {
  const axios = require('axios')
  const axiosConfig = {
    url: mockURL,
  }
  axiosInstance = axios.create()
}

test('axiosInstance.request function should be called', async () => {
  initializeRetryStorage({
    errorConfig: {
      url: mockURL,
    },
  })

  await retryRequest({
    axiosInstance,
    axiosConfig,
    mode: 'multiple',
    delayMilliseconds: 5000,
  })

  expect(axiosInstance.request).toHaveBeenCalled()
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.