flyingsquirrel-dev / axios-retryable Goto Github PK
View Code? Open in Web Editor NEWAxios plugin to retry requests
License: MIT License
Axios plugin to retry requests
License: MIT License
axios-retryable/lib/contants/index.ts
Line 1 in 9e69173
const는 재할당이 안되서 이것은 의미가 없는 소스인 것 같아요. object, array 같은 경우는 freeze 한 역할을 할 수 있을 것 같습니다. 저도 이렇게 쓸 수 있는 것을 처음 알았네요~
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions
axios-retryable/lib/utils/__test__/retryRequest.spec.ts
Lines 13 to 36 in 9e69173
중복 소스는 하나로 합치는 것이 좋습니다. 더 줄일 수 있을 것 같은데 좀 더 연구해시면 될 것 같아요.
자세한 것은 아래 링크를 참고
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()
})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.